UI: WindowManager: Move showWidget() to WidgetWindow

This commit is contained in:
Nodir Temirkhodjaev 2023-05-15 13:04:19 +03:00
parent e62ffcd199
commit 11dbd70e62
6 changed files with 25 additions and 21 deletions

View File

@ -10,6 +10,7 @@
#include <form/controls/controlutil.h>
#include <manager/windowmanager.h>
#include <util/guiutil.h>
#include <util/window/widgetwindow.h>
PasswordDialog::PasswordDialog(QWidget *parent) : QDialog(parent)
{
@ -111,7 +112,7 @@ bool PasswordDialog::getPassword(QString &password, UnlockType &unlockType, QWid
{
PasswordDialog dialog(parent);
WindowManager::showWidget(&dialog);
WidgetWindow::showWidget(&dialog);
if (dialog.exec() == 0)
return false;

View File

@ -22,6 +22,7 @@
#include <manager/windowmanager.h>
#include <util/iconcache.h>
#include <util/ioc/ioccontainer.h>
#include <util/window/widgetwindow.h>
#include "programscontroller.h"
@ -98,7 +99,7 @@ void ProgramEditDialog::initialize(const AppRow &appRow, const QVector<qint64> &
void ProgramEditDialog::activate()
{
WindowManager::showWidget(this);
WidgetWindow::showWidget(this);
m_editPath->selectAll();
m_editPath->setFocus();

View File

@ -85,16 +85,6 @@ void WindowManager::tearDown()
closeAll();
}
void WindowManager::showWidget(QWidget *w)
{
if (w->isMinimized()) {
w->setWindowState(w->windowState() ^ Qt::WindowMinimized);
}
w->show();
w->raise();
w->activateWindow();
}
QFont WindowManager::defaultFont()
{
static QFont g_font(
@ -285,7 +275,7 @@ void WindowManager::showHomeWindow()
setupHomeWindow();
showWidget(m_homeWindow);
m_homeWindow->showWindow();
}
void WindowManager::closeHomeWindow()
@ -309,7 +299,7 @@ void WindowManager::showProgramsWindow()
setupProgramsWindow();
}
showWidget(m_progWindow);
m_progWindow->showWindow();
}
void WindowManager::closeProgramsWindow()
@ -348,7 +338,7 @@ void WindowManager::showOptionsWindow()
emit optWindowChanged(true);
}
showWidget(m_optWindow);
m_optWindow->showWindow();
}
void WindowManager::closeOptionsWindow()
@ -387,7 +377,7 @@ void WindowManager::showPoliciesWindow()
setupPoliciesWindow();
}
showWidget(m_policiesWindow);
m_policiesWindow->showWindow();
}
void WindowManager::closePoliciesWindow()
@ -411,7 +401,7 @@ void WindowManager::showStatisticsWindow()
setupStatisticsWindow();
}
showWidget(m_statWindow);
m_statWindow->showWindow();
}
void WindowManager::closeStatisticsWindow()
@ -435,7 +425,7 @@ void WindowManager::showServicesWindow()
setupServicesWindow();
}
showWidget(m_serviceWindow);
m_serviceWindow->showWindow();
}
void WindowManager::closeServicesWindow()
@ -459,7 +449,7 @@ void WindowManager::showZonesWindow()
setupZonesWindow();
}
showWidget(m_zoneWindow);
m_zoneWindow->showWindow();
}
void WindowManager::closeZonesWindow()

View File

@ -40,8 +40,6 @@ public:
void setUp() override;
void tearDown() override;
static void showWidget(QWidget *w);
static QFont defaultFont();
signals:

View File

@ -4,6 +4,16 @@
WidgetWindow::WidgetWindow(QWidget *parent) : QWidget(parent) { }
void WidgetWindow::showWidget(QWidget *w)
{
if (w->isMinimized()) {
w->setWindowState(w->windowState() ^ Qt::WindowMinimized);
}
w->show();
w->raise();
w->activateWindow();
}
void WidgetWindow::moveEvent(QMoveEvent *event)
{
QWidget::moveEvent(event);

View File

@ -10,6 +10,10 @@ class WidgetWindow : public QWidget
public:
explicit WidgetWindow(QWidget *parent = nullptr);
void showWindow() { showWidget(this); }
static void showWidget(QWidget *w);
signals:
void activationChanged(bool isActive);
void activated();