UI: TrayIcon: Refactor windows visibility handling

This commit is contained in:
Nodir Temirkhodjaev 2023-05-17 17:49:06 +03:00
parent 36f89efea0
commit 9ee0b96fb3
2 changed files with 17 additions and 6 deletions

View File

@ -13,8 +13,7 @@
#include <form/controls/clickablemenu.h> #include <form/controls/clickablemenu.h>
#include <form/controls/controlutil.h> #include <form/controls/controlutil.h>
#include <form/controls/mainwindow.h> #include <form/controls/mainwindow.h>
#include <form/graph/graphwindow.h> #include <form/windowtypes.h>
#include <form/opt/optionswindow.h>
#include <fortsettings.h> #include <fortsettings.h>
#include <manager/hotkeymanager.h> #include <manager/hotkeymanager.h>
#include <manager/windowmanager.h> #include <manager/windowmanager.h>
@ -295,10 +294,8 @@ void TrayIcon::switchFilterModeMenu(bool /*checked*/)
void TrayIcon::setupController() void TrayIcon::setupController()
{ {
connect(windowManager()->optWindow(), &WidgetWindow::visibilityChanged, this, connect(windowManager(), &WindowManager::windowVisibilityChanged, this,
&TrayIcon::updateTrayMenuFlags); &TrayIcon::onWindowVisibilityChanged);
connect(windowManager()->graphWindow(), &WidgetWindow::visibilityChanged, m_graphAction,
&QAction::setChecked);
connect(settings(), &FortSettings::passwordCheckedChanged, this, connect(settings(), &FortSettings::passwordCheckedChanged, this,
&TrayIcon::updateTrayMenuFlags); &TrayIcon::updateTrayMenuFlags);
@ -738,3 +735,15 @@ void TrayIcon::onTrayActivatedByClick(TrayIcon::ClickType clickType, bool checkT
m_trayTriggered = false; m_trayTriggered = false;
onMouseClicked(clickType); onMouseClicked(clickType);
} }
void TrayIcon::onWindowVisibilityChanged(quint32 code, bool isVisible)
{
switch (code) {
case WindowOptions: {
updateTrayMenuFlags();
} break;
case WindowGraph: {
m_graphAction->setChecked(isVisible);
} break;
}
}

View File

@ -116,6 +116,8 @@ private:
void onTrayActivatedByTrigger(); void onTrayActivatedByTrigger();
void onTrayActivatedByClick(TrayIcon::ClickType clickType, bool checkTriggered = false); void onTrayActivatedByClick(TrayIcon::ClickType clickType, bool checkTriggered = false);
void onWindowVisibilityChanged(quint32 code, bool isVisible);
private: private:
bool m_trayTriggered : 1; bool m_trayTriggered : 1;
bool m_alerted : 1; bool m_alerted : 1;