mirror of
https://github.com/tnodir/fort
synced 2024-11-15 09:45:44 +00:00
UI: Options: Simplify ScrollArea.
This commit is contained in:
parent
42751356e8
commit
2a75b1760d
@ -148,15 +148,7 @@ QLayout *ControlUtil::createScrollLayout(QLayout *content, bool isBgTransparent)
|
||||
auto scrollAreaContent = new QWidget();
|
||||
scrollAreaContent->setLayout(content);
|
||||
|
||||
auto scrollArea = new QScrollArea();
|
||||
scrollArea->setContentsMargins(0, 0, 0, 0);
|
||||
scrollArea->setWidgetResizable(true);
|
||||
scrollArea->setWidget(scrollAreaContent);
|
||||
|
||||
if (isBgTransparent) {
|
||||
scrollArea->setStyleSheet("QScrollArea { background: transparent; }");
|
||||
scrollAreaContent->setStyleSheet(".QWidget { background: transparent; }");
|
||||
}
|
||||
auto scrollArea = wrapToScrollArea(scrollAreaContent, isBgTransparent);
|
||||
|
||||
auto layout = new QHBoxLayout();
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
@ -165,6 +157,21 @@ QLayout *ControlUtil::createScrollLayout(QLayout *content, bool isBgTransparent)
|
||||
return layout;
|
||||
}
|
||||
|
||||
QWidget *ControlUtil::wrapToScrollArea(QWidget *content, bool isBgTransparent)
|
||||
{
|
||||
auto c = new QScrollArea();
|
||||
c->setContentsMargins(0, 0, 0, 0);
|
||||
c->setWidgetResizable(true);
|
||||
c->setWidget(content);
|
||||
|
||||
if (isBgTransparent) {
|
||||
c->setStyleSheet("QScrollArea { background: transparent; }");
|
||||
content->setAutoFillBackground(false);
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
QFont ControlUtil::fontDemiBold()
|
||||
{
|
||||
QFont font;
|
||||
|
@ -39,7 +39,9 @@ public:
|
||||
static QBoxLayout *createLayoutByWidgets(
|
||||
const QList<QWidget *> &widgets, Qt::Orientation o = Qt::Vertical);
|
||||
static QFrame *createSeparator(Qt::Orientation o = Qt::Horizontal);
|
||||
|
||||
static QLayout *createScrollLayout(QLayout *content, bool isBgTransparent = true);
|
||||
static QWidget *wrapToScrollArea(QWidget *content, bool isBgTransparent = true);
|
||||
|
||||
static QFont fontDemiBold();
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <QIcon>
|
||||
#include <QPushButton>
|
||||
#include <QScrollArea>
|
||||
#include <QTabWidget>
|
||||
#include <QUrl>
|
||||
#include <QVBoxLayout>
|
||||
@ -61,19 +62,19 @@ void MainPage::setupTabBar()
|
||||
{
|
||||
m_tabBar = new QTabWidget();
|
||||
|
||||
m_optionsPage = new OptionsPage(ctrl());
|
||||
m_addressesPage = new AddressesPage(ctrl());
|
||||
m_rulesPage = new RulesPage(ctrl());
|
||||
m_applicationsPage = new ApplicationsPage(ctrl());
|
||||
m_statisticsPage = new StatisticsPage(ctrl());
|
||||
m_schedulePage = new SchedulePage(ctrl());
|
||||
auto optionsPage = ControlUtil::wrapToScrollArea(new OptionsPage(ctrl()));
|
||||
auto addressesPage = new AddressesPage(ctrl());
|
||||
auto rulesPage = new RulesPage(ctrl());
|
||||
auto applicationsPage = new ApplicationsPage(ctrl());
|
||||
auto statisticsPage = new StatisticsPage(ctrl());
|
||||
auto schedulePage = new SchedulePage(ctrl());
|
||||
|
||||
m_tabBar->addTab(m_optionsPage, IconCache::icon(":/icons/cog.png"), QString());
|
||||
m_tabBar->addTab(m_addressesPage, IconCache::icon(":/icons/map-marker.png"), QString());
|
||||
m_tabBar->addTab(m_rulesPage, IconCache::icon(":/icons/task-list.png"), QString());
|
||||
m_tabBar->addTab(m_applicationsPage, IconCache::icon(":/icons/window.png"), QString());
|
||||
m_tabBar->addTab(m_statisticsPage, IconCache::icon(":/icons/database.png"), QString());
|
||||
m_tabBar->addTab(m_schedulePage, IconCache::icon(":/icons/clock.png"), QString());
|
||||
m_tabBar->addTab(optionsPage, IconCache::icon(":/icons/cog.png"), QString());
|
||||
m_tabBar->addTab(addressesPage, IconCache::icon(":/icons/map-marker.png"), QString());
|
||||
m_tabBar->addTab(rulesPage, IconCache::icon(":/icons/task-list.png"), QString());
|
||||
m_tabBar->addTab(applicationsPage, IconCache::icon(":/icons/window.png"), QString());
|
||||
m_tabBar->addTab(statisticsPage, IconCache::icon(":/icons/database.png"), QString());
|
||||
m_tabBar->addTab(schedulePage, IconCache::icon(":/icons/clock.png"), QString());
|
||||
|
||||
m_tabBar->setTabVisible(2, false); // TODO: Impl. Network Rules
|
||||
}
|
||||
|
@ -5,13 +5,6 @@
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QTabWidget)
|
||||
|
||||
class AddressesPage;
|
||||
class ApplicationsPage;
|
||||
class OptionsPage;
|
||||
class RulesPage;
|
||||
class SchedulePage;
|
||||
class StatisticsPage;
|
||||
|
||||
class MainPage : public BasePage
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -39,13 +32,6 @@ private:
|
||||
QPushButton *m_btOk = nullptr;
|
||||
QPushButton *m_btApply = nullptr;
|
||||
QPushButton *m_btCancel = nullptr;
|
||||
|
||||
OptionsPage *m_optionsPage = nullptr;
|
||||
AddressesPage *m_addressesPage = nullptr;
|
||||
RulesPage *m_rulesPage = nullptr;
|
||||
ApplicationsPage *m_applicationsPage = nullptr;
|
||||
StatisticsPage *m_statisticsPage = nullptr;
|
||||
SchedulePage *m_schedulePage = nullptr;
|
||||
};
|
||||
|
||||
#endif // MAINPAGE_H
|
||||
|
@ -102,17 +102,6 @@ void OptionsPage::retranslateDriverMessage()
|
||||
}
|
||||
|
||||
void OptionsPage::setupUi()
|
||||
{
|
||||
// Main Layout
|
||||
auto mainLayout = setupMainLayout();
|
||||
|
||||
// Scroll Area
|
||||
auto scrollLayout = ControlUtil::createScrollLayout(mainLayout);
|
||||
|
||||
this->setLayout(scrollLayout);
|
||||
}
|
||||
|
||||
QLayout *OptionsPage::setupMainLayout()
|
||||
{
|
||||
// Column #1
|
||||
auto colLayout1 = setupColumn1();
|
||||
@ -127,7 +116,7 @@ QLayout *OptionsPage::setupMainLayout()
|
||||
layout->addLayout(colLayout2);
|
||||
layout->addStretch();
|
||||
|
||||
return layout;
|
||||
this->setLayout(layout);
|
||||
}
|
||||
|
||||
QLayout *OptionsPage::setupColumn1()
|
||||
|
@ -24,7 +24,6 @@ private:
|
||||
void retranslateDriverMessage();
|
||||
|
||||
void setupUi();
|
||||
QLayout *setupMainLayout();
|
||||
QLayout *setupColumn1();
|
||||
void setupStartupBox();
|
||||
void setupTrafficBox();
|
||||
|
Loading…
Reference in New Issue
Block a user