| 1 | // Copyright 2020 Dolphin Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | |
| 4 | #include "DolphinQt/NKitWarningDialog.h" |
| 5 | |
| 6 | #include <QApplication> |
| 7 | #include <QCheckBox> |
| 8 | #include <QHBoxLayout> |
| 9 | #include <QIcon> |
| 10 | #include <QLabel> |
| 11 | #include <QPushButton> |
| 12 | #include <QStyle> |
| 13 | #include <QVBoxLayout> |
| 14 | |
| 15 | #include "Common/Config/Config.h" |
| 16 | #include "Core/Config/MainSettings.h" |
| 17 | #include "DolphinQt/Resources.h" |
| 18 | |
| 19 | bool NKitWarningDialog::ShowUnlessDisabled(QWidget* parent) |
| 20 | { |
| 21 | if (Config::Get(Config::MAIN_SKIP_NKIT_WARNING)) |
| 22 | return true; |
| 23 | |
| 24 | NKitWarningDialog dialog(parent); |
| 25 | return dialog.exec() == QDialog::Accepted; |
| 26 | } |
| 27 | |
| 28 | NKitWarningDialog::NKitWarningDialog(QWidget* parent) : QDialog(parent) |
| 29 | { |
| 30 | setWindowTitle(tr("NKit Warning")); |
| 31 | setWindowIcon(Resources::GetAppIcon()); |
| 32 | |
| 33 | QVBoxLayout* main_layout = new QVBoxLayout; |
| 34 | |
| 35 | QLabel* warning = new QLabel( |
| 36 | tr("You are about to run an NKit disc image. NKit disc images cause problems that don't " |
| 37 | "happen with normal disc images. These problems include:\n" |
| 38 | "\n" |
| 39 | "• The emulated loading times are longer\n" |
| 40 | "• You can't use NetPlay with people who have normal disc images\n" |
| 41 | "• Input recordings are not compatible between NKit disc images and normal disc images\n" |
| 42 | "• Savestates are not compatible between NKit disc images and normal disc images\n" |
| 43 | "• Some games can crash, such as Super Paper Mario and Metal Gear Solid: The Twin Snakes\n" |
| 44 | "• Wii games don't work at all in older versions of Dolphin and in many other programs\n" |
| 45 | "\n" |
| 46 | "Are you sure you want to continue anyway?")); |
| 47 | warning->setWordWrap(true); |
| 48 | main_layout->addWidget(warning); |
| 49 | |
| 50 | QCheckBox* checkbox_accept = new QCheckBox(tr("I am aware of the risks and want to continue")); |
| 51 | main_layout->addWidget(checkbox_accept); |
| 52 | |
| 53 | QCheckBox* checkbox_skip = new QCheckBox(tr("Don't show this again")); |
| 54 | main_layout->addWidget(checkbox_skip); |
| 55 | |
| 56 | QHBoxLayout* button_layout = new QHBoxLayout; |
| 57 | QPushButton* ok = new QPushButton(tr("OK")); |
| 58 | button_layout->addWidget(ok); |
| 59 | QPushButton* cancel = new QPushButton(tr("Cancel")); |
| 60 | button_layout->addWidget(cancel); |
| 61 | main_layout->addLayout(button_layout); |
| 62 | |
| 63 | QHBoxLayout* top_layout = new QHBoxLayout; |
| 64 | |
| 65 | QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning); |
| 66 | QLabel* icon_label = new QLabel; |
| 67 | icon_label->setPixmap(icon.pixmap(100)); |
| 68 | icon_label->setAlignment(Qt::AlignTop); |
| 69 | top_layout->addWidget(icon_label); |
| 70 | top_layout->addSpacing(10); |
| 71 | |
| 72 | top_layout->addLayout(main_layout); |
| 73 | |
| 74 | setLayout(top_layout); |
| 75 | |
| 76 | connect(ok, &QPushButton::clicked, this, &QDialog::accept); |
| 77 | connect(cancel, &QPushButton::clicked, this, &QDialog::reject); |
| 78 | |
| 79 | ok->setEnabled(false); |
| 80 | #if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) |
| 81 | connect(checkbox_accept, &QCheckBox::checkStateChanged, |
| 82 | [ok](Qt::CheckState state) { ok->setEnabled(state == Qt::Checked); }); |
| 83 | #else |
| 84 | connect(checkbox_accept, &QCheckBox::stateChanged, |
| 85 | [ok](int state) { ok->setEnabled(state == Qt::Checked); }); |
| 86 | #endif |
| 87 | |
| 88 | connect(this, &QDialog::accepted, [checkbox_skip] { |
| 89 | Config::SetBase(Config::MAIN_SKIP_NKIT_WARNING, checkbox_skip->isChecked()); |
| 90 | }); |
| 91 | } |