equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Hedgewars, a free turn based strategy game |
2 * Hedgewars, a free turn based strategy game |
3 * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com> |
3 * Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
4 * |
4 * |
5 * This program is free software; you can redistribute it and/or modify |
5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License as published by |
6 * it under the terms of the GNU General Public License as published by |
7 * the Free Software Foundation; version 2 of the License |
7 * the Free Software Foundation; version 2 of the License |
8 * |
8 * |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. |
12 * GNU General Public License for more details. |
13 * |
13 * |
14 * You should have received a copy of the GNU General Public License |
14 * You should have received a copy of the GNU General Public License |
15 * along with this program; if not, write to the Free Software |
15 * along with this program; if not, write to the Free Software |
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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, |
43 parent); |
45 parent); |
44 } |
46 } |
45 |
47 |
46 int MessageDialog::ShowMessage(const QString & title, const QString & msg, QMessageBox::Icon icon, QWidget * parent) |
48 int MessageDialog::ShowMessage(const QString & title, const QString & msg, QMessageBox::Icon icon, QWidget * parent) |
47 { |
49 { |
48 QMessageBox msgMsg(parent ? parent : HWApplication::activeWindow()); |
50 // if no parent try to use active window |
|
51 parent = parent ? parent : HWApplication::activeWindow(); |
|
52 |
|
53 // didn't work? make child of hwform (e.g. for style and because modal) |
|
54 if (!parent) |
|
55 { |
|
56 try |
|
57 { |
|
58 HWApplication * app = dynamic_cast<HWApplication*>(HWApplication::instance()); |
|
59 if (app->form) |
|
60 parent = app->form; |
|
61 } |
|
62 catch (...) { /* nothing */ } |
|
63 } |
|
64 |
|
65 QMessageBox msgMsg(parent); |
49 msgMsg.setWindowTitle(title != NULL ? title : "Hedgewars"); |
66 msgMsg.setWindowTitle(title != NULL ? title : "Hedgewars"); |
50 msgMsg.setText(msg); |
67 msgMsg.setText(msg); |
51 msgMsg.setIcon(icon); |
68 msgMsg.setIcon(icon); |
52 msgMsg.setWindowModality(Qt::WindowModal); |
69 msgMsg.setWindowModality(Qt::WindowModal); |
53 |
70 |