From 62dc387de644a0a47156079f78f7e0ab174abdaa Mon Sep 17 00:00:00 2001 From: Al12rs Date: Tue, 17 Apr 2018 01:32:03 +0200 Subject: Added key shourtcuts to open in explorer a selected mo by pressing Enter or Return. Needs support for overwrte --- src/mainwindow.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 401e3c8b..3eb7244a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -150,6 +150,7 @@ along with Mod Organizer. If not, see . #include #include #include +#include #include #include @@ -369,6 +370,9 @@ MainWindow::MainWindow(QSettings &initSettings connect(ui->espList->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(esplistSelectionsChanged(QItemSelection))); connect(ui->modList->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(modlistSelectionsChanged(QItemSelection))); + new QShortcut(QKeySequence(Qt::Key_Enter), this, SLOT(openExplorer_activated())); + new QShortcut(QKeySequence(Qt::Key_Return), this, SLOT(openExplorer_activated())); + m_UpdateProblemsTimer.setSingleShot(true); connect(&m_UpdateProblemsTimer, SIGNAL(timeout()), this, SLOT(updateProblemsButton())); @@ -2615,6 +2619,20 @@ void MainWindow::openExplorer_clicked() ::ShellExecuteW(nullptr, L"explore", ToWString(modInfo->absolutePath()).c_str(), nullptr, nullptr, SW_SHOWNORMAL); } +void MainWindow::openExplorer_activated() +{ + QItemSelectionModel *selection = ui->modList->selectionModel(); + if (selection->hasSelection() && selection->selectedRows().count() == 1 && ui->modList->hasFocus()) { + + QModelIndex idx = selection->currentIndex(); + ModInfo::Ptr modInfo = ModInfo::getByIndex(idx.data(Qt::UserRole + 1).toInt()); + if (modInfo->isRegular()) { + ::ShellExecuteW(nullptr, L"explore", ToWString(modInfo->absolutePath()).c_str(), nullptr, nullptr, SW_SHOWNORMAL); + } + + } +} + void MainWindow::information_clicked() { try { -- cgit v1.3.1