From a612366300aef70d2574b3f738afebdb106f1214 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Mon, 15 Jun 2009 10:28:31 +0300 Subject: Added error handling to qdesktopservices example when openUrl fails. Now qdesktopservices example will show message box if openUrl call fails i.e. returns false. --- demos/embedded/desktopservices/contenttab.cpp | 12 +++++++++++- demos/embedded/desktopservices/contenttab.h | 2 +- demos/embedded/desktopservices/linktab.cpp | 9 +++++++++ demos/embedded/desktopservices/linktab.h | 1 + 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/demos/embedded/desktopservices/contenttab.cpp b/demos/embedded/desktopservices/contenttab.cpp index 450a080..bdc5e03 100644 --- a/demos/embedded/desktopservices/contenttab.cpp +++ b/demos/embedded/desktopservices/contenttab.cpp @@ -41,6 +41,7 @@ // EXTERNAL INCLUDES #include +#include #include #include #include @@ -135,10 +136,19 @@ void ContentTab::keyPressEvent(QKeyEvent *event) } } +void ContentTab::handleErrorInOpen(QListWidgetItem *item) +{ + Q_UNUSED(item); + QMessageBox::warning( this, tr("Operation Failed"), tr("Unkown error!"), QMessageBox::Close); +} + // NEW SLOTS void ContentTab::openItem(QListWidgetItem *item) { - QDesktopServices::openUrl(itemUrl(item)); + bool ret = QDesktopServices::openUrl(itemUrl(item)); + if(!ret) + handleErrorInOpen(item); } + // End of File diff --git a/demos/embedded/desktopservices/contenttab.h b/demos/embedded/desktopservices/contenttab.h index a5a402e..8d37209 100644 --- a/demos/embedded/desktopservices/contenttab.h +++ b/demos/embedded/desktopservices/contenttab.h @@ -83,7 +83,7 @@ protected: // New Methods virtual void populateListWidget(); virtual QString itemName(const QFileInfo &item); virtual QUrl itemUrl(QListWidgetItem *item); - + virtual void handleErrorInOpen(QListWidgetItem *item); protected: void keyPressEvent(QKeyEvent *event); diff --git a/demos/embedded/desktopservices/linktab.cpp b/demos/embedded/desktopservices/linktab.cpp index b4ab308..58d1cc6 100644 --- a/demos/embedded/desktopservices/linktab.cpp +++ b/demos/embedded/desktopservices/linktab.cpp @@ -41,6 +41,7 @@ // EXTERNAL INCLUDES #include +#include #include // INTERNAL INCLUDES @@ -75,5 +76,13 @@ QUrl LinkTab::itemUrl(QListWidgetItem *item) return QUrl(); } } +void LinkTab::handleErrorInOpen(QListWidgetItem *item) +{ + if(m_MailToItem == item) { + QMessageBox::warning( this, tr("Operation Failed"), tr("Please check that you have\ne-mail accunt defined"), QMessageBox::Close); + } else { + ContentTab::handleErrorInOpen(item); + } +} // End of file diff --git a/demos/embedded/desktopservices/linktab.h b/demos/embedded/desktopservices/linktab.h index 2ce1094..a9c9868 100644 --- a/demos/embedded/desktopservices/linktab.h +++ b/demos/embedded/desktopservices/linktab.h @@ -71,6 +71,7 @@ public: // Constructors & Destructors protected: // Derived Methods virtual void populateListWidget(); virtual QUrl itemUrl(QListWidgetItem *item); + virtual void handleErrorInOpen(QListWidgetItem *item); private: // Used variables QListWidgetItem *m_WebItem; -- cgit v0.12 From cdb6cf0cd190b9d7373a4a295ef3ef65eedc6b53 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Mon, 15 Jun 2009 10:30:46 +0300 Subject: Added placeholder to create e-mail account in qdesktopservices. Currently e-mail sending with qdesktopservices::openUrl works in Symbian only if e-mail account already exists. The CSendUI API which is similar to RSendAs API we currently use, would provide that e-mail account creation service for us automatically but it requires so extensive capabilities that we cannot use it. --- src/gui/util/qdesktopservices_s60.cpp | 75 ++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 31 deletions(-) diff --git a/src/gui/util/qdesktopservices_s60.cpp b/src/gui/util/qdesktopservices_s60.cpp index d53c046..3588ec9 100644 --- a/src/gui/util/qdesktopservices_s60.cpp +++ b/src/gui/util/qdesktopservices_s60.cpp @@ -89,38 +89,51 @@ static void handleMailtoSchemeL(const QUrl &url) User::LeaveIfError(sendAs.Connect()); CleanupClosePushL(sendAs); - RSendAsMessage sendAsMessage; - sendAsMessage.CreateL(sendAs, KUidMsgTypeSMTP); - CleanupClosePushL(sendAsMessage); - - - // Subject - sendAsMessage.SetSubjectL(qt_QString2TPtrC(subject)); - - // Body - sendAsMessage.SetBodyTextL(qt_QString2TPtrC(body)); - - // To - foreach(QString item, recipients) - sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientTo ); - - foreach(QString item, tos) - sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientTo ); - - // Cc - foreach(QString item, ccs) - sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientCc ); - - // Bcc - foreach(QString item, bccs) - sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientBcc ); - - // send the message - sendAsMessage.LaunchEditorAndCloseL(); - - // sendAsMessage (already closed) - CleanupStack::Pop(); + CSendAsAccounts* accounts = CSendAsAccounts::NewL(); + CleanupStack::PushL(accounts); + sendAs.AvailableAccountsL(KUidMsgTypeSMTP, *accounts); + TInt count = accounts->Count(); + CleanupStack::PopAndDestroy(accounts); + + if(!count) { + // TODO: we should try to create account if count == 0 + // CSendUi would provide account creation service for us, but it requires ridicilous + // capabilities: LocalServices NetworkServices ReadDeviceData ReadUserData WriteDeviceData WriteUserData + User::Leave(KErrNotSupported); + } else { + RSendAsMessage sendAsMessage; + sendAsMessage.CreateL(sendAs, KUidMsgTypeSMTP); + CleanupClosePushL(sendAsMessage); + + + // Subject + sendAsMessage.SetSubjectL(qt_QString2TPtrC(subject)); + + // Body + sendAsMessage.SetBodyTextL(qt_QString2TPtrC(body)); + + // To + foreach(QString item, recipients) + sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientTo ); + + foreach(QString item, tos) + sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientTo ); + + // Cc + foreach(QString item, ccs) + sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientCc ); + + // Bcc + foreach(QString item, bccs) + sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientBcc ); + + // send the message + sendAsMessage.LaunchEditorAndCloseL(); + + // sendAsMessage (already closed) + CleanupStack::Pop(); + } // sendAs CleanupStack::PopAndDestroy(); } -- cgit v0.12 From 56942fc52e637e6b721ddd8e11b84e1855c6b84d Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Mon, 15 Jun 2009 09:40:27 +0200 Subject: Better text to label --- examples/widgets/softkeys/softkeys.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/widgets/softkeys/softkeys.cpp b/examples/widgets/softkeys/softkeys.cpp index 87d11c9..083d05c 100644 --- a/examples/widgets/softkeys/softkeys.cpp +++ b/examples/widgets/softkeys/softkeys.cpp @@ -46,7 +46,7 @@ MainWindow::MainWindow(QWidget *parent) { central = new QWidget(this); setCentralWidget(central); - infoLabel = new QLabel(tr("Funky stuff in menu!")); + infoLabel = new QLabel(tr("Open menu to start!")); layout = new QVBoxLayout; layout->addWidget(infoLabel); -- cgit v0.12 From 47ec0f00869019fd7ea08577b9906209dd4bdf55 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Mon, 15 Jun 2009 10:22:09 +0200 Subject: export QSymbianLeaveException --- src/corelib/global/qglobal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 450fd86..10dee86 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -2314,7 +2314,7 @@ QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathSysconf(); #include -class QSymbianLeaveException : public std::exception +class Q_CORE_EXPORT QSymbianLeaveException : public std::exception { public: inline QSymbianLeaveException(int err) : error(err) {} -- cgit v0.12