Added close window shortcut

This commit is contained in:
defnax 2023-12-30 00:15:28 +01:00
parent 79977a0c37
commit 75ef4dceb5
2 changed files with 18 additions and 1 deletions

View File

@ -673,11 +673,18 @@ void MainWindow::createMenuBar()
actionMinimize->setShortcutContext(Qt::ApplicationShortcut);
actionMinimize->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));
actionMinimize->setShortcutVisibleInContextMenu(true);
connect(actionMinimize,SIGNAL(triggered()),this,SLOT(minimizeWindow())) ;
connect(actionMinimize,SIGNAL(triggered()),this,SLOT(minimizeWindow())) ;
actionCloseWindow = new QAction(tr("Close window"),this);
actionCloseWindow->setShortcutContext(Qt::ApplicationShortcut);
actionCloseWindow->setShortcut(QKeySequence::Close);
actionCloseWindow->setShortcutVisibleInContextMenu(true);
connect(actionCloseWindow,SIGNAL(triggered()),this,SLOT(closeWindow())) ;
menuBar = new QMenuBar(this);
QMenu *fileMenu = menuBar->addMenu("");
fileMenu->addAction(actionMinimize);
fileMenu->addAction(actionCloseWindow);
dockMenu = new QMenu(this);
dockMenu->setAsDockMenu();
@ -705,6 +712,14 @@ void MainWindow::minimizeWindow()
}
#endif
#if defined(Q_OS_DARWIN)
void MainWindow::closeWindow()
{
// On macOS window close is basically equivalent to window hide.
close();
}
#endif
void MainWindow::showBandwidthGraph()
{
if(_bandwidthGraph == NULL)

View File

@ -267,6 +267,7 @@ private slots:
#if defined(Q_OS_DARWIN)
void minimizeWindow();
void closeWindow();
#endif
/** Toolbar fns. */
@ -337,6 +338,7 @@ private:
QMenuBar *menuBar;
QMenu *dockMenu;
QAction* actionMinimize;
QAction* actionCloseWindow;
#endif
QSystemTrayIcon *trayIcon;