summaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2019-12-02 15:18:55 -0500
committerisanae <14251494+isanae@users.noreply.github.com>2019-12-02 15:18:55 -0500
commit3b78e436dbee043e4a3f81e5bfa09695c2a708c4 (patch)
treea8f32d4aa0ec39600c32788c9022ea4559d408b6 /src/mainwindow.cpp
parent48fd9fd08070e1a937bb7e49d44189d9a071edc5 (diff)
double-click now opens files for the data tab, filetree and conflict lists
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index cfa27fad..3af0f30c 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -350,6 +350,7 @@ MainWindow::MainWindow(Settings &settings
connect(ui->espFilterEdit, SIGNAL(textChanged(QString)), this, SLOT(espFilterChanged(QString)));
connect(ui->dataTree, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(expandDataTreeItem(QTreeWidgetItem*)));
+ connect(ui->dataTree, SIGNAL(itemActivated(QTreeWidgetItem*, int)), this, SLOT(activateDataTreeItem(QTreeWidgetItem*, int)));
connect(m_OrganizerCore.directoryRefresher(), SIGNAL(refreshed()), this, SLOT(directory_refreshed()));
connect(m_OrganizerCore.directoryRefresher(), SIGNAL(progress(int)), this, SLOT(refresher_progress(int)));
@@ -1767,6 +1768,10 @@ void MainWindow::expandDataTreeItem(QTreeWidgetItem *item)
}
}
+void MainWindow::activateDataTreeItem(QTreeWidgetItem *item, int column)
+{
+ openDataFile(item);
+}
bool MainWindow::refreshProfiles(bool selectProfile)
{
@@ -5295,7 +5300,19 @@ void MainWindow::openDataFile()
return;
}
- const QString path = m_ContextItem->data(0, Qt::UserRole).toString();
+ openDataFile(m_ContextItem);
+}
+
+void MainWindow::openDataFile(QTreeWidgetItem* item)
+{
+ const auto isArchive = item->data(0, Qt::UserRole + 1).toBool();
+ const auto isDirectory = item->data(0, Qt::UserRole + 3).toBool();
+
+ if (isArchive || isDirectory) {
+ return;
+ }
+
+ const QString path = item->data(0, Qt::UserRole).toString();
const QFileInfo targetInfo(path);
m_OrganizerCore.processRunner()
@@ -5389,8 +5406,7 @@ void MainWindow::motdReceived(const QString &motd)
void MainWindow::on_dataTree_customContextMenuRequested(const QPoint &pos)
{
- QTreeWidget *dataTree = findChild<QTreeWidget*>("dataTree");
- m_ContextItem = dataTree->itemAt(pos.x(), pos.y());
+ m_ContextItem = ui->dataTree->itemAt(pos.x(), pos.y());
QMenu menu;
if ((m_ContextItem != nullptr) && (m_ContextItem->childCount() == 0)
@@ -5399,13 +5415,21 @@ void MainWindow::on_dataTree_customContextMenuRequested(const QPoint &pos)
const auto isArchive = m_ContextItem->data(0, Qt::UserRole + 1).toBool();
const auto isDirectory = m_ContextItem->data(0, Qt::UserRole + 3).toBool();
+ QAction* open = nullptr;
+
if (canRunFile(isArchive, fileName)) {
- menu.addAction(tr("&Execute"), this, SLOT(openDataFile()));
+ open = menu.addAction(tr("&Execute"), this, SLOT(openDataFile()));
} else if (canOpenFile(isArchive, fileName)) {
- menu.addAction(tr("&Open"), this, SLOT(openDataFile()));
+ open = menu.addAction(tr("&Open"), this, SLOT(openDataFile()));
menu.addAction(tr("Open with &VFS"), this, SLOT(runDataFileHooked()));
}
+ if (open) {
+ auto bold = open->font();
+ bold.setBold(true);
+ open->setFont(bold);
+ }
+
menu.addAction(tr("&Add as Executable"), this, SLOT(addAsExecutable()));
if (m_PluginContainer.previewGenerator().previewSupported(QFileInfo(fileName).suffix())) {
@@ -5432,7 +5456,7 @@ void MainWindow::on_dataTree_customContextMenuRequested(const QPoint &pos)
menu.addAction(tr("Write To File..."), this, SLOT(writeDataToFile()));
menu.addAction(tr("Refresh"), this, SLOT(on_btnRefreshData_clicked()));
- menu.exec(dataTree->viewport()->mapToGlobal(pos));
+ menu.exec(ui->dataTree->viewport()->mapToGlobal(pos));
}
void MainWindow::on_conflictsCheckBox_toggled(bool)