Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hotkey for group switching #10625

Merged
merged 2 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/gui/group/GroupView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ 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(selectPreviousGroup()), nullptr, Qt::WindowShortcut);
new QShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_PageDown, this, SLOT(selectNextGroup()), nullptr, Qt::WindowShortcut);

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

void GroupView::selectPreviousGroup()
{
auto previousIndex = indexAbove(currentIndex());
if (previousIndex.isValid()) {
auto previousGroup = m_model->groupFromIndex(previousIndex);
setCurrentGroup(previousGroup);
}
}

void GroupView::selectNextGroup()
{
auto nextIndex = indexBelow(currentIndex());
if (nextIndex.isValid()) {
auto 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 selectPreviousGroup();
void selectNextGroup();

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