From 399ff3fcf7920adec128d30f3c97a7636a6f10be Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Thu, 31 Dec 2020 23:03:03 +0100 Subject: Minor clean for plugin list. --- src/pluginlist.cpp | 45 +++++++++++++-------------------------------- 1 file changed, 13 insertions(+), 32 deletions(-) (limited to 'src/pluginlist.cpp') 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 allIndex; for (auto& idx : indices) { -- cgit v1.3.1