Skip to content

Commit

Permalink
feat: add some shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
nowhszh authored and marvin committed Nov 18, 2024
1 parent 0205db2 commit 32f3658
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/settings/include/shortcuts.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ struct ShortcutAction {
static constexpr auto MainWindowCloseFile = "mainwindow.close_file";
static constexpr auto MainWindowCloseAll = "mainwindow.close_all";
static constexpr auto MainWindowQuit = "mainwindow.quit";
static constexpr auto MainWindowFullScreen = "mainwindow.fullscreen";
static constexpr auto MainWindowMax = "mainwindow.max_window";
static constexpr auto MainWindowMin = "mainwindow.min_window";
static constexpr auto MainWindowPreference = "mainwindow.preference";
static constexpr auto MainWindowCopy = "mainwindow.copy_selection";
static constexpr auto MainWindowSelectAll = "mainwindow.select_all";
static constexpr auto MainWindowOpenQf = "mainwindow.open_qf";
Expand Down
28 changes: 28 additions & 0 deletions src/settings/src/shortcuts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,34 @@ const ShortcutAction::ShortcutList& ShortcutAction::defaultShortcutList()
QStringList{ "Ctrl+Q" },
},
},
{
MainWindowFullScreen,
{
QApplication::tr( "Full Screen" ),
QStringList{},
},
},
{
MainWindowMax,
{
QApplication::tr( "Maximize window" ),
QStringList{},
},
},
{
MainWindowMin,
{
QApplication::tr( "Minimize Window" ),
QStringList{},
},
},
{
MainWindowPreference,
{
QApplication::tr( "Preferences" ),
QStringList{},
},
},
{
MainWindowOpenQf,
{
Expand Down
10 changes: 10 additions & 0 deletions src/ui/src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,15 @@ void MainWindow::updateShortcuts()
crawler->focusSearchEdit();
}
} );
ShortcutAction::registerShortcut( shortcuts, shortcuts_, this, Qt::WindowShortcut,
ShortcutAction::MainWindowFullScreen,
[ this ] { this->showFullScreen(); } );
ShortcutAction::registerShortcut( shortcuts, shortcuts_, this, Qt::WindowShortcut,
ShortcutAction::MainWindowMax,
[ this ] { this->showMaximized(); } );
ShortcutAction::registerShortcut( shortcuts, shortcuts_, this, Qt::WindowShortcut,
ShortcutAction::MainWindowMin,
[ this ] { this->showMinimized(); } );

auto setShortcuts = [ &shortcuts ]( auto* action, const auto& actionName ) {
action->setShortcuts( ShortcutAction::shortcutKeys( actionName, shortcuts ) );
Expand All @@ -721,6 +730,7 @@ void MainWindow::updateShortcuts()
setShortcuts( showScratchPadAction, ShortcutAction::MainWindowScratchpad );
setShortcuts( selectOpenFileAction, ShortcutAction::MainWindowSelectOpenFile );
setShortcuts( goToLineAction, ShortcutAction::LogViewJumpToLine );
setShortcuts( optionsAction, ShortcutAction::MainWindowPreference );
}

void MainWindow::loadIcons()
Expand Down

0 comments on commit 32f3658

Please sign in to comment.