summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2019-12-02 14:50:01 -0500
committerisanae <14251494+isanae@users.noreply.github.com>2019-12-02 14:50:01 -0500
commit48fd9fd08070e1a937bb7e49d44189d9a071edc5 (patch)
tree733967ad033a3ec5fca1f38746dedda3aba2e2ba
parent47b767ef2fd1071a065e546c543805f490ab3e2d (diff)
added "open with vfs" to the data tab
uniform order for file context menus
-rw-r--r--src/mainwindow.cpp37
-rw-r--r--src/mainwindow.h1
-rw-r--r--src/modinfodialogconflicts.cpp48
3 files changed, 55 insertions, 31 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index b5af9aa5..cfa27fad 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -5304,6 +5304,21 @@ void MainWindow::openDataFile()
.run();
}
+void MainWindow::runDataFileHooked()
+{
+ if (m_ContextItem == nullptr) {
+ return;
+ }
+
+ const QString path = m_ContextItem->data(0, Qt::UserRole).toString();
+ const QFileInfo targetInfo(path);
+
+ m_OrganizerCore.processRunner()
+ .setFromFile(this, targetInfo, true)
+ .setWaitForCompletion(ProcessRunner::Refresh)
+ .run();
+}
+
void MainWindow::openDataOriginExplorer_clicked()
{
if (m_ContextItem == nullptr) {
@@ -5380,23 +5395,31 @@ void MainWindow::on_dataTree_customContextMenuRequested(const QPoint &pos)
QMenu menu;
if ((m_ContextItem != nullptr) && (m_ContextItem->childCount() == 0)
&& (m_ContextItem->data(0, Qt::UserRole + 3).toBool() != true)) {
- menu.addAction(tr("Open/Execute"), this, SLOT(openDataFile()));
- menu.addAction(tr("Add as Executable"), this, SLOT(addAsExecutable()));
-
QString fileName = m_ContextItem->text(0);
+ const auto isArchive = m_ContextItem->data(0, Qt::UserRole + 1).toBool();
+ const auto isDirectory = m_ContextItem->data(0, Qt::UserRole + 3).toBool();
+
+ if (canRunFile(isArchive, fileName)) {
+ menu.addAction(tr("&Execute"), this, SLOT(openDataFile()));
+ } else if (canOpenFile(isArchive, fileName)) {
+ menu.addAction(tr("&Open"), this, SLOT(openDataFile()));
+ menu.addAction(tr("Open with &VFS"), this, SLOT(runDataFileHooked()));
+ }
+
+ menu.addAction(tr("&Add as Executable"), this, SLOT(addAsExecutable()));
+
if (m_PluginContainer.previewGenerator().previewSupported(QFileInfo(fileName).suffix())) {
menu.addAction(tr("Preview"), this, SLOT(previewDataFile()));
}
- const auto isArchive = m_ContextItem->data(0, Qt::UserRole + 1).toBool();
- const auto isDirectory = m_ContextItem->data(0, Qt::UserRole + 3).toBool();
-
if (!isArchive && !isDirectory) {
menu.addAction("Open Origin in Explorer", this, SLOT(openDataOriginExplorer_clicked()));
}
menu.addAction("Open Mod Info", this, SLOT(openDataModInfo_clicked()));
+ menu.addSeparator();
+
// offer to hide/unhide file, but not for files from archives
if (!isArchive) {
if (m_ContextItem->text(0).endsWith(ModInfo::s_HiddenExt)) {
@@ -5405,8 +5428,6 @@ void MainWindow::on_dataTree_customContextMenuRequested(const QPoint &pos)
menu.addAction(tr("Hide"), this, SLOT(hideFile()));
}
}
-
- menu.addSeparator();
}
menu.addAction(tr("Write To File..."), this, SLOT(writeDataToFile()));
menu.addAction(tr("Refresh"), this, SLOT(on_btnRefreshData_clicked()));
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 69aee073..ada8e7a7 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -440,6 +440,7 @@ private slots:
// data-tree context menu
void writeDataToFile();
void openDataFile();
+ void runDataFileHooked();
void addAsExecutable();
void previewDataFile();
void hideFile();
diff --git a/src/modinfodialogconflicts.cpp b/src/modinfodialogconflicts.cpp
index 58e935f2..6018306c 100644
--- a/src/modinfodialogconflicts.cpp
+++ b/src/modinfodialogconflicts.cpp
@@ -608,6 +608,19 @@ void ConflictsTab::showContextMenu(const QPoint &pos, QTreeView* tree)
menu.addAction(actions.preview);
}
+ // goto
+ if (actions.gotoMenu) {
+ menu.addMenu(actions.gotoMenu);
+
+ for (auto* a : actions.gotoActions) {
+ connect(a, &QAction::triggered, [&, name=a->text()]{
+ emitModOpen(name);
+ });
+
+ actions.gotoMenu->addAction(a);
+ }
+ }
+
// explore
if (actions.explore) {
connect(actions.explore, &QAction::triggered, [&]{
@@ -617,6 +630,8 @@ void ConflictsTab::showContextMenu(const QPoint &pos, QTreeView* tree)
menu.addAction(actions.explore);
}
+ menu.addSeparator();
+
// hide
if (actions.hide) {
connect(actions.hide, &QAction::triggered, [&]{
@@ -635,19 +650,6 @@ void ConflictsTab::showContextMenu(const QPoint &pos, QTreeView* tree)
menu.addAction(actions.unhide);
}
- // goto
- if (actions.gotoMenu) {
- menu.addMenu(actions.gotoMenu);
-
- for (auto* a : actions.gotoActions) {
- connect(a, &QAction::triggered, [&, name=a->text()]{
- emitModOpen(name);
- });
-
- actions.gotoMenu->addAction(a);
- }
- }
-
if (!menu.isEmpty()) {
menu.exec(tree->viewport()->mapToGlobal(pos));
}
@@ -732,14 +734,6 @@ ConflictsTab::Actions ConflictsTab::createMenuActions(QTreeView* tree)
Actions actions;
- actions.hide = new QAction(tr("&Hide"), parentWidget());
- actions.hide->setEnabled(enableHide);
-
- // note that it is possible for hidden files to appear if they override other
- // hidden files from another mod
- actions.unhide = new QAction(tr("&Unhide"), parentWidget());
- actions.unhide->setEnabled(enableUnhide);
-
if (enableRun) {
actions.open = new QAction(tr("&Execute"), parentWidget());
} else if (enableOpen) {
@@ -750,11 +744,19 @@ ConflictsTab::Actions ConflictsTab::createMenuActions(QTreeView* tree)
actions.preview = new QAction(tr("&Preview"), parentWidget());
actions.preview->setEnabled(enablePreview);
+ actions.gotoMenu = new QMenu(tr("&Go to..."), parentWidget());
+ actions.gotoMenu->setEnabled(enableGoto);
+
actions.explore = new QAction(tr("Open in &Explorer"), parentWidget());
actions.explore->setEnabled(enableExplore);
- actions.gotoMenu = new QMenu(tr("&Go to..."), parentWidget());
- actions.gotoMenu->setEnabled(enableGoto);
+ actions.hide = new QAction(tr("&Hide"), parentWidget());
+ actions.hide->setEnabled(enableHide);
+
+ // note that it is possible for hidden files to appear if they override other
+ // hidden files from another mod
+ actions.unhide = new QAction(tr("&Unhide"), parentWidget());
+ actions.unhide->setEnabled(enableUnhide);
if (enableGoto && n == 1) {
const auto* item = model->getItem(static_cast<std::size_t>(