summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMikaël Capelle <capelle.mikael@gmail.com>2020-12-31 23:03:03 +0100
committerMikaël Capelle <capelle.mikael@gmail.com>2021-01-02 15:38:18 +0100
commit399ff3fcf7920adec128d30f3c97a7636a6f10be (patch)
treee69ae1ae362cfc2aef2c91231b712db0b6c890b5 /src
parent91081315cf7b654f5defe855dea3dc1f71b0962c (diff)
Minor clean for plugin list.
Diffstat (limited to 'src')
-rw-r--r--src/pluginlist.cpp45
-rw-r--r--src/pluginlist.h14
-rw-r--r--src/pluginlistcontextmenu.cpp16
3 files changed, 31 insertions, 44 deletions
diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp
index f6a52a80..a2e485ee 100644
--- a/src/pluginlist.cpp
+++ b/src/pluginlist.cpp
@@ -349,43 +349,24 @@ void PluginList::setEnabled(const QModelIndexList& indices, bool enabled)
}
if (!dirty.isEmpty()) {
emit writePluginsList();
- pluginStatesChanged(dirty, IPluginList::PluginState::STATE_ACTIVE);
+ pluginStatesChanged(dirty,
+ enabled ? IPluginList::PluginState::STATE_ACTIVE : IPluginList::PluginState::STATE_INACTIVE);
}
}
-void PluginList::enableAll()
+void PluginList::setEnabledAll(bool enabled)
{
- if (QMessageBox::question(nullptr, tr("Confirm"), tr("Really enable all plugins?"),
- QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
- QStringList dirty;
- for (ESPInfo &info : m_ESPs) {
- if (!info.enabled) {
- info.enabled = true;
- dirty.append(info.name);
- }
- }
- if (!dirty.isEmpty()) {
- emit writePluginsList();
- pluginStatesChanged(dirty, IPluginList::PluginState::STATE_ACTIVE);
+ QStringList dirty;
+ for (ESPInfo &info : m_ESPs) {
+ if (info.enabled != enabled) {
+ info.enabled = enabled;
+ dirty.append(info.name);
}
}
-}
-
-void PluginList::disableAll()
-{
- if (QMessageBox::question(nullptr, tr("Confirm"), tr("Really disable all plugins?"),
- QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
- QStringList dirty;
- for (ESPInfo &info : m_ESPs) {
- if (!info.forceEnabled && info.enabled) {
- info.enabled = false;
- dirty.append(info.name);
- }
- }
- if (!dirty.isEmpty()) {
- emit writePluginsList();
- pluginStatesChanged(dirty, IPluginList::PluginState::STATE_INACTIVE);
- }
+ if (!dirty.isEmpty()) {
+ emit writePluginsList();
+ pluginStatesChanged(dirty,
+ enabled ? IPluginList::PluginState::STATE_ACTIVE : IPluginList::PluginState::STATE_INACTIVE);
}
}
@@ -404,7 +385,7 @@ void PluginList::sendToPriority(const QModelIndexList& indices, int newPriority)
void PluginList::shiftPluginsPriority(const QModelIndexList& indices, int offset)
{
- // retrieve the mod index and sort them by priority to avoid issue
+ // retrieve the plugin index and sort them by priority to avoid issue
// when moving them
std::vector<int> allIndex;
for (auto& idx : indices) {
diff --git a/src/pluginlist.h b/src/pluginlist.h
index 6b0f584c..c93ce5cb 100644
--- a/src/pluginlist.h
+++ b/src/pluginlist.h
@@ -257,15 +257,9 @@ public: // implementation of the QAbstractTableModel interface
public slots:
- /**
- * @brief enables ALL plugins
- **/
- void enableAll();
-
- /**
- * @brief disables ALL plugins
- **/
- void disableAll();
+ // enable/disable all plugins
+ //
+ void setEnabledAll(bool enabled);
// enable/disable plugins at the given indices.
//
@@ -273,7 +267,7 @@ public slots:
// send plugins to the given priority
//
- void sendToPriority(const QModelIndexList& selectionModel, int priority);
+ void sendToPriority(const QModelIndexList& indices, int priority);
// shift the priority of mods at the given indices by the given offset
//
diff --git a/src/pluginlistcontextmenu.cpp b/src/pluginlistcontextmenu.cpp
index 787e5c0c..e6afd996 100644
--- a/src/pluginlistcontextmenu.cpp
+++ b/src/pluginlistcontextmenu.cpp
@@ -27,8 +27,20 @@ PluginListContextMenu::PluginListContextMenu(
addSeparator();
- addAction(tr("Enable all"), m_core.pluginList(), &PluginList::enableAll);
- addAction(tr("Disable all"), m_core.pluginList(), &PluginList::disableAll);
+ addAction(tr("Enable all"), [=]() {
+ if (QMessageBox::question(
+ m_view->topLevelWidget(), tr("Confirm"), tr("Really enable all plugins?"),
+ QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
+ m_core.pluginList()->setEnabledAll(true);
+ }
+ });
+ addAction(tr("Disable all"), [=]() {
+ if (QMessageBox::question(
+ m_view->topLevelWidget(), tr("Confirm"), tr("Really disable all plugins?"),
+ QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
+ m_core.pluginList()->setEnabledAll(false);
+ }
+ });
addSeparator();