From 0af33ccddf1962ff7ba72edda3d0aef660914a3c Mon Sep 17 00:00:00 2001 From: Al12rs Date: Tue, 11 Dec 2018 16:26:41 +0100 Subject: Added "Open Origin in Explorer" and "Open Origin Info..." options to ESPList context menu. --- src/mainwindow.cpp | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/mainwindow.h | 2 ++ 2 files changed, 70 insertions(+) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 935c3612..55ffedc0 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2837,6 +2837,29 @@ void MainWindow::openExplorer_clicked() } } +void MainWindow::openOriginExplorer_clicked() +{ + QItemSelectionModel *selection = ui->espList->selectionModel(); + if (selection->hasSelection() && selection->selectedRows().count() > 0) { + for (QModelIndex idx : selection->selectedRows()) { + QString fileName = idx.data().toString(); + ModInfo::Ptr modInfo = ModInfo::getByIndex(ModInfo::getIndex(m_OrganizerCore.pluginList()->origin(fileName))); + std::vector flags = modInfo->getFlags(); + + ::ShellExecuteW(nullptr, L"explore", ToWString(modInfo->absolutePath()).c_str(), nullptr, nullptr, SW_SHOWNORMAL); + } + } + else { + QModelIndex idx = selection->currentIndex(); + QString fileName = idx.data().toString(); + + ModInfo::Ptr modInfo = ModInfo::getByIndex(ModInfo::getIndex(m_OrganizerCore.pluginList()->origin(fileName))); + std::vector flags = modInfo->getFlags(); + + ::ShellExecuteW(nullptr, L"explore", ToWString(modInfo->absolutePath()).c_str(), nullptr, nullptr, SW_SHOWNORMAL); + } +} + void MainWindow::openExplorer_activated() { if (ui->modList->hasFocus()) { @@ -3150,6 +3173,38 @@ void MainWindow::on_listOptionsBtn_pressed() m_ContextRow = -1; } +void MainWindow::openOriginInformation_clicked() +{ + try { + QItemSelectionModel *selection = ui->espList->selectionModel(); + if (selection->hasSelection() && selection->selectedRows().count() > 0) { + for (QModelIndex idx : selection->selectedRows()) { + QString fileName = idx.data().toString(); + ModInfo::Ptr modInfo = ModInfo::getByIndex(ModInfo::getIndex(m_OrganizerCore.pluginList()->origin(fileName))); + std::vector flags = modInfo->getFlags(); + + if (modInfo->isRegular() || (std::find(flags.begin(), flags.end(), ModInfo::FLAG_OVERWRITE) != flags.end())) { + displayModInformation(ModInfo::getIndex(m_OrganizerCore.pluginList()->origin(fileName))); + } + } + } + else { + QModelIndex idx = selection->currentIndex(); + QString fileName = idx.data().toString(); + + ModInfo::Ptr modInfo = ModInfo::getByIndex(ModInfo::getIndex(m_OrganizerCore.pluginList()->origin(fileName))); + std::vector flags = modInfo->getFlags(); + + if (modInfo->isRegular() || (std::find(flags.begin(), flags.end(), ModInfo::FLAG_OVERWRITE) != flags.end())) { + displayModInformation(ModInfo::getIndex(m_OrganizerCore.pluginList()->origin(fileName))); + } + } + } + catch (const std::exception &e) { + reportError(e.what()); + } +} + void MainWindow::on_espList_doubleClicked(const QModelIndex &index) { if (!index.isValid()) { @@ -5175,6 +5230,19 @@ void MainWindow::on_espList_customContextMenuRequested(const QPoint &pos) menu.addAction(tr("Lock load order"), this, SLOT(lockESPIndex())); } + menu.addSeparator(); + menu.addAction(tr("Open Origin in Explorer"), this, SLOT(openOriginExplorer_clicked())); + + QModelIndex idx = ui->espList->selectionModel()->currentIndex(); + ModInfo::Ptr modInfo = ModInfo::getByIndex(ModInfo::getIndex(m_OrganizerCore.pluginList()->origin(idx.data().toString()))); + std::vector flags = modInfo->getFlags(); + + if (std::find(flags.begin(), flags.end(), ModInfo::FLAG_FOREIGN) == flags.end()) { + menu.addSeparator(); + QAction *infoAction = menu.addAction(tr("Open Origin Info..."), this, SLOT(openOriginInformation_clicked())); + menu.setDefaultAction(infoAction); + } + try { menu.exec(ui->espList->mapToGlobal(pos)); } catch (const std::exception &e) { diff --git a/src/mainwindow.h b/src/mainwindow.h index 366765a2..d5484400 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -425,6 +425,8 @@ private slots: void visitOnNexus_clicked(); void visitWebPage_clicked(); void openExplorer_clicked(); + void openOriginExplorer_clicked(); + void openOriginInformation_clicked(); void information_clicked(); void enableSelectedMods_clicked(); void disableSelectedMods_clicked(); -- cgit v1.3.1