gameconfigerrorbox.cpp
1 //------------------------------------------------------------------------------
2 // gameconfigerrorbox.cpp
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2022 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #include "gameconfigerrorbox.h"
24 
25 #include "application.h"
26 #include "gui/configuration/doomseekerconfigurationdialog.h"
27 #include "gui/mainwindow.h"
28 
29 #include <QMessageBox>
30 #include <QPushButton>
31 
32 void GameConfigErrorBox::show(EnginePlugin *game, const QString &title,
33  const QString &message, bool showConfigureButton, QWidget *parent)
34 {
35  QMessageBox msgBox(QMessageBox::Critical, title, message, QMessageBox::NoButton, parent);
36  QPushButton *btnConfigure;
37  if (showConfigureButton)
38  {
39  btnConfigure = new QPushButton(
40  QIcon(":/icons/preferences-system-4.png"),
41  tr("Configure &game"), &msgBox);
42  msgBox.addButton(btnConfigure, QMessageBox::AcceptRole);
43  msgBox.addButton(QMessageBox::Close);
44  msgBox.setDefaultButton(btnConfigure);
45  }
46  else
47  {
48  msgBox.addButton(QMessageBox::Ok);
49  }
50  msgBox.exec();
51  if (btnConfigure != nullptr && msgBox.clickedButton() == btnConfigure)
52  {
53  DoomseekerConfigurationDialog::openConfiguration(
54  parent != nullptr ? parent : gApp->mainWindow(),
55  game);
56  }
57 }