fix: use the closeEvent to hide to tray and quit the application
This commit is contained in:
parent
58563d36ca
commit
08d4b348e0
2 changed files with 15 additions and 34 deletions
|
|
@ -130,8 +130,6 @@ MainWindow::MainWindow(ConfigScopes &configScopes, AppConfig &appConfig)
|
||||||
|
|
||||||
m_ConfigScopes.signalReady();
|
m_ConfigScopes.signalReady();
|
||||||
|
|
||||||
applyCloseToTray();
|
|
||||||
|
|
||||||
updateScreenName();
|
updateScreenName();
|
||||||
applyConfig();
|
applyConfig();
|
||||||
restoreWindow();
|
restoreWindow();
|
||||||
|
|
@ -270,7 +268,7 @@ void MainWindow::connectSlots()
|
||||||
connect(m_actionHelp, &QAction::triggered, this, &MainWindow::openHelpUrl);
|
connect(m_actionHelp, &QAction::triggered, this, &MainWindow::openHelpUrl);
|
||||||
connect(m_actionMinimize, &QAction::triggered, this, &MainWindow::hide);
|
connect(m_actionMinimize, &QAction::triggered, this, &MainWindow::hide);
|
||||||
|
|
||||||
connect(m_actionQuit, &QAction::triggered, this, &MainWindow::quitApp);
|
connect(m_actionQuit, &QAction::triggered, this, &MainWindow::close);
|
||||||
connect(m_actionRestore, &QAction::triggered, this, &MainWindow::showAndActivate);
|
connect(m_actionRestore, &QAction::triggered, this, &MainWindow::showAndActivate);
|
||||||
connect(m_actionSave, &QAction::triggered, this, &MainWindow::saveConfig);
|
connect(m_actionSave, &QAction::triggered, this, &MainWindow::saveConfig);
|
||||||
connect(m_actionSettings, &QAction::triggered, this, &MainWindow::openSettings);
|
connect(m_actionSettings, &QAction::triggered, this, &MainWindow::openSettings);
|
||||||
|
|
@ -438,7 +436,6 @@ void MainWindow::clearSettings()
|
||||||
|
|
||||||
m_CoreProcess.stop();
|
m_CoreProcess.stop();
|
||||||
|
|
||||||
m_Quitting = true;
|
|
||||||
m_SaveOnExit = false;
|
m_SaveOnExit = false;
|
||||||
diagnostic::clearSettings(m_ConfigScopes, true);
|
diagnostic::clearSettings(m_ConfigScopes, true);
|
||||||
}
|
}
|
||||||
|
|
@ -474,7 +471,6 @@ void MainWindow::openSettings()
|
||||||
m_ConfigScopes.save();
|
m_ConfigScopes.save();
|
||||||
|
|
||||||
applyConfig();
|
applyConfig();
|
||||||
applyCloseToTray();
|
|
||||||
|
|
||||||
if (m_CoreProcess.isStarted()) {
|
if (m_CoreProcess.isStarted()) {
|
||||||
m_CoreProcess.restart();
|
m_CoreProcess.restart();
|
||||||
|
|
@ -527,13 +523,6 @@ void MainWindow::setModeClient()
|
||||||
m_ConfigScopes.save();
|
m_ConfigScopes.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::quitApp()
|
|
||||||
{
|
|
||||||
qDebug() << "quitting application";
|
|
||||||
m_Quitting = true;
|
|
||||||
QApplication::quit();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::onWindowSaveTimerTimeout()
|
void MainWindow::onWindowSaveTimerTimeout()
|
||||||
{
|
{
|
||||||
saveWindow();
|
saveWindow();
|
||||||
|
|
@ -580,7 +569,7 @@ void MainWindow::open()
|
||||||
// Duplicate quit needed for mac os tray menu
|
// Duplicate quit needed for mac os tray menu
|
||||||
QAction *actionTrayQuit = new QAction(tr("Quit Deskflow"), this);
|
QAction *actionTrayQuit = new QAction(tr("Quit Deskflow"), this);
|
||||||
actionTrayQuit->setShortcut(QKeySequence::Quit);
|
actionTrayQuit->setShortcut(QKeySequence::Quit);
|
||||||
connect(actionTrayQuit, &QAction::triggered, this, &MainWindow::quitApp);
|
connect(actionTrayQuit, &QAction::triggered, this, &MainWindow::close);
|
||||||
|
|
||||||
m_actionRestore->setText(tr("Open Deskflow"));
|
m_actionRestore->setText(tr("Open Deskflow"));
|
||||||
trayActions.insert(3, m_actionRestore);
|
trayActions.insert(3, m_actionRestore);
|
||||||
|
|
@ -676,11 +665,6 @@ void MainWindow::applyConfig()
|
||||||
updateLocalFingerprint();
|
updateLocalFingerprint();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::applyCloseToTray() const
|
|
||||||
{
|
|
||||||
QApplication::setQuitOnLastWindowClosed(!m_AppConfig.closeToTray());
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::saveSettings()
|
void MainWindow::saveSettings()
|
||||||
{
|
{
|
||||||
m_AppConfig.setServerGroupChecked(ui->rbModeServer->isChecked());
|
m_AppConfig.setServerGroupChecked(ui->rbModeServer->isChecked());
|
||||||
|
|
@ -809,23 +793,23 @@ void MainWindow::showEvent(QShowEvent *event)
|
||||||
|
|
||||||
void MainWindow::closeEvent(QCloseEvent *event)
|
void MainWindow::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
if (m_Quitting) {
|
if (m_AppConfig.closeToTray() && event->spontaneous()) {
|
||||||
qDebug() << "skipping close event handle on quit";
|
if (m_AppConfig.showCloseReminder()) {
|
||||||
|
messages::showCloseReminder(this);
|
||||||
|
m_AppConfig.setShowCloseReminder(false);
|
||||||
|
}
|
||||||
|
qDebug() << "hiding to tray";
|
||||||
|
hide();
|
||||||
|
event->ignore();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_AppConfig.closeToTray()) {
|
if (m_SaveOnExit)
|
||||||
qDebug() << "window will not hide to tray";
|
m_ConfigScopes.save();
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_AppConfig.showCloseReminder()) {
|
qDebug() << "quitting application";
|
||||||
messages::showCloseReminder(this);
|
event->accept();
|
||||||
m_AppConfig.setShowCloseReminder(false);
|
QApplication::quit();
|
||||||
}
|
|
||||||
|
|
||||||
m_ConfigScopes.save();
|
|
||||||
qDebug() << "window should hide to tray";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::showFirstConnectedMessage()
|
void MainWindow::showFirstConnectedMessage()
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,6 @@ private slots:
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<Ui::MainWindow> ui;
|
std::unique_ptr<Ui::MainWindow> ui;
|
||||||
|
|
||||||
void quitApp();
|
|
||||||
void updateSize();
|
void updateSize();
|
||||||
AppConfig &appConfig()
|
AppConfig &appConfig()
|
||||||
{
|
{
|
||||||
|
|
@ -152,7 +151,6 @@ private:
|
||||||
void createStatusBar();
|
void createStatusBar();
|
||||||
void createTrayIcon();
|
void createTrayIcon();
|
||||||
void applyConfig();
|
void applyConfig();
|
||||||
void applyCloseToTray() const;
|
|
||||||
void setIcon();
|
void setIcon();
|
||||||
bool checkForApp(int which, QString &app);
|
bool checkForApp(int which, QString &app);
|
||||||
void setStatus(const QString &status);
|
void setStatus(const QString &status);
|
||||||
|
|
@ -190,7 +188,6 @@ private:
|
||||||
QAbstractButton *m_pCancelButton = nullptr;
|
QAbstractButton *m_pCancelButton = nullptr;
|
||||||
bool m_SecureSocket = false;
|
bool m_SecureSocket = false;
|
||||||
bool m_SaveWindow = false;
|
bool m_SaveWindow = false;
|
||||||
bool m_Quitting = false;
|
|
||||||
deskflow::gui::config::ServerConfigDialogState m_ServerConfigDialogState;
|
deskflow::gui::config::ServerConfigDialogState m_ServerConfigDialogState;
|
||||||
bool m_SaveOnExit = true;
|
bool m_SaveOnExit = true;
|
||||||
deskflow::gui::core::WaylandWarnings m_WaylandWarnings;
|
deskflow::gui::core::WaylandWarnings m_WaylandWarnings;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue