From 2c9074b2e8ba2c33d61065f07a6a985215a8fac7 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Mon, 20 Jan 2014 13:59:08 +0100 Subject: [PATCH] Work on many things. --- CMakeLists.txt | 1 + src/gui/formmain.cpp | 1 - src/gui/lineeditwithstatus.h | 6 ++++- src/gui/messagebox.cpp | 49 ++++++++++++++++++++++++++++++++++++ src/gui/messagebox.h | 23 +++++++++++++++++ src/gui/messagesview.cpp | 4 +++ src/gui/systemtrayicon.cpp | 1 - src/gui/webbrowser.cpp | 1 - 8 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 src/gui/messagebox.cpp create mode 100644 src/gui/messagebox.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 275fc935f..c978cc26e 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -290,6 +290,7 @@ set(APP_SOURCES src/gui/formcategorydetails.cpp src/gui/plaintoolbutton.cpp src/gui/lineeditwithstatus.cpp + src/gui/messagebox.cpp # CORE sources. src/core/debugging.cpp diff --git a/src/gui/formmain.cpp b/src/gui/formmain.cpp index e2b4449c3..f3b2afae1 100755 --- a/src/gui/formmain.cpp +++ b/src/gui/formmain.cpp @@ -15,7 +15,6 @@ #include "qtsingleapplication/qtsingleapplication.h" #include -#include #include #include #include diff --git a/src/gui/lineeditwithstatus.h b/src/gui/lineeditwithstatus.h index 05615851e..034fb90ff 100644 --- a/src/gui/lineeditwithstatus.h +++ b/src/gui/lineeditwithstatus.h @@ -16,7 +16,11 @@ class LineEditWithStatus : public QWidget { explicit LineEditWithStatus(QWidget *parent = 0); virtual ~LineEditWithStatus(); - + // TODO: napsat metodu setStatus(enum-statusu, qstring) + // kde enum-statusu bude Ok, Warning, Error a qstring bude text kerej se objevi jako + // tooltip na toolbuttonu + // pak bude proste navazani na textEdited() a tam si bude uzivatel + // widgetu nastavovat pres to setStatus co chce on private: BaseLineEdit *m_txtInput; diff --git a/src/gui/messagebox.cpp b/src/gui/messagebox.cpp new file mode 100644 index 000000000..d1a21bc31 --- /dev/null +++ b/src/gui/messagebox.cpp @@ -0,0 +1,49 @@ +#include "gui/messagebox.h" + +#include +#include +#include + + +MessageBox::MessageBox() { +} + +QMessageBox::StandardButton MessageBox::showMessageBox(QWidget *parent, + QMessageBox::Icon icon, + const QString &title, + const QString &text, + QMessageBox::StandardButtons buttons, + QMessageBox::StandardButton defaultButton) { + QMessageBox msgBox(icon, title, text, QMessageBox::NoButton, parent); + QDialogButtonBox *buttonBox = msgBox.findChild(); + + uint mask = QMessageBox::FirstButton; + while (mask <= QMessageBox::LastButton) { + uint sb = buttons & mask; + mask <<= 1; + if (!sb) + continue; + + // TODO: tady podle hodnoty masky switchnout prave pridanej button a podle toho mu dat ikonu. + // neco jako + switch (mask) { + case QMessageBox::Ok: + // TODO: nastav ikonu "ok" + break; + default: + break; + } + + QPushButton *button = msgBox.addButton((QMessageBox::StandardButton)sb); + + // Choose the first accept role as the default + if (msgBox.defaultButton()) + continue; + if ((defaultButton == QMessageBox::NoButton && buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole) + || (defaultButton != QMessageBox::NoButton && sb == uint(defaultButton))) + msgBox.setDefaultButton(button); + } + if (msgBox.exec() == -1) + return QMessageBox::Cancel; + return msgBox.standardButton(msgBox.clickedButton()); +} diff --git a/src/gui/messagebox.h b/src/gui/messagebox.h new file mode 100644 index 000000000..4a5f0a40c --- /dev/null +++ b/src/gui/messagebox.h @@ -0,0 +1,23 @@ +#ifndef MESSAGEBOX_H +#define MESSAGEBOX_H + +#include + + +class MessageBox { + private: + // Constructors and destructors. + explicit MessageBox(); + + public: + // TODO: tudle metodu udelat private a udelat public + // metody information, warning atd a ty budou tudle volat + // se spravnejma parametrama + static QMessageBox::StandardButton showMessageBox(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 552610470..b8b3e016f 100644 --- a/src/gui/messagesview.cpp +++ b/src/gui/messagesview.cpp @@ -4,6 +4,7 @@ #include "core/messagesmodel.h" #include "core/settings.h" #include "gui/formmain.h" +#include "gui/messagebox.h" #include #include @@ -220,6 +221,9 @@ void MessagesView::openSelectedSourceArticlesExternally() { "%1").toString(); if (browser.isEmpty() || arguments.isEmpty()) { + MessageBox::showMessageBox(this, QMessageBox::Information, + "aa", "bb", QMessageBox::Ok, QMessageBox::Ok); + QMessageBox::critical(this, tr("External browser not set"), tr("External browser is not set, head to application settings and set it up to use this feature."), diff --git a/src/gui/systemtrayicon.cpp b/src/gui/systemtrayicon.cpp index 3a1b9e1bd..dda156f3e 100644 --- a/src/gui/systemtrayicon.cpp +++ b/src/gui/systemtrayicon.cpp @@ -8,7 +8,6 @@ #include #include -#include #if defined(Q_OS_WIN) diff --git a/src/gui/webbrowser.cpp b/src/gui/webbrowser.cpp index de164fb4d..8b0e85d30 100644 --- a/src/gui/webbrowser.cpp +++ b/src/gui/webbrowser.cpp @@ -18,7 +18,6 @@ #include #include #include -#include #include