Browse Source

Merge pull request #8033 from vit9696/cmdw

Fix CMD+W not closing the main window
adaptive-webui-19844
sledgehammer999 7 years ago committed by GitHub
parent
commit
cbfdb7df56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      src/gui/mainwindow.cpp
  2. 4
      src/gui/mainwindow.h
  3. 6
      src/gui/mainwindow.ui

15
src/gui/mainwindow.cpp

@ -843,6 +843,11 @@ void MainWindow::createKeyboardShortcuts()
m_ui->actionDelete->setShortcutContext(Qt::WidgetShortcut); // nullify its effect: delete key event is handled by respective widgets, not here m_ui->actionDelete->setShortcutContext(Qt::WidgetShortcut); // nullify its effect: delete key event is handled by respective widgets, not here
m_ui->actionDownloadFromURL->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_O); m_ui->actionDownloadFromURL->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_O);
m_ui->actionExit->setShortcut(Qt::CTRL + Qt::Key_Q); m_ui->actionExit->setShortcut(Qt::CTRL + Qt::Key_Q);
#ifdef Q_OS_MAC
m_ui->actionCloseWindow->setShortcut(QKeySequence::Close);
#else
m_ui->actionCloseWindow->setVisible(false);
#endif
QShortcut *switchTransferShortcut = new QShortcut(Qt::ALT + Qt::Key_1, this); QShortcut *switchTransferShortcut = new QShortcut(Qt::ALT + Qt::Key_1, this);
connect(switchTransferShortcut, &QShortcut::activated, this, &MainWindow::displayTransferTab); connect(switchTransferShortcut, &QShortcut::activated, this, &MainWindow::displayTransferTab);
@ -978,6 +983,16 @@ void MainWindow::on_actionExit_triggered()
close(); close();
} }
#ifdef Q_OS_MAC
void MainWindow::on_actionCloseWindow_triggered()
{
// On macOS window close is basically equivalent to window hide.
// If you decide to implement this functionality for other OS,
// then you will also need ui lock checks like in actionExit.
close();
}
#endif
QWidget *MainWindow::currentTabWidget() const QWidget *MainWindow::currentTabWidget() const
{ {
if (isMinimized() || !isVisible()) if (isMinimized() || !isVisible())

4
src/gui/mainwindow.h

@ -187,7 +187,9 @@ private slots:
void toolbarTextBeside(); void toolbarTextBeside();
void toolbarTextUnder(); void toolbarTextUnder();
void toolbarFollowSystem(); void toolbarFollowSystem();
#ifndef Q_OS_MAC #ifdef Q_OS_MAC
void on_actionCloseWindow_triggered();
#else
void toggleVisibility(const QSystemTrayIcon::ActivationReason reason = QSystemTrayIcon::Trigger); void toggleVisibility(const QSystemTrayIcon::ActivationReason reason = QSystemTrayIcon::Trigger);
void createSystrayDelayed(); void createSystrayDelayed();
void updateTrayIconMenu(); void updateTrayIconMenu();

6
src/gui/mainwindow.ui

@ -90,6 +90,7 @@
</property> </property>
<addaction name="actionOpen"/> <addaction name="actionOpen"/>
<addaction name="actionDownloadFromURL"/> <addaction name="actionDownloadFromURL"/>
<addaction name="actionCloseWindow"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionExit"/> <addaction name="actionExit"/>
</widget> </widget>
@ -466,6 +467,11 @@
<string>Critical Messages</string> <string>Critical Messages</string>
</property> </property>
</action> </action>
<action name="actionCloseWindow">
<property name="text">
<string>Close Window</string>
</property>
</action>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>

Loading…
Cancel
Save