diff --git a/src/ui/form/tray/trayicon.cpp b/src/ui/form/tray/trayicon.cpp index c5c9002b..37a48d06 100644 --- a/src/ui/form/tray/trayicon.cpp +++ b/src/ui/form/tray/trayicon.cpp @@ -13,8 +13,7 @@ #include
#include #include -#include -#include +#include #include #include #include @@ -295,10 +294,8 @@ void TrayIcon::switchFilterModeMenu(bool /*checked*/) void TrayIcon::setupController() { - connect(windowManager()->optWindow(), &WidgetWindow::visibilityChanged, this, - &TrayIcon::updateTrayMenuFlags); - connect(windowManager()->graphWindow(), &WidgetWindow::visibilityChanged, m_graphAction, - &QAction::setChecked); + connect(windowManager(), &WindowManager::windowVisibilityChanged, this, + &TrayIcon::onWindowVisibilityChanged); connect(settings(), &FortSettings::passwordCheckedChanged, this, &TrayIcon::updateTrayMenuFlags); @@ -738,3 +735,15 @@ void TrayIcon::onTrayActivatedByClick(TrayIcon::ClickType clickType, bool checkT m_trayTriggered = false; onMouseClicked(clickType); } + +void TrayIcon::onWindowVisibilityChanged(quint32 code, bool isVisible) +{ + switch (code) { + case WindowOptions: { + updateTrayMenuFlags(); + } break; + case WindowGraph: { + m_graphAction->setChecked(isVisible); + } break; + } +} diff --git a/src/ui/form/tray/trayicon.h b/src/ui/form/tray/trayicon.h index 56fe05eb..24655a57 100644 --- a/src/ui/form/tray/trayicon.h +++ b/src/ui/form/tray/trayicon.h @@ -116,6 +116,8 @@ private: void onTrayActivatedByTrigger(); void onTrayActivatedByClick(TrayIcon::ClickType clickType, bool checkTriggered = false); + void onWindowVisibilityChanged(quint32 code, bool isVisible); + private: bool m_trayTriggered : 1; bool m_alerted : 1;