QTfrontend/util/MessageDialog.cpp
changeset 10307 e13d3147f15b
parent 10305 17f3ca06e39a
child 11046 47a8c19ecb60
--- a/QTfrontend/util/MessageDialog.cpp	Sun Jun 15 00:02:25 2014 +0200
+++ b/QTfrontend/util/MessageDialog.cpp	Sun Jun 15 04:33:54 2014 +0200
@@ -47,26 +47,26 @@
 
 int MessageDialog::ShowMessage(const QString & title, const QString & msg, QMessageBox::Icon icon, QWidget * parent)
 {
-    QMessageBox msgMsg(parent ? parent : HWApplication::activeWindow());
+    // if no parent try to use active window
+    parent = parent ? parent : HWApplication::activeWindow();
+
+    // didn't work? make child of hwform (e.g. for style and because modal)
+    if (!parent)
+    {
+        try
+        {
+            HWApplication * app = dynamic_cast<HWApplication*>(HWApplication::instance());
+            if (app->form)
+                parent = app->form;
+        }
+        catch (...) { /* nothing */ }
+    }
+
+    QMessageBox msgMsg(parent);
     msgMsg.setWindowTitle(title != NULL ? title : "Hedgewars");
     msgMsg.setText(msg);
     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();
 }