diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/disableproxyplugindialog.cpp | 30 | ||||
| -rw-r--r-- | src/disableproxyplugindialog.h | 43 | ||||
| -rw-r--r-- | src/disableproxyplugindialog.ui | 174 | ||||
| -rw-r--r-- | src/settingsdialogplugins.cpp | 28 |
5 files changed, 258 insertions, 18 deletions
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<MOBase::IPlugin*> 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 <http://www.gnu.org/licenses/>. +*/ + +#ifndef DISABLEPROXYPLUGINDIALOG_H +#define DISABLEPROXYPLUGINDIALOG_H + +#include <QDialog> + +#include "ipluginproxy.h" + +namespace Ui { class DisableProxyPluginDialog; } + +class DisableProxyPluginDialog : public QDialog { +public: + + DisableProxyPluginDialog( + MOBase::IPlugin* proxyPlugin, + std::vector<MOBase::IPlugin*> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>DisableProxyPluginDialog</class> + <widget class="QDialog" name="DisableProxyPluginDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>522</width> + <height>417</height> + </rect> + </property> + <property name="windowTitle"> + <string>Really disable plugin?</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QWidget" name="horizontalWidget" native="true"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="label_2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string/> + </property> + <property name="textFormat"> + <enum>Qt::PlainText</enum> + </property> + <property name="pixmap"> + <pixmap resource="resources.qrc">:/MO/gui/remove</pixmap> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>10</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="topLabel"> + <property name="text"> + <string>Disabling the '%1' plugin will prevent the following plugins from working:</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QTableWidget" name="requiredPlugins"> + <property name="columnCount"> + <number>2</number> + </property> + <attribute name="horizontalHeaderStretchLastSection"> + <bool>true</bool> + </attribute> + <column> + <property name="text"> + <string>Plugin</string> + </property> + </column> + <column> + <property name="text"> + <string>Description</string> + </property> + </column> + </widget> + </item> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Do you want to continue? You will need to restart Mod Organizer for the change to take effect.</string> + </property> + </widget> + </item> + <item> + <widget class="QWidget" name="buttons" native="true"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="yesBtn"> + <property name="minimumSize"> + <size> + <width>80</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>Yes</string> + </property> + <property name="icon"> + <iconset resource="resources.qrc"> + <normaloff>:/MO/gui/remove</normaloff>:/MO/gui/remove</iconset> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="noBtn"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>80</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>No</string> + </property> + <property name="default"> + <bool>true</bool> + </property> + <property name="flat"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <resources> + <include location="resources.qrc"/> + </resources> + <connections/> +</ui> 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 <iplugin.h> +#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( - "<p>Disabling the '%1' plugin will prevent the following plugins from working:</p><ul>%1</ul>" - "<p>Do you want to continue? You will need to restart ModOrganizer2 for the change to take effect.</p>") - .arg(plugin->localizedName()).arg("<li>" + pluginNames.join("</li><li>") + "</li>"); - 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: |
