summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAl12rs <gabriel.cortesi@outlook.com>2018-12-11 16:26:41 +0100
committerAl12rs <gabriel.cortesi@outlook.com>2018-12-11 16:26:41 +0100
commit0af33ccddf1962ff7ba72edda3d0aef660914a3c (patch)
tree23e5013ca640057e3eaf6dbd37fbfa5a0f21b8c5 /src
parent413c04538359391b1544b329671b81947a2a6c24 (diff)
Added "Open Origin in Explorer" and "Open Origin Info..." options to ESPList context menu.
Diffstat (limited to 'src')
-rw-r--r--src/mainwindow.cpp68
-rw-r--r--src/mainwindow.h2
2 files changed, 70 insertions, 0 deletions
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<ModInfo::EFlag> 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<ModInfo::EFlag> 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<ModInfo::EFlag> 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<ModInfo::EFlag> 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<ModInfo::EFlag> 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();