diff options
-rw-r--r-- | ui/qt/interface_toolbar.cpp | 12 | ||||
-rw-r--r-- | ui/qt/simple_dialog.cpp | 30 | ||||
-rw-r--r-- | ui/qt/simple_dialog.h | 1 | ||||
-rw-r--r-- | ui/simple_dialog.h | 4 |
4 files changed, 41 insertions, 6 deletions
diff --git a/ui/qt/interface_toolbar.cpp b/ui/qt/interface_toolbar.cpp index a7811402bd..82dc9309c7 100644 --- a/ui/qt/interface_toolbar.cpp +++ b/ui/qt/interface_toolbar.cpp @@ -550,15 +550,15 @@ void InterfaceToolbar::controlReceived(QString ifname, int num, int command, QBy break; case commandInformationMessage: - simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK, "%s", payload.data()); + simple_dialog_async(ESD_TYPE_INFO, ESD_BTN_OK, "%s", payload.data()); break; case commandWarningMessage: - simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK, "%s", payload.data()); + simple_dialog_async(ESD_TYPE_WARN, ESD_BTN_OK, "%s", payload.data()); break; case commandErrorMessage: - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", payload.data()); + simple_dialog_async(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", payload.data()); break; default: @@ -598,9 +598,9 @@ void InterfaceToolbar::controlSend(QString ifname, int num, int command, const Q if (ws_write(interface_[ifname].out_fd, ba.data(), ba.length()) != ba.length()) { - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, - "Unable to send control message:\n%s.", - g_strerror(errno)); + simple_dialog_async(ESD_TYPE_ERROR, ESD_BTN_OK, + "Unable to send control message:\n%s.", + g_strerror(errno)); } } diff --git a/ui/qt/simple_dialog.cpp b/ui/qt/simple_dialog.cpp index 3565be3c48..b09184354b 100644 --- a/ui/qt/simple_dialog.cpp +++ b/ui/qt/simple_dialog.cpp @@ -73,6 +73,19 @@ simple_dialog(ESD_TYPE_E type, gint btn_mask, const gchar *msg_format, ...) return NULL; } +gpointer +simple_dialog_async(ESD_TYPE_E type, gint btn_mask, const gchar *msg_format, ...) +{ + va_list ap; + + va_start(ap, msg_format); + SimpleDialog sd(wsApp->mainWindow(), type, btn_mask, msg_format, ap); + va_end(ap); + + sd.show(); + return NULL; +} + /* * Alert box, with optional "don't show this message again" variable * and checkbox, and optional secondary text. @@ -333,6 +346,23 @@ int SimpleDialog::exec() } } +void SimpleDialog::show() +{ + if (!message_box_) { + return; + } + + message_box_->setDetailedText(detailed_text_); + message_box_->setCheckBox(check_box_); + + message_box_->setModal(Qt::WindowModal); + message_box_->setAttribute(Qt::WA_DeleteOnClose); + message_box_->show(); + + /* Message box was shown and will be deleted once user closes it */ + message_box_ = 0; +} + const MessagePair SimpleDialog::splitMessage(QString &message) const { if (message.startsWith(primary_delimiter_)) { diff --git a/ui/qt/simple_dialog.h b/ui/qt/simple_dialog.h index 95c85189e3..7211e6153f 100644 --- a/ui/qt/simple_dialog.h +++ b/ui/qt/simple_dialog.h @@ -38,6 +38,7 @@ public: void setDetailedText(QString text) { detailed_text_ = text; } void setCheckBox(QCheckBox *cb) { check_box_ = cb; } int exec(); + void show(); private: const MessagePair splitMessage(QString &message) const; diff --git a/ui/simple_dialog.h b/ui/simple_dialog.h index 654ac3ee53..182d6e7f9b 100644 --- a/ui/simple_dialog.h +++ b/ui/simple_dialog.h @@ -96,6 +96,10 @@ extern gpointer simple_dialog(ESD_TYPE_E type, gint btn_mask, const gchar *msg_format, ...) G_GNUC_PRINTF(3, 4); +extern gpointer simple_dialog_async(ESD_TYPE_E type, gint btn_mask, + const gchar *msg_format, ...) + G_GNUC_PRINTF(3, 4); + /** Surround the primary dialog message text by * simple_dialog_primary_start() and simple_dialog_primary_end(). */ |