From 75ef4dceb535ee35e5e164d3f12aa6bb1022bd0e Mon Sep 17 00:00:00 2001 From: defnax Date: Sat, 30 Dec 2023 00:15:28 +0100 Subject: [PATCH] Added close window shortcut --- retroshare-gui/src/gui/MainWindow.cpp | 17 ++++++++++++++++- retroshare-gui/src/gui/MainWindow.h | 2 ++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 9e5671598..be53e41c9 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -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) diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h index 7525a0e30..64211d67d 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -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;