diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2019-12-02 14:50:01 -0500 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2019-12-02 14:50:01 -0500 |
| commit | 48fd9fd08070e1a937bb7e49d44189d9a071edc5 (patch) | |
| tree | 733967ad033a3ec5fca1f38746dedda3aba2e2ba /src/mainwindow.cpp | |
| parent | 47b767ef2fd1071a065e546c543805f490ab3e2d (diff) | |
added "open with vfs" to the data tab
uniform order for file context menus
Diffstat (limited to 'src/mainwindow.cpp')
| -rw-r--r-- | src/mainwindow.cpp | 37 |
1 files changed, 29 insertions, 8 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())); |
