From 701aa93b0a7d3fcf93b556f0dca06786f62539f8 Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Wed, 9 May 2018 01:00:10 +0300 Subject: [PATCH] Add scrollbar in the settings menu --- resources/styles/nheko-dark.qss | 11 +++++++++++ resources/styles/nheko.qss | 11 +++++++++++ src/UserSettingsPage.cc | 28 +++++++++++++--------------- src/ui/ToggleButton.cc | 1 - 4 files changed, 35 insertions(+), 16 deletions(-) diff --git a/resources/styles/nheko-dark.qss b/resources/styles/nheko-dark.qss index e0a6fe20..35b4cd10 100644 --- a/resources/styles/nheko-dark.qss +++ b/resources/styles/nheko-dark.qss @@ -119,6 +119,10 @@ UserSettingsPage { background-color: #202228; } +#UserSettingScrollWidget { + background-color: #202228; +} + Avatar { qproperty-textColor: white; qproperty-backgroundColor: #2d3139; @@ -213,3 +217,10 @@ TextInputWidget > QLineEdit { background-color: #2d3139; color: #caccd1; } + +Toggle { + qproperty-activeColor: #38a3d8; + qproperty-disabledColor: gray; + qproperty-inactiveColor: gray; + qproperty-trackColor: rgb(240, 240, 240); +} diff --git a/resources/styles/nheko.qss b/resources/styles/nheko.qss index 2a746e37..dbc8d1e0 100644 --- a/resources/styles/nheko.qss +++ b/resources/styles/nheko.qss @@ -121,6 +121,10 @@ UserSettingsPage { background-color: white; } +#UserSettingScrollWidget { + background-color: white; +} + Avatar { qproperty-textColor: black; qproperty-backgroundColor: #eee; @@ -201,3 +205,10 @@ TopRoomBar { border: none; qproperty-borderColor: #dcdcdc; } + +Toggle { + qproperty-activeColor: #38a3d8; + qproperty-disabledColor: gray; + qproperty-inactiveColor: gray; + qproperty-trackColor: rgb(240, 240, 240); +} diff --git a/src/UserSettingsPage.cc b/src/UserSettingsPage.cc index fe66c189..8bf77533 100644 --- a/src/UserSettingsPage.cc +++ b/src/UserSettingsPage.cc @@ -135,8 +135,6 @@ UserSettingsPage::UserSettingsPage(QSharedPointer settings, QWidge trayOptionLayout_->setContentsMargins(0, OptionMargin, 0, OptionMargin); auto trayLabel = new QLabel(tr("Minimize to tray"), this); trayToggle_ = new Toggle(this); - trayToggle_->setActiveColor(QColor("#38A3D8")); - trayToggle_->setInactiveColor(QColor("gray")); trayLabel->setStyleSheet("font-size: 15px;"); trayOptionLayout_->addWidget(trayLabel); @@ -146,8 +144,6 @@ UserSettingsPage::UserSettingsPage(QSharedPointer settings, QWidge startInTrayOptionLayout_->setContentsMargins(0, OptionMargin, 0, OptionMargin); auto startInTrayLabel = new QLabel(tr("Start in tray"), this); startInTrayToggle_ = new Toggle(this); - startInTrayToggle_->setActiveColor(QColor("#38A3D8")); - startInTrayToggle_->setInactiveColor(QColor("gray")); if (!settings_->isTrayEnabled()) startInTrayToggle_->setDisabled(true); startInTrayLabel->setStyleSheet("font-size: 15px;"); @@ -160,8 +156,6 @@ UserSettingsPage::UserSettingsPage(QSharedPointer settings, QWidge orderRoomLayout->setContentsMargins(0, OptionMargin, 0, OptionMargin); auto orderLabel = new QLabel(tr("Re-order rooms based on activity"), this); roomOrderToggle_ = new Toggle(this); - roomOrderToggle_->setActiveColor(QColor("#38A3D8")); - roomOrderToggle_->setInactiveColor(QColor("gray")); orderLabel->setStyleSheet("font-size: 15px;"); orderRoomLayout->addWidget(orderLabel); @@ -171,8 +165,6 @@ UserSettingsPage::UserSettingsPage(QSharedPointer settings, QWidge groupViewLayout->setContentsMargins(0, OptionMargin, 0, OptionMargin); auto groupViewLabel = new QLabel(tr("Group's sidebar"), this); groupViewToggle_ = new Toggle(this); - groupViewToggle_->setActiveColor(QColor("#38A3D8")); - groupViewToggle_->setInactiveColor(QColor("gray")); groupViewLabel->setStyleSheet("font-size: 15px;"); groupViewLayout->addWidget(groupViewLabel); @@ -182,8 +174,6 @@ UserSettingsPage::UserSettingsPage(QSharedPointer settings, QWidge typingLayout->setContentsMargins(0, OptionMargin, 0, OptionMargin); auto typingLabel = new QLabel(tr("Typing notifications"), this); typingNotifications_ = new Toggle(this); - typingNotifications_->setActiveColor(QColor("#38A3D8")); - typingNotifications_->setInactiveColor(QColor("gray")); typingLabel->setStyleSheet("font-size: 15px;"); typingLayout->addWidget(typingLabel); @@ -193,8 +183,6 @@ UserSettingsPage::UserSettingsPage(QSharedPointer settings, QWidge receiptsLayout->setContentsMargins(0, OptionMargin, 0, OptionMargin); auto receiptsLabel = new QLabel(tr("Read receipts"), this); readReceipts_ = new Toggle(this); - readReceipts_->setActiveColor(QColor("#38A3D8")); - readReceipts_->setInactiveColor(QColor("gray")); receiptsLabel->setStyleSheet("font-size: 15px;"); receiptsLayout->addWidget(receiptsLabel); @@ -222,7 +210,6 @@ UserSettingsPage::UserSettingsPage(QSharedPointer settings, QWidge mainLayout_->addWidget(general_, 1, Qt::AlignLeft | Qt::AlignVCenter); mainLayout_->addWidget(new HorizontalLine(this)); mainLayout_->addLayout(trayOptionLayout_); - mainLayout_->addWidget(new HorizontalLine(this)); mainLayout_->addLayout(startInTrayOptionLayout_); mainLayout_->addWidget(new HorizontalLine(this)); mainLayout_->addLayout(orderRoomLayout); @@ -235,9 +222,20 @@ UserSettingsPage::UserSettingsPage(QSharedPointer settings, QWidge mainLayout_->addLayout(themeOptionLayout_); mainLayout_->addWidget(new HorizontalLine(this)); + auto scrollArea_ = new QScrollArea(this); + scrollArea_->setFrameShape(QFrame::NoFrame); + scrollArea_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + scrollArea_->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents); + scrollArea_->setWidgetResizable(true); + scrollArea_->setAlignment(Qt::AlignTop | Qt::AlignVCenter); + + auto scrollAreaContents_ = new QWidget(this); + scrollAreaContents_->setObjectName("UserSettingScrollWidget"); + scrollAreaContents_->setLayout(mainLayout_); + + scrollArea_->setWidget(scrollAreaContents_); topLayout_->addLayout(topBarLayout_); - topLayout_->addLayout(mainLayout_); - topLayout_->addStretch(1); + topLayout_->addWidget(scrollArea_); topLayout_->addWidget(versionInfo); connect(themeCombo_, diff --git a/src/ui/ToggleButton.cc b/src/ui/ToggleButton.cc index e7b242b8..755f528f 100644 --- a/src/ui/ToggleButton.cc +++ b/src/ui/ToggleButton.cc @@ -35,7 +35,6 @@ Toggle::init() setCursor(QCursor(Qt::PointingHandCursor)); setCheckable(true); setChecked(false); - setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); setState(false); setupProperties();