Skip to content

Commit

Permalink
Add hotkey for group switching
Browse files Browse the repository at this point in the history
Ctrl + Shift + Key_PageUp for previous group
Ctrl + Shift + Key_PageDown for next group
Fixes: #4394
  • Loading branch information
0xdeadbeer committed Apr 25, 2024
1 parent 5b123e7 commit fff6b52
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/gui/group/GroupView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ GroupView::GroupView(Database* db, QWidget* parent)
// clang-format on

new QShortcut(Qt::CTRL + Qt::Key_F10, this, SLOT(contextMenuShortcutPressed()), nullptr, Qt::WidgetShortcut);
new QShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_PageUp, this, SLOT(prevGroup()), nullptr, Qt::WindowShortcut);
new QShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_PageDown, this, SLOT(nextGroup()), nullptr, Qt::WindowShortcut);

// keyboard shortcuts to sort children of a group
auto shortcut = new QShortcut(Qt::CTRL + Qt::Key_Down, this);
Expand All @@ -60,6 +62,26 @@ GroupView::GroupView(Database* db, QWidget* parent)
setDefaultDropAction(Qt::MoveAction);
}

void GroupView::prevGroup()
{
auto prevIndex = indexAbove(currentIndex());
if (!prevIndex.isValid())
return;

Group* prevGroup = m_model->groupFromIndex(prevIndex);
setCurrentGroup(prevGroup);
}

void GroupView::nextGroup()
{
auto nextIndex = indexBelow(currentIndex());
if (!nextIndex.isValid())
return;

Group* nextGroup = m_model->groupFromIndex(nextIndex);
setCurrentGroup(nextGroup);
}

void GroupView::contextMenuShortcutPressed()
{
auto index = currentIndex();
Expand Down
2 changes: 2 additions & 0 deletions src/gui/group/GroupView.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ private slots:
void syncExpandedState(const QModelIndex& parent, int start, int end);
void modelReset();
void contextMenuShortcutPressed();
void prevGroup();
void nextGroup();

protected:
void dragMoveEvent(QDragMoveEvent* event) override;
Expand Down

0 comments on commit fff6b52

Please sign in to comment.