enforce style on message boxes some more
authorsheepluva
Sat, 14 Jun 2014 23:59:20 +0200
changeset 10305 17f3ca06e39a
parent 10304 7e40820b7ed6
child 10306 4fca8bcfaff0
enforce style on message boxes some more
QTfrontend/HWApplication.cpp
QTfrontend/HWApplication.h
QTfrontend/util/MessageDialog.cpp
--- a/QTfrontend/HWApplication.cpp	Sat Jun 14 15:49:44 2014 +0200
+++ b/QTfrontend/HWApplication.cpp	Sat Jun 14 23:59:20 2014 +0200
@@ -20,7 +20,6 @@
 #include <QFileOpenEvent>
 #include <QEvent>
 
-#include "hwform.h"
 #include "MessageDialog.h"
 
 #if !defined(Q_OS_WIN)
--- a/QTfrontend/HWApplication.h	Sat Jun 14 15:49:44 2014 +0200
+++ b/QTfrontend/HWApplication.h	Sat Jun 14 23:59:20 2014 +0200
@@ -20,6 +20,7 @@
 #define HWAPP_H
 
 #include <QApplication>
+#include "hwform.h"
 
 class HWForm;
 class QEvent;
--- a/QTfrontend/util/MessageDialog.cpp	Sat Jun 14 15:49:44 2014 +0200
+++ b/QTfrontend/util/MessageDialog.cpp	Sat Jun 14 23:59:20 2014 +0200
@@ -19,6 +19,8 @@
 #include "MessageDialog.h"
 #include "HWApplication.h"
 
+
+
 int MessageDialog::ShowFatalMessage(const QString & msg, QWidget * parent)
 {
     return ShowMessage(QMessageBox::tr("Hedgewars - Error"),
@@ -51,5 +53,20 @@
     msgMsg.setIcon(icon);
     msgMsg.setWindowModality(Qt::WindowModal);
 
+    if (!parent)
+    {
+        try
+        {
+            /* workaround to make sure style is correct
+             * I'd rather assign the stylesheet to qApp directly (in main.cpp),
+             * but the current Stylesheet will ruin the look (e.g. map selection) :(
+             */
+            HWApplication * app = dynamic_cast<HWApplication*>(HWApplication::instance());
+            if (app->form)
+                msgMsg.setStyleSheet(app->form->styleSheet());
+        }
+        catch (...) { /* nothing */ }
+    }
+
     return msgMsg.exec();
 }