UI: Statistics: Add "Options" button

This commit is contained in:
Nodir Temirkhodjaev 2024-01-15 15:22:47 +03:00
parent 5afc73063f
commit 8692bbb3f2
4 changed files with 46 additions and 3 deletions

View File

@ -3,6 +3,7 @@
#include <QIcon>
#include <QPushButton>
#include <QTabWidget>
#include <QToolButton>
#include <QVBoxLayout>
#include <form/controls/controlutil.h>
@ -24,6 +25,8 @@ void StatMainPage::onRetranslateUi()
{
m_tabWidget->setTabText(0, tr("Traffic"));
m_tabWidget->setTabText(1, tr("Blocked Connections"));
m_btOptions->setText(tr("Options"));
}
void StatMainPage::setupUi()
@ -47,8 +50,33 @@ void StatMainPage::setupTabBar()
m_tabWidget->addTab(statisticsPage, IconCache::icon(":/icons/chart_bar.png"), QString());
m_tabWidget->addTab(connectionsPage, IconCache::icon(":/icons/connect.png"), QString());
setupCornerWidget();
}
void StatMainPage::setupCornerWidget()
{
auto layout = setupCornerLayout();
auto w = new QWidget();
w->setLayout(layout);
m_tabWidget->setCornerWidget(w);
}
QLayout *StatMainPage::setupCornerLayout()
{
// Options button
m_btOptions = ControlUtil::createFlatToolButton(":/icons/cog.png");
connect(m_btOptions, &QAbstractButton::clicked, windowManager(),
&WindowManager::showStatOptionsWindow);
// Menu button
m_btMenu = windowManager()->createMenuButton();
m_tabWidget->setCornerWidget(m_btMenu);
auto layout = ControlUtil::createHLayoutByWidgets(
{ m_btOptions, ControlUtil::createVSeparator(), m_btMenu });
layout->setContentsMargins(0, 0, 0, 0);
return layout;
}

View File

@ -18,9 +18,12 @@ protected slots:
private:
void setupUi();
void setupTabBar();
void setupCornerWidget();
QLayout *setupCornerLayout();
private:
QTabWidget *m_tabWidget = nullptr;
QToolButton *m_btOptions = nullptr;
QPushButton *m_btMenu = nullptr;
};

View File

@ -434,15 +434,25 @@ void WindowManager::closeStatisticsWindow()
}
}
void WindowManager::showAppGroupsWindow()
void WindowManager::showOptionsWindowTab(int index)
{
showOptionsWindow();
if (m_optWindow) {
m_optWindow->selectTab(2);
m_optWindow->selectTab(index);
}
}
void WindowManager::showAppGroupsWindow()
{
showOptionsWindowTab(2);
}
void WindowManager::showStatOptionsWindow()
{
showOptionsWindowTab(3);
}
void WindowManager::showServicesWindow()
{
if (!checkWindowPassword(WindowServices))

View File

@ -92,7 +92,9 @@ public slots:
void showStatisticsWindow();
void closeStatisticsWindow();
void showOptionsWindowTab(int index);
void showAppGroupsWindow();
void showStatOptionsWindow();
void showServicesWindow();
void closeServicesWindow();