mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Ignore double close event on macOS, resolves #430
This commit is contained in:
parent
c69a978589
commit
00dc4b9ace
@ -103,9 +103,9 @@ const QString MainWindow::BaseWindowTitle = "KeePassXC";
|
|||||||
MainWindow::MainWindow()
|
MainWindow::MainWindow()
|
||||||
: m_ui(new Ui::MainWindow())
|
: m_ui(new Ui::MainWindow())
|
||||||
, m_trayIcon(nullptr)
|
, m_trayIcon(nullptr)
|
||||||
|
, m_appExitCalled(false)
|
||||||
|
, m_appExiting(false)
|
||||||
{
|
{
|
||||||
appExitCalled = false;
|
|
||||||
|
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
|
|
||||||
// Setup the search widget in the toolbar
|
// Setup the search widget in the toolbar
|
||||||
@ -347,7 +347,7 @@ MainWindow::~MainWindow()
|
|||||||
|
|
||||||
void MainWindow::appExit()
|
void MainWindow::appExit()
|
||||||
{
|
{
|
||||||
appExitCalled = true;
|
m_appExitCalled = true;
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -663,9 +663,15 @@ void MainWindow::databaseTabChanged(int tabIndex)
|
|||||||
|
|
||||||
void MainWindow::closeEvent(QCloseEvent* event)
|
void MainWindow::closeEvent(QCloseEvent* event)
|
||||||
{
|
{
|
||||||
|
// ignore double close events (happens on macOS when closing from the dock)
|
||||||
|
if (m_appExiting) {
|
||||||
|
event->accept();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
bool minimizeOnClose = isTrayIconEnabled() &&
|
bool minimizeOnClose = isTrayIconEnabled() &&
|
||||||
config()->get("GUI/MinimizeOnClose").toBool();
|
config()->get("GUI/MinimizeOnClose").toBool();
|
||||||
if (minimizeOnClose && !appExitCalled)
|
if (minimizeOnClose && !m_appExitCalled)
|
||||||
{
|
{
|
||||||
event->ignore();
|
event->ignore();
|
||||||
hideWindow();
|
hideWindow();
|
||||||
@ -680,6 +686,7 @@ void MainWindow::closeEvent(QCloseEvent* event)
|
|||||||
bool accept = saveLastDatabases();
|
bool accept = saveLastDatabases();
|
||||||
|
|
||||||
if (accept) {
|
if (accept) {
|
||||||
|
m_appExiting = true;
|
||||||
saveWindowInformation();
|
saveWindowInformation();
|
||||||
|
|
||||||
event->accept();
|
event->accept();
|
||||||
|
@ -40,6 +40,7 @@ class MainWindow : public QMainWindow
|
|||||||
public:
|
public:
|
||||||
MainWindow();
|
MainWindow();
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
enum StackedWidgetIndex
|
enum StackedWidgetIndex
|
||||||
{
|
{
|
||||||
DatabaseTabScreen = 0,
|
DatabaseTabScreen = 0,
|
||||||
@ -118,7 +119,8 @@ private:
|
|||||||
|
|
||||||
Q_DISABLE_COPY(MainWindow)
|
Q_DISABLE_COPY(MainWindow)
|
||||||
|
|
||||||
bool appExitCalled;
|
bool m_appExitCalled;
|
||||||
|
bool m_appExiting;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define KEEPASSXC_MAIN_WINDOW (qobject_cast<Application*>(qApp) ? \
|
#define KEEPASSXC_MAIN_WINDOW (qobject_cast<Application*>(qApp) ? \
|
||||||
|
Loading…
Reference in New Issue
Block a user