UI: HomeWindow: Show menu on activation

This commit is contained in:
Nodir Temirkhodjaev 2023-05-08 16:01:15 +03:00
parent ac61771bc3
commit 2806813f48
5 changed files with 27 additions and 16 deletions

View File

@ -23,6 +23,12 @@ HomeWindow::HomeWindow(QWidget *parent) :
setupUi();
setupController();
setupStateWatcher();
connect(this, &HomeWindow::activationChanged, this, [&] {
if (isActiveWindow()) {
m_btMenu->showMenu();
}
});
}
ConfManager *HomeWindow::confManager() const

View File

@ -240,6 +240,9 @@ void TrayIcon::onTrayActivated(QSystemTrayIcon::ActivationReason reason)
void TrayIcon::updateTrayIcon(bool alerted)
{
if (m_alerted == alerted)
return;
m_alerted = alerted;
m_animatedAlert = false;

View File

@ -327,6 +327,7 @@ void FortManager::show()
if (iniUser.trayShowIcon()) {
windowManager->showTrayIcon();
} else {
windowManager->setupHomeWindow(/*quitOnClose=*/true);
windowManager->showHomeWindow();
}

View File

@ -146,14 +146,6 @@ void WindowManager::closeMainWindow()
m_mainWindow = nullptr;
}
void WindowManager::setupHomeWindow()
{
m_homeWindow = new HomeWindow();
m_homeWindow->restoreWindowState();
connect(m_homeWindow, &HomeWindow::aboutToClose, this, &WindowManager::closeHomeWindow);
}
void WindowManager::setupProgramsWindow()
{
m_progWindow = new ProgramsWindow();
@ -269,14 +261,27 @@ void WindowManager::showTrayMessage(const QString &message, WindowManager::TrayM
m_trayIcon->showMessage(QGuiApplication::applicationDisplayName(), message);
}
void WindowManager::setupHomeWindow(bool quitOnClose)
{
if (m_homeWindow)
return;
m_homeWindow = new HomeWindow();
m_homeWindow->restoreWindowState();
if (quitOnClose) {
connect(m_homeWindow, &HomeWindow::aboutToClose, trayIcon(), &TrayIcon::quitProgram);
} else {
connect(m_homeWindow, &HomeWindow::aboutToClose, this, &WindowManager::closeHomeWindow);
}
}
void WindowManager::showHomeWindow()
{
if (!widgetVisibleByCheckPassword(m_homeWindow))
return;
if (!m_homeWindow) {
setupHomeWindow();
}
showWidget(m_homeWindow);
}
@ -291,10 +296,6 @@ void WindowManager::closeHomeWindow()
m_homeWindow->deleteLater();
m_homeWindow = nullptr;
if (!trayIcon()->isVisible()) {
trayIcon()->quitProgram();
}
}
void WindowManager::showProgramsWindow()

View File

@ -57,6 +57,7 @@ public slots:
void showTrayMessage(
const QString &message, WindowManager::TrayMessageType type = MessageOptions);
void setupHomeWindow(bool quitOnClose = false);
void showHomeWindow();
void closeHomeWindow();
@ -107,7 +108,6 @@ private:
void setupMainWindow();
void closeMainWindow();
void setupHomeWindow();
void setupProgramsWindow();
void setupOptionsWindow();
void setupPoliciesWindow();