QTfrontend/util/MessageDialog.cpp
changeset 10305 17f3ca06e39a
parent 10108 c68cf030eded
child 10307 e13d3147f15b
equal deleted inserted replaced
10304:7e40820b7ed6 10305:17f3ca06e39a
    16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    17  */
    17  */
    18 
    18 
    19 #include "MessageDialog.h"
    19 #include "MessageDialog.h"
    20 #include "HWApplication.h"
    20 #include "HWApplication.h"
       
    21 
       
    22 
    21 
    23 
    22 int MessageDialog::ShowFatalMessage(const QString & msg, QWidget * parent)
    24 int MessageDialog::ShowFatalMessage(const QString & msg, QWidget * parent)
    23 {
    25 {
    24     return ShowMessage(QMessageBox::tr("Hedgewars - Error"),
    26     return ShowMessage(QMessageBox::tr("Hedgewars - Error"),
    25                        msg,
    27                        msg,
    49     msgMsg.setWindowTitle(title != NULL ? title : "Hedgewars");
    51     msgMsg.setWindowTitle(title != NULL ? title : "Hedgewars");
    50     msgMsg.setText(msg);
    52     msgMsg.setText(msg);
    51     msgMsg.setIcon(icon);
    53     msgMsg.setIcon(icon);
    52     msgMsg.setWindowModality(Qt::WindowModal);
    54     msgMsg.setWindowModality(Qt::WindowModal);
    53 
    55 
       
    56     if (!parent)
       
    57     {
       
    58         try
       
    59         {
       
    60             /* workaround to make sure style is correct
       
    61              * I'd rather assign the stylesheet to qApp directly (in main.cpp),
       
    62              * but the current Stylesheet will ruin the look (e.g. map selection) :(
       
    63              */
       
    64             HWApplication * app = dynamic_cast<HWApplication*>(HWApplication::instance());
       
    65             if (app->form)
       
    66                 msgMsg.setStyleSheet(app->form->styleSheet());
       
    67         }
       
    68         catch (...) { /* nothing */ }
       
    69     }
       
    70 
    54     return msgMsg.exec();
    71     return msgMsg.exec();
    55 }
    72 }