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->setShortcutContext(Qt::ApplicationShortcut);
actionMinimize->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); actionMinimize->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));
actionMinimize->setShortcutVisibleInContextMenu(true); 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); menuBar = new QMenuBar(this);
QMenu *fileMenu = menuBar->addMenu(""); QMenu *fileMenu = menuBar->addMenu("");
fileMenu->addAction(actionMinimize); fileMenu->addAction(actionMinimize);
fileMenu->addAction(actionCloseWindow);
dockMenu = new QMenu(this); dockMenu = new QMenu(this);
dockMenu->setAsDockMenu(); dockMenu->setAsDockMenu();
@ -705,6 +712,14 @@ void MainWindow::minimizeWindow()
} }
#endif #endif
#if defined(Q_OS_DARWIN)
void MainWindow::closeWindow()
{
// On macOS window close is basically equivalent to window hide.
close();
}
#endif
void MainWindow::showBandwidthGraph() void MainWindow::showBandwidthGraph()
{ {
if(_bandwidthGraph == NULL) if(_bandwidthGraph == NULL)

View File

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