diff options
| author | LostDragonist <lost.dragonist@gmail.com> | 2018-11-04 13:10:41 -0600 |
|---|---|---|
| committer | LostDragonist <lost.dragonist@gmail.com> | 2018-11-04 13:10:41 -0600 |
| commit | a48a20f13fd20e599c2055752bae5065bce43700 (patch) | |
| tree | 01c266049b6e61a7e7a0644e6c2bda3b246c7f21 /src | |
| parent | 2e09e633bd40f9844d0346ae86b19b9709d8a735 (diff) | |
Add context menu option to send to a specific priority
Diffstat (limited to 'src')
| -rw-r--r-- | src/mainwindow.cpp | 84 | ||||
| -rw-r--r-- | src/mainwindow.h | 11 | ||||
| -rw-r--r-- | src/pluginlist.cpp | 23 | ||||
| -rw-r--r-- | src/pluginlist.h | 9 |
4 files changed, 72 insertions, 55 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7c7d9c95..3d7cc13b 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -3683,6 +3683,26 @@ QMenu *MainWindow::modListContextMenu() return menu;
}
+QMenu *MainWindow::modSendToContextMenu()
+{
+ QMenu *menu = new QMenu(this);
+ menu->setTitle(tr("Send to"));
+ menu->addAction(tr("Top"), this, SLOT(sendSelectedModsToTop_clicked()));
+ menu->addAction(tr("Bottom"), this, SLOT(sendSelectedModsToBottom_clicked()));
+ menu->addAction(tr("Priority..."), this, SLOT(sendSelectedModsToPriority_clicked()));
+ return menu;
+}
+
+QMenu *MainWindow::pluginSendToContextMenu()
+{
+ QMenu *menu = new QMenu(this);
+ menu->setTitle(tr("Send to"));
+ menu->addAction(tr("Top"), this, SLOT(sendSelectedPluginsToTop_clicked()));
+ menu->addAction(tr("Bottom"), this, SLOT(sendSelectedPluginsToBottom_clicked()));
+ menu->addAction(tr("Priority..."), this, SLOT(sendSelectedPluginsToPriority_clicked()));
+ return menu;
+}
+
void MainWindow::on_modList_customContextMenuRequested(const QPoint &pos)
{
try {
@@ -3726,16 +3746,14 @@ void MainWindow::on_modList_customContextMenuRequested(const QPoint &pos) menu->addAction(tr("Rename Separator..."), this, SLOT(renameMod_clicked()));
menu->addAction(tr("Remove Separator..."), this, SLOT(removeMod_clicked()));
menu->addSeparator();
- menu->addAction(tr("Send to Top"), this, SLOT(sendModToTop_clicked()));
- menu->addAction(tr("Send to Bottom"), this, SLOT(sendModToBottom_clicked()));
+ menu->addMenu(modSendToContextMenu());
menu->addSeparator();
menu->addAction(tr("Select Color..."), this, SLOT(setColor_clicked()));
if(info->getColor().isValid())
menu->addAction(tr("Reset Color"), this, SLOT(resetColor_clicked()));
menu->addSeparator();
} else if (std::find(flags.begin(), flags.end(), ModInfo::FLAG_FOREIGN) != flags.end()) {
- menu->addAction(tr("Send to Top"), this, SLOT(sendModToTop_clicked()));
- menu->addAction(tr("Send to Bottom"), this, SLOT(sendModToBottom_clicked()));
+ menu->addMenu(modSendToContextMenu());
} else {
QMenu *addRemoveCategoriesMenu = new QMenu(tr("Change Categories"));
populateMenuCategories(addRemoveCategoriesMenu, 0);
@@ -3767,8 +3785,7 @@ void MainWindow::on_modList_customContextMenuRequested(const QPoint &pos) menu->addSeparator();
- menu->addAction(tr("Send to Top"), this, SLOT(sendModToTop_clicked()));
- menu->addAction(tr("Send to Bottom"), this, SLOT(sendModToBottom_clicked()));
+ menu->addMenu(modSendToContextMenu());
menu->addSeparator();
@@ -4358,12 +4375,23 @@ void MainWindow::disableSelectedPlugins_clicked() void MainWindow::sendSelectedPluginsToTop_clicked()
{
- m_OrganizerCore.pluginList()->sendToTop(ui->espList->selectionModel());
+ m_OrganizerCore.pluginList()->sendToPriority(ui->espList->selectionModel(), 0);
}
void MainWindow::sendSelectedPluginsToBottom_clicked()
{
- m_OrganizerCore.pluginList()->sendToBottom(ui->espList->selectionModel());
+ m_OrganizerCore.pluginList()->sendToPriority(ui->espList->selectionModel(), INT_MAX);
+}
+
+void MainWindow::sendSelectedPluginsToPriority_clicked()
+{
+ bool ok;
+ int newPriority = QInputDialog::getInt(this,
+ tr("Set Priority"), tr("Set the priority of the selected mods"),
+ 0, 0, INT_MAX, 1, &ok);
+ if (!ok) return;
+
+ m_OrganizerCore.pluginList()->sendToPriority(ui->espList->selectionModel(), newPriority);
}
@@ -4993,8 +5021,7 @@ void MainWindow::on_espList_customContextMenuRequested(const QPoint &pos) menu.addSeparator();
- menu.addAction(tr("Send to top"), this, SLOT(sendSelectedPluginsToTop_clicked()));
- menu.addAction(tr("Send to bottom"), this, SLOT(sendSelectedPluginsToBottom_clicked()));
+ menu.addMenu(pluginSendToContextMenu());
QItemSelection currentSelection = ui->espList->selectionModel()->selection();
bool hasLocked = false;
@@ -5607,30 +5634,37 @@ void MainWindow::on_clearFiltersButton_clicked() deselectFilters();
}
-void MainWindow::sendModToTop_clicked()
+void MainWindow::sendSelectedModsToPriority(int newPriority)
{
QItemSelectionModel *selection = ui->modList->selectionModel();
if (selection->hasSelection() && selection->selectedRows().count() > 1) {
std::vector<int> modsToMove;
for (QModelIndex idx : selection->selectedRows()) {
- modsToMove.push_back(idx.data(Qt::UserRole + 1).toInt());
+ modsToMove.push_back(idx.data().toInt());
}
- m_OrganizerCore.modList()->changeModPriority(modsToMove, 0);
+ m_OrganizerCore.modList()->changeModPriority(modsToMove, newPriority);
} else {
- m_OrganizerCore.modList()->changeModPriority(m_ContextRow, 0);
+ m_OrganizerCore.modList()->changeModPriority(m_ContextRow, newPriority);
}
}
-void MainWindow::sendModToBottom_clicked()
+void MainWindow::sendSelectedModsToTop_clicked()
{
- QItemSelectionModel *selection = ui->modList->selectionModel();
- if (selection->hasSelection() && selection->selectedRows().count() > 1) {
- std::vector<int> modsToMove;
- for (QModelIndex idx : selection->selectedRows()) {
- modsToMove.push_back(idx.data(Qt::UserRole + 1).toInt());
- }
- m_OrganizerCore.modList()->changeModPriority(modsToMove, INT_MAX);
- } else {
- m_OrganizerCore.modList()->changeModPriority(m_ContextRow, INT_MAX);
- }
+ sendSelectedModsToPriority(0);
+}
+
+void MainWindow::sendSelectedModsToBottom_clicked()
+{
+ sendSelectedModsToPriority(INT_MAX);
+}
+
+void MainWindow::sendSelectedModsToPriority_clicked()
+{
+ bool ok;
+ int newPriority = QInputDialog::getInt(this,
+ tr("Set Priority"), tr("Set the priority of the selected mods"),
+ 0, 0, INT_MAX, 1, &ok);
+ if (!ok) return;
+
+ sendSelectedModsToPriority(newPriority);
}
diff --git a/src/mainwindow.h b/src/mainwindow.h index c595575e..85b3fc2d 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -278,6 +278,8 @@ private: QString queryRestore(const QString &filePath);
QMenu *modListContextMenu();
+ QMenu *modSendToContextMenu();
+ QMenu *pluginSendToContextMenu();
QMenu *openFolderMenu();
@@ -294,6 +296,9 @@ private: bool registerWidgetState(const QString &name, QHeaderView *view, const char *oldSettingName = nullptr);
+ void sendSelectedModsToPriority(int newPriority);
+ void sendSelectedPluginsToPriority(int newPriority);
+
private:
static const char *PATTERN_BACKUP_GLOB;
@@ -423,8 +428,9 @@ private slots: void information_clicked();
void enableSelectedMods_clicked();
void disableSelectedMods_clicked();
- void sendModToTop_clicked();
- void sendModToBottom_clicked();
+ void sendSelectedModsToTop_clicked();
+ void sendSelectedModsToBottom_clicked();
+ void sendSelectedModsToPriority_clicked();
// savegame context menu
void deleteSavegame_clicked();
void fixMods_clicked(SaveGameInfo::MissingAssets const &missingAssets);
@@ -441,6 +447,7 @@ private slots: void disableSelectedPlugins_clicked();
void sendSelectedPluginsToTop_clicked();
void sendSelectedPluginsToBottom_clicked();
+ void sendSelectedPluginsToPriority_clicked();
void linkToolbar();
void linkDesktop();
diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index 21e716d3..480cb014 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -359,7 +359,7 @@ void PluginList::disableAll() }
}
-void PluginList::sendToTop(const QItemSelectionModel *selectionModel)
+void PluginList::sendToPriority(const QItemSelectionModel *selectionModel, int newPriority)
{
if (selectionModel->hasSelection()) {
std::vector<int> pluginsToMove;
@@ -370,30 +370,11 @@ void PluginList::sendToTop(const QItemSelectionModel *selectionModel) }
}
if (pluginsToMove.size()) {
- changePluginPriority(pluginsToMove, 0);
- emit SIGNAL(displayPlugin(0));
+ changePluginPriority(pluginsToMove, newPriority);
}
}
}
-void PluginList::sendToBottom(const QItemSelectionModel *selectionModel)
-{
- if (selectionModel->hasSelection()) {
- std::vector<int> pluginsToMove;
- for (auto row: selectionModel->selectedRows(COL_PRIORITY)) {
- int rowIndex = findPluginByPriority(row.data().toInt());
- if (!m_ESPs[rowIndex].m_ForceEnabled) {
- pluginsToMove.push_back(rowIndex);
- }
- }
- if (pluginsToMove.size()) {
- changePluginPriority(pluginsToMove, INT_MAX);
- emit SIGNAL(displayPlugin(INT_MAX));
- }
- }
-}
-
-
bool PluginList::isEnabled(const QString &name)
{
std::map<QString, int>::iterator iter = m_ESPsByName.find(name.toLower());
diff --git a/src/pluginlist.h b/src/pluginlist.h index f7817c37..228ccdec 100644 --- a/src/pluginlist.h +++ b/src/pluginlist.h @@ -265,14 +265,9 @@ public slots: void disableAll();
/**
- * @brief moves selected plugins to the top (lowest priority)
+ * @brief moves selected plugins to specified priority
**/
- void sendToTop(const QItemSelectionModel *selectionModel);
-
- /**
- * @brief moves selected plugins to the bottom (highest priority)
- **/
- void sendToBottom(const QItemSelectionModel *selectionModel);
+ void sendToPriority(const QItemSelectionModel *selectionModel, int priority);
/**
* @brief The currently managed game has changed
|
