diff options
author | Janne Anttila <janne.anttila@digia.com> | 2009-06-15 07:28:31 (GMT) |
---|---|---|
committer | Janne Anttila <janne.anttila@digia.com> | 2009-06-15 07:28:31 (GMT) |
commit | a612366300aef70d2574b3f738afebdb106f1214 (patch) | |
tree | d86fce2c281ce98873fd1a41216ebc1ba95c5b09 /demos/embedded/desktopservices | |
parent | 9b34c6dffcb19664e336d4b51092e042e861f475 (diff) | |
download | Qt-a612366300aef70d2574b3f738afebdb106f1214.zip Qt-a612366300aef70d2574b3f738afebdb106f1214.tar.gz Qt-a612366300aef70d2574b3f738afebdb106f1214.tar.bz2 |
Added error handling to qdesktopservices example when openUrl fails.
Now qdesktopservices example will show message box if openUrl call
fails i.e. returns false.
Diffstat (limited to 'demos/embedded/desktopservices')
-rw-r--r-- | demos/embedded/desktopservices/contenttab.cpp | 12 | ||||
-rw-r--r-- | demos/embedded/desktopservices/contenttab.h | 2 | ||||
-rw-r--r-- | demos/embedded/desktopservices/linktab.cpp | 9 | ||||
-rw-r--r-- | 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 <QKeyEvent> +#include <QMessageBox> #include <QListWidget> #include <QVBoxLayout> #include <QFileInfoList> @@ -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 <QUrl> +#include <QMessageBox> #include <QListWidgetItem> // 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; |