Change window close event to hide window

This commit is contained in:
BlackMark 2020-07-08 22:42:24 +02:00
parent 2253a25011
commit eb18ab9f1e
2 changed files with 10 additions and 1 deletions

View File

@ -5,6 +5,7 @@
#include <cmath>
#include <QCloseEvent>
#include <QGroupBox>
#include <QSlider>
#include <QtDebug>
@ -52,7 +53,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
m_visibility = !m_visibility;
});
m_trayIconMenu->addSeparator();
m_trayIconMenu->addAction(tr("Quit"), this, &QWidget::close);
m_trayIconMenu->addAction(tr("Quit"), this, &QCoreApplication::quit);
qDebug(ltr("Tray icon context menu initialized"));
@ -88,6 +89,12 @@ MainWindow::~MainWindow()
}
}
void MainWindow::closeEvent(QCloseEvent* event)
{
m_showHideAction->activate(QAction::Trigger);
event->ignore();
}
void MainWindow::loadIcons()
{
qDebug(ltr("Loading icons"));

View File

@ -25,6 +25,8 @@ class MainWindow : public QMainWindow {
~MainWindow();
private:
void closeEvent(QCloseEvent* event) override;
void loadIcons();
void updateState();