git repos / SagoImageBrowser

commit ff6ac640

Poul Sander · 2026-06-02 16:53
ff6ac640c1802ab141912d1bf1bedce036acd50c patch · browse files
parent 83a4e329fd6040bd3b2b4973af672c55e4b4e4df

Make the prev and next shortcut keys more reliable in the browser and switch default to alt+left/right

Changed files

M .gitignore before
M src/mainwindow.cpp before
M src/shortcutmanager.cpp before
diff --git a/.gitignore b/.gitignore index 445b017..5776b83 100644 --- a/.gitignore +++ b/.gitignore
@@ -1,3 +1,5 @@
.qt
build
-Makefile
\ No newline at end of file
+Makefile
+*.patch
+.idea
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 3ce7ccf..d992d4f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp
@@ -423,6 +423,12 @@ void MainWindow::setupConnections()
// Also catch resize — visible range changes when the viewport is resized
m_listView->viewport()->installEventFilter(this);
+
+ // The folder list and tree views consume Ctrl+Left/Ctrl+Right for their own
+ // item navigation, so those keys never reach MainWindow::keyPressEvent.
+ // Filter them here so PrevFolder/NextFolder shortcuts work while a view has focus.
+ m_listView->installEventFilter(this);
+ m_treeView->installEventFilter(this);
}
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
@@ -430,6 +436,23 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event)
if (obj == m_listView->viewport() && event->type() == QEvent::Resize)
QTimer::singleShot(0, this, &MainWindow::loadVisibleThumbnails);
+ if ((obj == m_listView || obj == m_treeView)
+ && event->type() == QEvent::KeyPress
+ && m_stack->currentWidget() == m_browserPage)
+ {
+ const ShortcutManager &sc = ShortcutManager::instance();
+ QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
+
+ if (sc.matches(keyEvent, ShortcutManager::PrevFolder)) {
+ navigateToPrevFolder();
+ return true;
+ }
+ if (sc.matches(keyEvent, ShortcutManager::NextFolder)) {
+ navigateToNextFolder();
+ return true;
+ }
+ }
+
return QMainWindow::eventFilter(obj, event);
}
diff --git a/src/shortcutmanager.cpp b/src/shortcutmanager.cpp index a45111a..eb7ff8d 100644 --- a/src/shortcutmanager.cpp +++ b/src/shortcutmanager.cpp
@@ -32,8 +32,8 @@ static const ActionInfo kDefaults[ShortcutManager::ActionCount] = {
{"EditCaption", QT_TR_NOOP("Edit caption"), QKeySequence(Qt::Key_E), ShortcutManager::CatImageViewer},
{"ToggleFullscreen",QT_TR_NOOP("Toggle fullscreen"), QKeySequence(Qt::Key_F11), ShortcutManager::CatImageViewer},
{"ActivateEntry", QT_TR_NOOP("Open folder / image"), QKeySequence(Qt::Key_Return), ShortcutManager::CatBrowser},
- {"PrevFolder", QT_TR_NOOP("Previous folder"), QKeySequence(Qt::CTRL | Qt::Key_Left), ShortcutManager::CatBrowser},
- {"NextFolder", QT_TR_NOOP("Next folder"), QKeySequence(Qt::CTRL | Qt::Key_Right), ShortcutManager::CatBrowser},
+ {"PrevFolder", QT_TR_NOOP("Previous folder"), QKeySequence(Qt::ALT | Qt::Key_Left), ShortcutManager::CatBrowser},
+ {"NextFolder", QT_TR_NOOP("Next folder"), QKeySequence(Qt::ALT | Qt::Key_Right), ShortcutManager::CatBrowser},
};
} // namespace