diff --git a/src/ui/form/opt/pages/optbasepage.h b/src/ui/form/opt/pages/optbasepage.h index ebda2963..f16c51b2 100644 --- a/src/ui/form/opt/pages/optbasepage.h +++ b/src/ui/form/opt/pages/optbasepage.h @@ -34,6 +34,9 @@ class OptBasePage : public QFrame public: explicit OptBasePage(OptionsController *ctrl, QWidget *parent = nullptr); +public slots: + virtual void onPageActivated() { } + protected: OptionsController *ctrl() const { return m_ctrl; } FortManager *fortManager() const; diff --git a/src/ui/form/opt/pages/optmainpage.cpp b/src/ui/form/opt/pages/optmainpage.cpp index 4e07497d..c77caaa1 100644 --- a/src/ui/form/opt/pages/optmainpage.cpp +++ b/src/ui/form/opt/pages/optmainpage.cpp @@ -65,7 +65,7 @@ void OptMainPage::setupUi() void OptMainPage::setupTabBar() { - auto optionsPage = ControlUtil::wrapToScrollArea(new OptionsPage(ctrl())); + auto optionsPage = new OptionsPage(ctrl()); auto addressesPage = new AddressesPage(ctrl()); auto rulesPage = new RulesPage(ctrl()); auto applicationsPage = new ApplicationsPage(ctrl()); @@ -73,8 +73,12 @@ void OptMainPage::setupTabBar() auto statisticsPage = new StatisticsPage(ctrl()); auto schedulePage = new SchedulePage(ctrl()); + m_pages = { optionsPage, addressesPage, rulesPage, applicationsPage, servicesPage, + statisticsPage, schedulePage }; + m_tabBar = new QTabWidget(); - m_tabBar->addTab(optionsPage, IconCache::icon(":/icons/cog.png"), QString()); + m_tabBar->addTab(ControlUtil::wrapToScrollArea(optionsPage), IconCache::icon(":/icons/cog.png"), + QString()); m_tabBar->addTab(addressesPage, IconCache::icon(":/icons/ip.png"), QString()); m_tabBar->addTab(rulesPage, IconCache::icon(":/icons/source_code.png"), QString()); m_tabBar->addTab( @@ -86,6 +90,9 @@ void OptMainPage::setupTabBar() #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) m_tabBar->setTabVisible(2, false); // TODO: Impl. Network Rules #endif + + connect(m_tabBar, &QTabWidget::currentChanged, this, + [&](int tabIndex) { m_pages[tabIndex]->onPageActivated(); }); } QLayout *OptMainPage::setupDialogButtons() diff --git a/src/ui/form/opt/pages/optmainpage.h b/src/ui/form/opt/pages/optmainpage.h index b3418f55..a840b4e5 100644 --- a/src/ui/form/opt/pages/optmainpage.h +++ b/src/ui/form/opt/pages/optmainpage.h @@ -32,6 +32,8 @@ private: QPushButton *m_btOk = nullptr; QPushButton *m_btApply = nullptr; QPushButton *m_btCancel = nullptr; + + QVector m_pages; }; #endif // OPTMAINPAGE_H diff --git a/src/ui/form/opt/pages/servicespage.cpp b/src/ui/form/opt/pages/servicespage.cpp index ed461d57..e18fa4b2 100644 --- a/src/ui/form/opt/pages/servicespage.cpp +++ b/src/ui/form/opt/pages/servicespage.cpp @@ -20,8 +20,6 @@ ServicesPage::ServicesPage(OptionsController *ctrl, QWidget *parent) : OptBasePage(ctrl, parent), m_serviceListModel(new ServiceListModel(this)) { setupUi(); - - serviceListModel()->initialize(); } ServiceInfoManager *ServicesPage::serviceInfoManager() const @@ -29,6 +27,11 @@ ServiceInfoManager *ServicesPage::serviceInfoManager() const return IoC(); } +void ServicesPage::onPageActivated() +{ + serviceListModel()->initialize(); +} + void ServicesPage::onRetranslateUi() { m_btRefresh->setText(tr("Refresh")); diff --git a/src/ui/form/opt/pages/servicespage.h b/src/ui/form/opt/pages/servicespage.h index b211c323..45f5596d 100644 --- a/src/ui/form/opt/pages/servicespage.h +++ b/src/ui/form/opt/pages/servicespage.h @@ -17,6 +17,9 @@ public: ServiceListModel *serviceListModel() const { return m_serviceListModel; } ServiceInfoManager *serviceInfoManager() const; +public slots: + void onPageActivated() override; + protected slots: void onRetranslateUi() override; diff --git a/src/ui/serviceinfo/serviceinfomanager.h b/src/ui/serviceinfo/serviceinfomanager.h index 564d76b3..d21349a4 100644 --- a/src/ui/serviceinfo/serviceinfomanager.h +++ b/src/ui/serviceinfo/serviceinfomanager.h @@ -19,9 +19,6 @@ public: static QVector loadServiceInfoList(); -signals: - void serviceChanged(quint32 processId, int groupIndex = -1); - private: QHash m_serviceGroups; };