UI: Unify "Menu" button creation

This commit is contained in:
Nodir Temirkhodjaev 2023-11-22 17:41:02 +03:00
parent 611e8865e0
commit 2fe847f3af
6 changed files with 18 additions and 10 deletions

View File

@ -90,7 +90,6 @@ void HomeWindow::retranslateUi()
m_btPasswordLock->setText(tr("Lock")); m_btPasswordLock->setText(tr("Lock"));
m_btPasswordUnlock->setText(tr("Unlock")); m_btPasswordUnlock->setText(tr("Unlock"));
m_btMenu->setText(tr("Menu"));
m_btLogs->setText(tr("Logs")); m_btLogs->setText(tr("Logs"));
m_btProfile->setText(tr("Profile")); m_btProfile->setText(tr("Profile"));
@ -152,7 +151,7 @@ QWidget *HomeWindow::setupHeader()
frame->setPalette(palette); frame->setPalette(palette);
auto layout = new QHBoxLayout(); auto layout = new QHBoxLayout();
layout->setContentsMargins(16, 6, 16, 6); layout->setContentsMargins(16, 6, 6, 6);
layout->setSpacing(10); layout->setSpacing(10);
// Logo image // Logo image
@ -170,8 +169,7 @@ QWidget *HomeWindow::setupHeader()
setupPasswordButtons(); setupPasswordButtons();
// Menu button // Menu button
m_btMenu = ControlUtil::createButton(":/icons/large_tiles.png"); m_btMenu = windowManager()->createMenuButton();
m_btMenu->setMenu(windowManager()->trayIcon()->menu());
layout->addWidget(iconLogo); layout->addWidget(iconLogo);
layout->addLayout(textLogo); layout->addLayout(textLogo);

View File

@ -80,8 +80,7 @@ void OptMainPage::setupTabBar()
m_tabWidget->addTab(schedulePage, IconCache::icon(":/icons/clock.png"), QString()); m_tabWidget->addTab(schedulePage, IconCache::icon(":/icons/clock.png"), QString());
// Menu button // Menu button
m_btMenu = ControlUtil::createLinkButton(":/icons/large_tiles.png"); m_btMenu = windowManager()->createMenuButton();
m_btMenu->setMenu(windowManager()->trayIcon()->menu());
m_tabWidget->setCornerWidget(m_btMenu); m_tabWidget->setCornerWidget(m_btMenu);

View File

@ -211,8 +211,7 @@ QLayout *ProgramsWindow::setupHeader()
&WindowManager::showServicesWindow); &WindowManager::showServicesWindow);
// Menu button // Menu button
m_btMenu = ControlUtil::createLinkButton(":/icons/large_tiles.png"); m_btMenu = windowManager()->createMenuButton();
m_btMenu->setMenu(windowManager()->trayIcon()->menu());
layout->addWidget(m_btEdit); layout->addWidget(m_btEdit);
layout->addWidget(ControlUtil::createSeparator(Qt::Vertical)); layout->addWidget(ControlUtil::createSeparator(Qt::Vertical));

View File

@ -48,8 +48,7 @@ void StatMainPage::setupTabBar()
m_tabWidget->addTab(connectionsPage, IconCache::icon(":/icons/connect.png"), QString()); m_tabWidget->addTab(connectionsPage, IconCache::icon(":/icons/connect.png"), QString());
// Menu button // Menu button
m_btMenu = ControlUtil::createLinkButton(":/icons/large_tiles.png"); m_btMenu = windowManager()->createMenuButton();
m_btMenu->setMenu(windowManager()->trayIcon()->menu());
m_tabWidget->setCornerWidget(m_btMenu); m_tabWidget->setCornerWidget(m_btMenu);
} }

View File

@ -5,11 +5,13 @@
#include <QMessageBox> #include <QMessageBox>
#include <QMouseEvent> #include <QMouseEvent>
#include <QProcess> #include <QProcess>
#include <QPushButton>
#include <QStyle> #include <QStyle>
#include <QStyleFactory> #include <QStyleFactory>
#include <QStyleHints> #include <QStyleHints>
#include <conf/confmanager.h> #include <conf/confmanager.h>
#include <form/controls/controlutil.h>
#include <form/controls/mainwindow.h> #include <form/controls/mainwindow.h>
#include <form/dialog/passworddialog.h> #include <form/dialog/passworddialog.h>
#include <form/graph/graphwindow.h> #include <form/graph/graphwindow.h>
@ -88,6 +90,13 @@ void WindowManager::tearDown()
closeAll(); closeAll();
} }
QPushButton *WindowManager::createMenuButton() const
{
auto c = ControlUtil::createLinkButton(":/icons/large_tiles.png");
c->setMenu(trayIcon()->menu());
return c;
}
QFont WindowManager::defaultFont() QFont WindowManager::defaultFont()
{ {
static QFont g_font( static QFont g_font(

View File

@ -6,6 +6,8 @@
#include <form/windowtypes.h> #include <form/windowtypes.h>
#include <util/ioc/iocservice.h> #include <util/ioc/iocservice.h>
QT_FORWARD_DECLARE_CLASS(QPushButton)
class GraphWindow; class GraphWindow;
class HomeWindow; class HomeWindow;
class MainWindow; class MainWindow;
@ -49,6 +51,8 @@ public:
bool isWindowOpen(WindowCode code) const { return isAnyWindowOpen(code); } bool isWindowOpen(WindowCode code) const { return isAnyWindowOpen(code); }
QPushButton *createMenuButton() const;
static QFont defaultFont(); static QFont defaultFont();
signals: signals: