From 8886674379c507fe46bfc6cb2ef013537567441b Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Tue, 17 Nov 2020 14:28:43 +0100 Subject: Better dialog for warning when disabling proxy plugin. --- src/CMakeLists.txt | 1 + src/disableproxyplugindialog.cpp | 30 +++++++ src/disableproxyplugindialog.h | 43 ++++++++++ src/disableproxyplugindialog.ui | 174 +++++++++++++++++++++++++++++++++++++++ src/settingsdialogplugins.cpp | 28 +++---- 5 files changed, 258 insertions(+), 18 deletions(-) create mode 100644 src/disableproxyplugindialog.cpp create mode 100644 src/disableproxyplugindialog.h create mode 100644 src/disableproxyplugindialog.ui (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bb4b151f..a53d845d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -186,6 +186,7 @@ add_filter(NAME src/settingsdialog GROUPS settingsdialogplugins settingsdialogsteam settingsdialogworkarounds + disableproxyplugindialog ) add_filter(NAME src/utilities GROUPS diff --git a/src/disableproxyplugindialog.cpp b/src/disableproxyplugindialog.cpp new file mode 100644 index 00000000..f392113b --- /dev/null +++ b/src/disableproxyplugindialog.cpp @@ -0,0 +1,30 @@ +#include "disableproxyplugindialog.h" + +#include "ui_proxyplugindialog.h" + +using namespace MOBase; + +DisableProxyPluginDialog::DisableProxyPluginDialog( + MOBase::IPlugin* proxyPlugin, std::vector const& required, QWidget* parent) + : QDialog(parent), ui(new Ui::DisableProxyPluginDialog) +{ + ui->setupUi(this); + + ui->topLabel->setText(QObject::tr( + "Disabling the '%1' plugin will prevent the following %2 plugin(s) from working:", "", required.size()) + .arg(proxyPlugin->localizedName()) + .arg(required.size())); + + connect(ui->noBtn, &QPushButton::clicked, this, &QDialog::reject); + connect(ui->yesBtn, &QPushButton::clicked, this, &QDialog::accept); + + ui->requiredPlugins->setSelectionMode(QAbstractItemView::NoSelection); + ui->requiredPlugins->setRowCount(required.size()); + for (int i = 0; i < required.size(); ++i) { + ui->requiredPlugins->setItem(i, 0, new QTableWidgetItem(required[i]->localizedName())); + ui->requiredPlugins->setItem(i, 1, new QTableWidgetItem(required[i]->description())); + ui->requiredPlugins->setRowHeight(i, 9); + } + ui->requiredPlugins->verticalHeader()->setVisible(false); + ui->requiredPlugins->sortByColumn(0, Qt::AscendingOrder); +} diff --git a/src/disableproxyplugindialog.h b/src/disableproxyplugindialog.h new file mode 100644 index 00000000..52f552e1 --- /dev/null +++ b/src/disableproxyplugindialog.h @@ -0,0 +1,43 @@ +/* +Copyright (C) 2020 Mikaël Capelle. All rights reserved. + +This file is part of Mod Organizer. + +Mod Organizer is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Mod Organizer is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Mod Organizer. If not, see . +*/ + +#ifndef DISABLEPROXYPLUGINDIALOG_H +#define DISABLEPROXYPLUGINDIALOG_H + +#include + +#include "ipluginproxy.h" + +namespace Ui { class DisableProxyPluginDialog; } + +class DisableProxyPluginDialog : public QDialog { +public: + + DisableProxyPluginDialog( + MOBase::IPlugin* proxyPlugin, + std::vector const& required, + QWidget* parent = nullptr); + +private slots: + + Ui::DisableProxyPluginDialog* ui; + +}; + +#endif diff --git a/src/disableproxyplugindialog.ui b/src/disableproxyplugindialog.ui new file mode 100644 index 00000000..9f068787 --- /dev/null +++ b/src/disableproxyplugindialog.ui @@ -0,0 +1,174 @@ + + + DisableProxyPluginDialog + + + + 0 + 0 + 522 + 417 + + + + Really disable plugin? + + + + + + + 0 + 0 + + + + + + + + 0 + 0 + + + + + + + Qt::PlainText + + + :/MO/gui/remove + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + Disabling the '%1' plugin will prevent the following plugins from working: + + + + + + + + + + 2 + + + true + + + + Plugin + + + + + Description + + + + + + + + Do you want to continue? You will need to restart Mod Organizer for the change to take effect. + + + + + + + + 0 + 0 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 80 + 0 + + + + Yes + + + + :/MO/gui/remove:/MO/gui/remove + + + + + + + + 0 + 0 + + + + + 80 + 0 + + + + No + + + true + + + false + + + + + + + + + + + + + diff --git a/src/settingsdialogplugins.cpp b/src/settingsdialogplugins.cpp index eb0035b2..4313b85e 100644 --- a/src/settingsdialogplugins.cpp +++ b/src/settingsdialogplugins.cpp @@ -3,6 +3,7 @@ #include "noeditdelegate.h" #include +#include "disableproxyplugindialog.h" #include "organizercore.h" #include "plugincontainer.h" @@ -242,29 +243,20 @@ void PluginsSettingsTab::on_checkboxEnabled_clicked(bool checked) QMessageBox::warning( parentWidget(), QObject::tr("Cannot disable plugin"), QObject::tr("The '%1' plugin is used by the current game plugin and cannot disabled.") - .arg(plugin->localizedName()), QMessageBox::Ok); - ui->enabledCheckbox->setChecked(true); - return; + .arg(plugin->localizedName()), QMessageBox::Ok); + ui->enabledCheckbox->setChecked(true); + return; } // Check the proxied plugins: auto proxied = requirements.proxied(); - QStringList pluginNames; - for (auto& p : proxied) { - pluginNames.append(p->localizedName()); - } - pluginNames.sort(); - QString message = QObject::tr( - "

Disabling the '%1' plugin will prevent the following plugins from working:

    %1
" - "

Do you want to continue? You will need to restart ModOrganizer2 for the change to take effect.

") - .arg(plugin->localizedName()).arg("
  • " + pluginNames.join("
  • ") + "
  • "); - if (QMessageBox::critical( - parentWidget(), QObject::tr("Really disable plugin?"), message, - QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) { - ui->enabledCheckbox->setChecked(true); - return; + if (!proxied.empty()) { + DisableProxyPluginDialog dialog(plugin, proxied, parentWidget()); + if (dialog.exec() != QDialog::Accepted) { + ui->enabledCheckbox->setChecked(true); + return; + } } - } // Check if the plugins is required for other plugins: -- cgit v1.3.1