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

View File

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

View File

@ -211,8 +211,7 @@ QLayout *ProgramsWindow::setupHeader()
&WindowManager::showServicesWindow);
// Menu button
m_btMenu = ControlUtil::createLinkButton(":/icons/large_tiles.png");
m_btMenu->setMenu(windowManager()->trayIcon()->menu());
m_btMenu = windowManager()->createMenuButton();
layout->addWidget(m_btEdit);
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());
// Menu button
m_btMenu = ControlUtil::createLinkButton(":/icons/large_tiles.png");
m_btMenu->setMenu(windowManager()->trayIcon()->menu());
m_btMenu = windowManager()->createMenuButton();
m_tabWidget->setCornerWidget(m_btMenu);
}

View File

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

View File

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