diff --git a/docs/keyboard_shortcuts.md b/docs/keyboard_shortcuts.md index 7f3a4abd..eb3c084b 100644 --- a/docs/keyboard_shortcuts.md +++ b/docs/keyboard_shortcuts.md @@ -24,7 +24,10 @@ These shortcuts are meant to be used while the Notes window is currently focused | Ctrl + E | Clear the search bar | | Ctrl + (or just ) | Select note below | | Ctrl + (or just ) | Select note above | +| Ctrl + _(macOS)_ | Select note below | +| Ctrl + _(macOS)_ | Select note above | | Ctrl + Enter | Focus on the text editor | +| Ctrl + L _(macOS)_ | Focus on the text editor | | Ctrl + Shift + F | Toggle full screen mode | | Ctrl + Shift + K | Toggle kanban view | | F11 | Toggle full screen mode | diff --git a/src/listviewlogic.cpp b/src/listviewlogic.cpp index d7fec348..22543fb9 100644 --- a/src/listviewlogic.cpp +++ b/src/listviewlogic.cpp @@ -189,6 +189,9 @@ void ListViewLogic::deleteNoteRequested(const NodeData ¬e) void ListViewLogic::selectNoteUp() { + // Ensure the list view has focus + m_listView->setFocus(); + auto currentIndex = m_listView->currentIndex(); if (currentIndex.isValid()) { int currentRow = currentIndex.row(); @@ -209,6 +212,9 @@ void ListViewLogic::selectNoteUp() void ListViewLogic::selectNoteDown() { + // Ensure the list view has focus + m_listView->setFocus(); + auto currentIndex = m_listView->currentIndex(); if (currentIndex.isValid()) { int currentRow = currentIndex.row(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4c33b7c3..1273ccce 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -532,14 +532,22 @@ void MainWindow::setupKeyboardShortcuts() new QShortcut(QKeySequence(Qt::CTRL | Qt::Key_D), this, SLOT(deleteSelectedNote())); new QShortcut(QKeySequence(Qt::CTRL | Qt::Key_F), m_searchEdit, SLOT(setFocus())); new QShortcut(QKeySequence(Qt::CTRL | Qt::Key_E), m_searchEdit, SLOT(clear())); + + // Shortcuts for note navigation +#if defined(Q_OS_MACOS) + new QShortcut(QKeySequence(Qt::META | Qt::Key_Down), this, SLOT(selectNoteDown())); + new QShortcut(QKeySequence(Qt::META | Qt::Key_Up), this, SLOT(selectNoteUp())); + new QShortcut(QKeySequence(Qt::META | Qt::Key_L), this, SLOT(setFocusOnText())); +#else new QShortcut(QKeySequence(Qt::CTRL | Qt::Key_Down), this, SLOT(selectNoteDown())); new QShortcut(QKeySequence(Qt::CTRL | Qt::Key_Up), this, SLOT(selectNoteUp())); + new QShortcut(QKeySequence(Qt::CTRL | Qt::Key_L), this, SLOT(setFocusOnText())); +#endif + new QShortcut(QKeySequence(Qt::Key_Down), this, SLOT(selectNoteDown())); new QShortcut(QKeySequence(Qt::Key_Up), this, SLOT(selectNoteUp())); new QShortcut(QKeySequence(Qt::CTRL | Qt::Key_Enter), this, SLOT(setFocusOnText())); new QShortcut(QKeySequence(Qt::CTRL | Qt::Key_Return), this, SLOT(setFocusOnText())); - // new QShortcut(QKeySequence(Qt::Key_Enter), this, SLOT(setFocusOnText())); - // new QShortcut(QKeySequence(Qt::Key_Return), this, SLOT(setFocusOnText())); new QShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_F), this, SLOT(fullscreenWindow())); new QShortcut(Qt::Key_F11, this, SLOT(fullscreenWindow())); connect(new QShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_L), this), &QShortcut::activated, this, [=]() { m_listView->setFocus(); });