aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ui/qt/simple_dialog_qt.cpp114
1 files changed, 114 insertions, 0 deletions
diff --git a/ui/qt/simple_dialog_qt.cpp b/ui/qt/simple_dialog_qt.cpp
index 5b1198958c..cb41542124 100644
--- a/ui/qt/simple_dialog_qt.cpp
+++ b/ui/qt/simple_dialog_qt.cpp
@@ -35,6 +35,8 @@
#include "simple_dialog_qt.h"
+#include <QMessageBox>
+
/* Simple dialog function - Displays a dialog box with the supplied message
* text.
*
@@ -143,3 +145,115 @@ SimpleDialog::SimpleDialog(QWidget *parent) :
QErrorMessage(parent)
{
}
+
+static void
+do_simple_message_box(ESD_TYPE_E type, gboolean *notagain,
+ const char *secondary_msg, const char *msg_format,
+ va_list ap)
+{
+ QMessageBox *msg_dialog;
+ gchar *message;
+
+ if (notagain != NULL) {
+ if (*notagain) {
+ /*
+ * The user had checked the "Don't show this message again" checkbox
+ * in the past; don't bother showing it.
+ */
+ return;
+ }
+ }
+
+ /*
+ * XXX - this should be passed the main window.
+ * Also, this should be set to window modal by setting its window
+ * modality to Qt::WindowModal, so it shows up as a sheet in
+ * OS X.
+ */
+ msg_dialog = new QMessageBox(NULL);
+ switch (type) {
+
+ case ESD_TYPE_INFO:
+ msg_dialog->setIcon(QMessageBox::Information);
+ break;
+
+ case ESD_TYPE_WARN:
+ msg_dialog->setIcon(QMessageBox::Warning);
+ break;
+
+ case ESD_TYPE_ERROR:
+ msg_dialog->setIcon(QMessageBox::Critical);
+ break;
+
+ default:
+ g_assert_not_reached();
+ return;
+ }
+
+ /* Format the message. */
+ message = g_strdup_vprintf(msg_format, ap);
+ msg_dialog->setText(message);
+ g_free(message);
+
+ /* Add the secondary text. */
+ if (secondary_msg != NULL)
+ msg_dialog->setInformativeText(secondary_msg);
+
+#if 0
+ if (notagain != NULL) {
+ checkbox = gtk_check_button_new_with_label("Don't show this message again.");
+ gtk_container_set_border_width(GTK_CONTAINER(checkbox), 12);
+ gtk_box_pack_start(GTK_BOX(gtk_message_dialog_get_message_area(GTK_MESSAGE_DIALOG(msg_dialog))), checkbox,
+ TRUE, TRUE, 0);
+ gtk_widget_show(checkbox);
+ }
+#endif
+
+ msg_dialog->exec();
+#if 0
+ if (notagain != NULL) {
+ /*
+ * OK, did they check the checkbox?
+ */
+ *notagain = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbox));
+ }
+#endif
+ delete msg_dialog;
+}
+
+/*
+ * Alert box, with optional "don't show this message again" variable
+ * and checkbox, and optional secondary text.
+ */
+void
+simple_message_box(ESD_TYPE_E type, gboolean *notagain,
+ const char *secondary_msg, const char *msg_format, ...)
+{
+ va_list ap;
+
+ va_start(ap, msg_format);
+ do_simple_message_box(type, notagain, secondary_msg, msg_format, ap);
+ va_end(ap);
+}
+
+/*
+ * Error alert box, taking a format and a va_list argument.
+ */
+void
+vsimple_error_message_box(const char *msg_format, va_list ap)
+{
+ do_simple_message_box(ESD_TYPE_ERROR, NULL, NULL, msg_format, ap);
+}
+
+/*
+ * Error alert box, taking a format and a list of arguments.
+ */
+void
+simple_error_message_box(const char *msg_format, ...)
+{
+ va_list ap;
+
+ va_start(ap, msg_format);
+ do_simple_message_box(ESD_TYPE_ERROR, NULL, NULL, msg_format, ap);
+ va_end(ap);
+}