From 43b2df9077db98475af6ab613cf7eaf301f84879 Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Thu, 16 Aug 2018 13:55:32 -0500 Subject: Add "enable/disable selected" to plugin list context menu --- src/mainwindow.cpp | 18 ++++++++++++++++++ src/mainwindow.h | 4 ++++ src/organizer_en.ts | 5 ++++- src/pluginlist.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ src/pluginlist.h | 10 ++++++++++ 5 files changed, 77 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e22fe07f..d638e988 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -4170,6 +4170,19 @@ void MainWindow::unhideFile() } } + +void MainWindow::enableSelectedPlugins_clicked() +{ + m_OrganizerCore.pluginList()->enableSelected(ui->espList->selectionModel()); +} + + +void MainWindow::disableSelectedPlugins_clicked() +{ + m_OrganizerCore.pluginList()->disableSelected(ui->espList->selectionModel()); +} + + void MainWindow::previewDataFile() { QString fileName = QDir::fromNativeSeparators(m_ContextItem->data(0, Qt::UserRole).toString()); @@ -4761,6 +4774,11 @@ void MainWindow::on_espList_customContextMenuRequested(const QPoint &pos) m_ContextRow = m_PluginListSortProxy->mapToSource(ui->espList->indexAt(pos)).row(); QMenu menu; + menu.addAction(tr("Enable selected"), this, SLOT(enableSelectedPlugins_clicked())); + menu.addAction(tr("Disable selected"), this, SLOT(disableSelectedPlugins_clicked())); + + menu.addSeparator(); + menu.addAction(tr("Enable all"), m_OrganizerCore.pluginList(), SLOT(enableAll())); menu.addAction(tr("Disable all"), m_OrganizerCore.pluginList(), SLOT(disableAll())); diff --git a/src/mainwindow.h b/src/mainwindow.h index 6cf83301..085126f7 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -428,6 +428,10 @@ private slots: void hideFile(); void unhideFile(); + // pluginlist context menu + void enableSelectedPlugins_clicked(); + void disableSelectedPlugins_clicked(); + void linkToolbar(); void linkDesktop(); void linkMenu(); diff --git a/src/organizer_en.ts b/src/organizer_en.ts index 90311b95..f96ca5cd 100644 --- a/src/organizer_en.ts +++ b/src/organizer_en.ts @@ -2565,6 +2565,7 @@ You can also use online editors and converters instead. + Open in Explorer @@ -2660,8 +2661,10 @@ You can also use online editors and converters instead. + - Open in explorer + Open in Explorer + Open in explorer diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index 323cd98f..18e40a6e 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -289,6 +289,47 @@ void PluginList::enableESP(const QString &name, bool enable) } } +void PluginList::enableSelected(const QItemSelectionModel *selectionModel) +{ + if (selectionModel->hasSelection()){ + bool dirty = false; + for (auto row : selectionModel->selectedRows(COL_PRIORITY)) { + int rowPriority = row.data().toInt(); + for (int i = 0; i < m_ESPs.size(); i++) { + if (m_ESPs[i].m_Priority == rowPriority) { + if (!m_ESPs[i].m_Enabled) { + m_ESPs[i].m_Enabled = true; + dirty = true; + } + + break; + } + } + } + if (dirty) emit writePluginsList(); + } +} + +void PluginList::disableSelected(const QItemSelectionModel *selectionModel) +{ + if (selectionModel->hasSelection()){ + bool dirty = false; + for (auto row : selectionModel->selectedRows(COL_PRIORITY)) { + int rowPriority = row.data().toInt(); + for (int i = 0; i < m_ESPs.size(); i++) { + if (m_ESPs[i].m_Priority == rowPriority) { + if (!m_ESPs[i].m_ForceEnabled && m_ESPs[i].m_Enabled) { + m_ESPs[i].m_Enabled = false; + dirty = true; + } + break; + } + } + } + if (dirty) emit writePluginsList(); + } +} + void PluginList::enableAll() { diff --git a/src/pluginlist.h b/src/pluginlist.h index b8e35c32..03d6426a 100644 --- a/src/pluginlist.h +++ b/src/pluginlist.h @@ -244,6 +244,16 @@ public: // implementation of the QAbstractTableModel interface public slots: + /** + * @brief enables selected plugins + **/ + void enableSelected(const QItemSelectionModel *selectionModel); + + /** + * @brief disables selected plugins + **/ + void disableSelected(const QItemSelectionModel *selectionModel); + /** * @brief enables ALL plugins **/ -- cgit v1.3.1