Skip to content

Commit 87d5575

Browse files
nowhszhmarvin
authored and
marvin
committed
feat: add some shortcut
1 parent 2602bda commit 87d5575

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

src/settings/include/shortcuts.h

+4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ struct ShortcutAction {
5454
static constexpr auto MainWindowCloseFile = "mainwindow.close_file";
5555
static constexpr auto MainWindowCloseAll = "mainwindow.close_all";
5656
static constexpr auto MainWindowQuit = "mainwindow.quit";
57+
static constexpr auto MainWindowFullScreen = "mainwindow.fullscreen";
58+
static constexpr auto MainWindowMax = "mainwindow.max_window";
59+
static constexpr auto MainWindowMin = "mainwindow.min_window";
60+
static constexpr auto MainWindowPreference = "mainwindow.preference";
5761
static constexpr auto MainWindowCopy = "mainwindow.copy_selection";
5862
static constexpr auto MainWindowSelectAll = "mainwindow.select_all";
5963
static constexpr auto MainWindowOpenQf = "mainwindow.open_qf";

src/settings/src/shortcuts.cpp

+28
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,34 @@ const ShortcutAction::ShortcutList& ShortcutAction::defaultShortcutList()
146146
QStringList{ "Ctrl+Q" },
147147
},
148148
},
149+
{
150+
MainWindowFullScreen,
151+
{
152+
QApplication::tr( "Full Screen" ),
153+
QStringList{},
154+
},
155+
},
156+
{
157+
MainWindowMax,
158+
{
159+
QApplication::tr( "Maximize window" ),
160+
QStringList{},
161+
},
162+
},
163+
{
164+
MainWindowMin,
165+
{
166+
QApplication::tr( "Minimize Window" ),
167+
QStringList{},
168+
},
169+
},
170+
{
171+
MainWindowPreference,
172+
{
173+
QApplication::tr( "Preferences" ),
174+
QStringList{},
175+
},
176+
},
149177
{
150178
MainWindowOpenQf,
151179
{

src/ui/src/mainwindow.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,15 @@ void MainWindow::updateShortcuts()
695695
crawler->focusSearchEdit();
696696
}
697697
} );
698+
ShortcutAction::registerShortcut( shortcuts, shortcuts_, this, Qt::WindowShortcut,
699+
ShortcutAction::MainWindowFullScreen,
700+
[ this ] { this->showFullScreen(); } );
701+
ShortcutAction::registerShortcut( shortcuts, shortcuts_, this, Qt::WindowShortcut,
702+
ShortcutAction::MainWindowMax,
703+
[ this ] { this->showMaximized(); } );
704+
ShortcutAction::registerShortcut( shortcuts, shortcuts_, this, Qt::WindowShortcut,
705+
ShortcutAction::MainWindowMin,
706+
[ this ] { this->showMinimized(); } );
698707

699708
auto setShortcuts = [ &shortcuts ]( auto* action, const auto& actionName ) {
700709
action->setShortcuts( ShortcutAction::shortcutKeys( actionName, shortcuts ) );
@@ -721,6 +730,7 @@ void MainWindow::updateShortcuts()
721730
setShortcuts( showScratchPadAction, ShortcutAction::MainWindowScratchpad );
722731
setShortcuts( selectOpenFileAction, ShortcutAction::MainWindowSelectOpenFile );
723732
setShortcuts( goToLineAction, ShortcutAction::LogViewJumpToLine );
733+
setShortcuts( optionsAction, ShortcutAction::MainWindowPreference );
724734
}
725735

726736
void MainWindow::loadIcons()

0 commit comments

Comments
 (0)