From c27e718fbdb3355bb75a92e8773afebb7d9c69a5 Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Thu, 16 Aug 2018 14:32:28 -0500 Subject: Add "enable/disable selected" to mod list context menu --- src/mainwindow.cpp | 22 ++++- src/mainwindow.h | 2 + src/modlist.cpp | 30 ++++++ src/modlist.h | 4 + src/organizer_en.ts | 263 ++++++++++++++++++++++++++-------------------------- 5 files changed, 190 insertions(+), 131 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d638e988..e6b454c5 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -3597,13 +3597,19 @@ void MainWindow::on_modList_customContextMenuRequested(const QPoint &pos) menu->addAction(tr("Ignore update"), this, SLOT(ignoreUpdate())); } } + + menu->addSeparator(); + + menu->addAction(tr("Enable selected"), this, SLOT(enableSelectedMods_clicked())); + menu->addAction(tr("Disable selected"), this, SLOT(disableSelectedMods_clicked())); + menu->addSeparator(); menu->addAction(tr("Rename Mod..."), this, SLOT(renameMod_clicked())); menu->addAction(tr("Reinstall Mod"), this, SLOT(reinstallMod_clicked())); - menu->addAction(tr("Remove Mod..."), this, SLOT(removeMod_clicked())); + menu->addAction(tr("Remove Mod..."), this, SLOT(removeMod_clicked())); - menu->addSeparator(); + menu->addSeparator(); if (info->getNexusID() > 0) { switch (info->endorsedState()) { @@ -4183,6 +4189,18 @@ void MainWindow::disableSelectedPlugins_clicked() } +void MainWindow::enableSelectedMods_clicked() +{ + m_OrganizerCore.modList()->enableSelected(ui->modList->selectionModel()); +} + + +void MainWindow::disableSelectedMods_clicked() +{ + m_OrganizerCore.modList()->disableSelected(ui->modList->selectionModel()); +} + + void MainWindow::previewDataFile() { QString fileName = QDir::fromNativeSeparators(m_ContextItem->data(0, Qt::UserRole).toString()); diff --git a/src/mainwindow.h b/src/mainwindow.h index 085126f7..ad0972da 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -417,6 +417,8 @@ private slots: void visitWebPage_clicked(); void openExplorer_clicked(); void information_clicked(); + void enableSelectedMods_clicked(); + void disableSelectedMods_clicked(); // savegame context menu void deleteSavegame_clicked(); void fixMods_clicked(SaveGameInfo::MissingAssets const &missingAssets); diff --git a/src/modlist.cpp b/src/modlist.cpp index 0d084c22..afed2241 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -1231,3 +1231,33 @@ bool ModList::eventFilter(QObject *obj, QEvent *event) } return QAbstractItemModel::eventFilter(obj, event); } + + +void ModList::enableSelected(const QItemSelectionModel *selectionModel) +{ + if (selectionModel->hasSelection()) { + bool dirty = false; + for (auto row : selectionModel->selectedRows(COL_PRIORITY)) { + int modID = m_Profile->modIndexByPriority(row.data().toInt()); + if (!m_Profile->modEnabled(modID)) { + m_Profile->setModEnabled(modID, true); + emit modlist_changed(row, 0); + } + } + } +} + + +void ModList::disableSelected(const QItemSelectionModel *selectionModel) +{ + if (selectionModel->hasSelection()) { + bool dirty = false; + for (auto row : selectionModel->selectedRows(COL_PRIORITY)) { + int modID = m_Profile->modIndexByPriority(row.data().toInt()); + if (m_Profile->modEnabled(modID)) { + m_Profile->setModEnabled(modID, false); + emit modlist_changed(row, 0); + } + } + } +} \ No newline at end of file diff --git a/src/modlist.h b/src/modlist.h index 2db98bd1..15376ed5 100644 --- a/src/modlist.h +++ b/src/modlist.h @@ -170,6 +170,10 @@ public slots: void dropModeUpdate(bool dropOnItems); + void enableSelected(const QItemSelectionModel *selectionModel); + + void disableSelected(const QItemSelectionModel *selectionModel); + signals: /** diff --git a/src/organizer_en.ts b/src/organizer_en.ts index f96ca5cd..0d0cae2c 100644 --- a/src/organizer_en.ts +++ b/src/organizer_en.ts @@ -1762,7 +1762,7 @@ p, li { white-space: pre-wrap; } - + Refresh @@ -1941,7 +1941,7 @@ p, li { white-space: pre-wrap; } - + Update @@ -1982,7 +1982,7 @@ Right now this has very limited functionality - + Endorse Mod Organizer @@ -2248,8 +2248,8 @@ Right now this has very limited functionality - - + + failed to rename "%1" to "%2" @@ -2257,7 +2257,7 @@ Right now this has very limited functionality - + Confirm @@ -2340,7 +2340,7 @@ Please enter a name: - + Are you sure? @@ -2368,7 +2368,7 @@ This function will guess the versioning scheme under the assumption that the ins - + Sorry @@ -2565,7 +2565,7 @@ You can also use online editors and converters instead. - + Open in Explorer @@ -2605,102 +2605,107 @@ You can also use online editors and converters instead. - + + + Enable selected + + + + + + Disable selected + + + + Rename Mod... - + Reinstall Mod - + Remove Mod... - + Un-Endorse - - + + Endorse - + Won't endorse - + Endorsement state unknown - + Ignore missing data - + Mark as converted/working - + Visit on Nexus - + Visit web page - - - Open in Explorer - Open in explorer - - - - + Information... - - + + Exception: - - + + Unknown exception - + <All> - + <Multiple> - + %1 more - + Are you sure you want to remove the following %n save(s)?<br><ul>%1</ul><br>Removed saves will be sent to the Recycle Bin. @@ -2708,12 +2713,12 @@ You can also use online editors and converters instead. - + Enable Mods... - + Delete %n save(s) @@ -2721,319 +2726,319 @@ You can also use online editors and converters instead. - + failed to remove %1 - + failed to create %1 - + Can't change download directory while downloads are in progress! - + failed to write to file %1 - + %1 written - + Select binary - + Binary - + Enter Name - + Please enter a name for the executable - + Not an executable - + This is not a recognized executable. - - + + Replace file? - + There already is a hidden version of this file. Replace it? - - + + File operation failed - - + + Failed to remove "%1". Maybe you lack the required file permissions? - + There already is a visible version of this file. Replace it? - + file not found: %1 - + failed to generate preview for %1 - + Sorry, can't preview anything. This function currently does not support extracting from bsas. - + Update available - + Open/Execute - + Add as Executable - + Preview - + Un-Hide - + Hide - + Write To File... - + Do you want to endorse Mod Organizer on %1 now? - + Thank you! - + Thank you for your endorsement! - + Request to Nexus failed: %1 - - + + failed to read %1: %2 - - + + Error - + failed to extract %1 (errorcode %2) - + Extract BSA - + This archive contains invalid hashes. Some files may be broken. - + Extract... - + This will restart MO, continue? - + Edit Categories... - + Deselect filter - + Remove - + Enable all - + Disable all - + Unlock load order - + Lock load order - + depends on missing "%1" - + incompatible with "%1" - + Please wait while LOOT is running - + loot failed. Exit code was: %1 - + failed to start loot - + failed to run loot: %1 - + Errors occured - + Backup of load order created - + Choose backup to restore - + No Backups - + There are no backups to restore - - + + Restore failed - - + + Failed to restore the backup. Errorcode: %1 - + Backup of modlist created - + A file with the same name has already been downloaded. What would you like to do? - + Overwrite - + Rename new file - + Ignore file @@ -4452,84 +4457,84 @@ Continue? - - + + Confirm - + Really enable all plugins? - + Really disable all plugins? - + The file containing locked plugin indices is broken - - + + <b>Origin</b>: %1 - + <br><b><i>This plugin can't be disabled (enforced by the game).</i></b> - + Author - + Description - + Missing Masters - + Enabled Masters - + Loads Archives - + There are Archives connected to this plugin. Their assets will be added to your game, overwriting in case of conflicts following the plugin order. Loose files will always overwrite assets from Archives. (This flag only checks for Archives from the same mod as the plugin) - + Loads INI settings - + There is an ini file connected to this plugin. Its settings will be added to your game settings, overwriting in case of conflicts. - + This ESP is flagged as an ESL. It will adhere to the ESP load order but the records will be loaded in ESL space. - + failed to restore load order for %1 @@ -5267,7 +5272,7 @@ If the folder was still in use, restart MO and try again. - + <Manage...> @@ -5308,12 +5313,12 @@ If the folder was still in use, restart MO and try again. - + failed to access %1 - + failed to set file time %1 -- cgit v1.3.1