From 74e11cf3233172382a0efe804cc9d754511fef37 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Mon, 8 May 2023 16:13:15 +0300 Subject: [PATCH] UI: HomeWindow: Don't activate menu on closing --- src/ui/form/home/homewindow.cpp | 2 +- src/ui/util/window/widgetwindow.cpp | 2 ++ src/ui/util/window/widgetwindow.h | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ui/form/home/homewindow.cpp b/src/ui/form/home/homewindow.cpp index 7512000b..14913259 100644 --- a/src/ui/form/home/homewindow.cpp +++ b/src/ui/form/home/homewindow.cpp @@ -25,7 +25,7 @@ HomeWindow::HomeWindow(QWidget *parent) : setupStateWatcher(); connect(this, &HomeWindow::activationChanged, this, [&] { - if (isActiveWindow()) { + if (isActiveWindow() && !isClosing()) { m_btMenu->showMenu(); } }); diff --git a/src/ui/util/window/widgetwindow.cpp b/src/ui/util/window/widgetwindow.cpp index f4499e0e..77cfd827 100644 --- a/src/ui/util/window/widgetwindow.cpp +++ b/src/ui/util/window/widgetwindow.cpp @@ -34,6 +34,8 @@ void WidgetWindow::hideEvent(QHideEvent *event) void WidgetWindow::closeEvent(QCloseEvent *event) { + m_isClosing = true; + emit aboutToClose(); QWidget::closeEvent(event); diff --git a/src/ui/util/window/widgetwindow.h b/src/ui/util/window/widgetwindow.h index 756a9149..f0a7da2e 100644 --- a/src/ui/util/window/widgetwindow.h +++ b/src/ui/util/window/widgetwindow.h @@ -10,6 +10,8 @@ class WidgetWindow : public QWidget public: explicit WidgetWindow(QWidget *parent = nullptr); + bool isClosing() const { return m_isClosing; } + signals: void activationChanged(); @@ -31,6 +33,9 @@ protected: void keyPressEvent(QKeyEvent *event) override; void changeEvent(QEvent *event) override; + +private: + bool m_isClosing = false; }; #endif // WIDGETWINDOW_H