From 8f2c44bcf3a75b117501fc4927bcb667ba10923c Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Wed, 22 Jan 2014 17:32:00 +0100 Subject: [PATCH] Advanced boxes. --- src/gui/messagebox.cpp | 12 ++++++++---- src/gui/messagebox.h | 21 ++++++++++----------- src/gui/messagesview.cpp | 11 +++-------- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/gui/messagebox.cpp b/src/gui/messagebox.cpp index 120cbd395..b52f66f7d 100644 --- a/src/gui/messagebox.cpp +++ b/src/gui/messagebox.cpp @@ -36,6 +36,9 @@ QIcon MessageBox::iconForRole(QDialogButtonBox::StandardButton button) { case QMessageBox::Ok: return IconThemeFactory::instance()->fromTheme("dialog-ok"); + case QMessageBox::Cancel: + return IconThemeFactory::instance()->fromTheme("edit-delete"); + case QMessageBox::Yes: case QMessageBox::YesToAll: return IconThemeFactory::instance()->fromTheme("dialog-yes"); @@ -73,8 +76,9 @@ QMessageBox::StandardButton MessageBox::show(QWidget *parent, QMessageBox::Icon icon, const QString &title, const QString &text, + const QString &informative_text, QMessageBox::StandardButtons buttons, - QMessageBox::StandardButton defaultButton) { + QMessageBox::StandardButton default_button) { // Create and find needed components. MessageBox msg_box(parent); QDialogButtonBox *button_box = msg_box.findChild(); @@ -82,14 +86,14 @@ QMessageBox::StandardButton MessageBox::show(QWidget *parent, // Initialize message box properties. msg_box.setWindowTitle(title); msg_box.setText(text); + msg_box.setInformativeText(informative_text); msg_box.setIcon(icon); msg_box.setStandardButtons(buttons); - msg_box.setDefaultButton(defaultButton); + msg_box.setDefaultButton(default_button); + // Setup button box icons. iconify(button_box); - - // Display it. if (msg_box.exec() == -1) { return QMessageBox::Cancel; diff --git a/src/gui/messagebox.h b/src/gui/messagebox.h index 706283e1a..5cf86e86f 100644 --- a/src/gui/messagebox.h +++ b/src/gui/messagebox.h @@ -13,26 +13,25 @@ class MessageBox : public QMessageBox { explicit MessageBox(QWidget *parent = 0); virtual ~MessageBox(); + // Custom icon setting. void setIcon(Icon icon); - // TODO: tudle metodu udelat private a udelat public - // metody information, warning atd a ty budou tudle volat - // se spravnejma parametrama - // a napsat taky metodu iconifyMessageButtonBox(qmessabebuttonbox) - // ktera nahraje do daneho boxu aktualni ikony + // Displays custom message box. + static QMessageBox::StandardButton show(QWidget *parent, + QMessageBox::Icon icon, + const QString &title, + const QString &text, + const QString &informative_text = QString(), + QMessageBox::StandardButtons buttons = QMessageBox::Ok, + QMessageBox::StandardButton default_button = QMessageBox::Ok); + private: // Performs icon replacements for given button box. static void iconify(QDialogButtonBox *button_box); // Returns icons for standard roles/statuses. static QIcon iconForRole(QDialogButtonBox::StandardButton button); static QIcon iconForStatus(QMessageBox::Icon status); - - static QMessageBox::StandardButton show(QWidget *parent, - QMessageBox::Icon icon, - const QString& title, const QString& text, - QMessageBox::StandardButtons buttons, - QMessageBox::StandardButton defaultButton); }; #endif // MESSAGEBOX_H diff --git a/src/gui/messagesview.cpp b/src/gui/messagesview.cpp index 594b18057..3b2f66073 100644 --- a/src/gui/messagesview.cpp +++ b/src/gui/messagesview.cpp @@ -224,8 +224,7 @@ void MessagesView::openSelectedSourceArticlesExternally() { MessageBox::show(this, QMessageBox::Critical, tr("External browser not set"), - tr("External browser is not set, head to application settings and set it up to use this feature."), - QMessageBox::Ok, QMessageBox::Ok); + tr("External browser is not set, head to application settings and set it up to use this feature.")); return; } @@ -237,9 +236,7 @@ void MessagesView::openSelectedSourceArticlesExternally() { MessageBox::show(this, QMessageBox::Critical, tr("Problem with starting external web browser"), - tr("External web browser could not be started."), - QMessageBox::Ok, - QMessageBox::Ok); + tr("External web browser could not be started.")); return; } } @@ -253,9 +250,7 @@ void MessagesView::openSelectedSourceMessagesInternally() { MessageBox::show(this, QMessageBox::Warning, tr("Meesage without URL"), - tr("Message '%s' does not contain URL.").arg(message.m_title), - QMessageBox::Ok, - QMessageBox::Ok); + tr("Message '%s' does not contain URL.").arg(message.m_title)); } else { emit openLinkNewTab(message.m_url);