From 03cf6e81ffb7fc871968c4a72c0f8067a607bd41 Mon Sep 17 00:00:00 2001 From: fourtf Date: Fri, 21 Feb 2020 03:01:48 +0100 Subject: [PATCH] fixed spaces and margins in general settings --- resources/qss/settings.qss | 1 - src/widgets/dialogs/SettingsDialog.cpp | 19 +++++++++---------- src/widgets/settingspages/GeneralPage.cpp | 12 ++++++++---- src/widgets/settingspages/GeneralPage.hpp | 6 ++++++ 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/resources/qss/settings.qss b/resources/qss/settings.qss index 590dff5f..a3172fd6 100644 --- a/resources/qss/settings.qss +++ b/resources/qss/settings.qss @@ -39,7 +39,6 @@ chatterino--TitleLabel { font-family: "Segoe UI light"; font-size: 24px; color: #4FC3F7; - margin-top: 16px; } chatterino--DescriptionLabel { diff --git a/src/widgets/dialogs/SettingsDialog.cpp b/src/widgets/dialogs/SettingsDialog.cpp index e33c260e..5fc79780 100644 --- a/src/widgets/dialogs/SettingsDialog.cpp +++ b/src/widgets/dialogs/SettingsDialog.cpp @@ -33,8 +33,7 @@ SettingsDialog::SettingsDialog() this->initUi(); this->addTabs(); this->overrideBackgroundColor_ = QColor("#111111"); - this->scaleChangedEvent( - this->scale()); // execute twice to fix performance + width of item + this->scaleChangedEvent(this->scale()); // execute twice to width of item } void SettingsDialog::initUi() @@ -67,13 +66,9 @@ void SettingsDialog::initUi() .assign(&this->ui_.tabContainer); // right side (pages) - auto right = - centerBox.emplace().withoutMargin().withoutSpacing(); - { - right.emplace() - .assign(&this->ui_.pageStack) - .withoutMargin(); - } + centerBox.emplace() + .assign(&this->ui_.pageStack) + .withoutMargin(); this->ui_.pageStack->setMargin(0); @@ -155,6 +150,8 @@ void SettingsDialog::addTabs() this->ui_.tabContainer->setContentsMargins(0, 20, 0, 20); + // Constructors are wrapped in std::function to remove some strain from first time loading. + // clang-format off this->addTab([]{return new GeneralPage;}, "General", ":/settings/about.svg"); this->ui_.tabContainer->addSpacing(16); @@ -268,8 +265,10 @@ void SettingsDialog::showDialog(SettingsDialogPreference preferredTab) void SettingsDialog::refresh() { + // Resets the cancel button. getSettings()->saveSnapshot(); + // Updates tabs. for (auto *tab : this->tabs_) { tab->page()->onShow(); @@ -300,7 +299,7 @@ void SettingsDialog::themeChangedEvent() BaseWindow::themeChangedEvent(); QPalette palette; - palette.setColor(QPalette::Background, QColor("#111")); + palette.setColor(QPalette::Window, QColor("#111")); this->setPalette(palette); } diff --git a/src/widgets/settingspages/GeneralPage.cpp b/src/widgets/settingspages/GeneralPage.cpp index bbc972a7..086b7a6a 100644 --- a/src/widgets/settingspages/GeneralPage.cpp +++ b/src/widgets/settingspages/GeneralPage.cpp @@ -74,14 +74,16 @@ namespace { TitleLabel *SettingsLayout::addTitle(const QString &title) { - auto label = new TitleLabel(title + ":"); + // space + if (!this->groups_.empty()) + this->addWidget(this->groups_.back().space = new Space); - if (this->count() == 0) - label->setStyleSheet("margin-top: 0"); + // title + auto label = new TitleLabel(title + ":"); this->addWidget(label); // groups - this->groups_.push_back(Group{title, label, {}}); + this->groups_.push_back(Group{title, label, nullptr, {}}); return label; } @@ -228,6 +230,8 @@ bool SettingsLayout::filterElements(const QString &query) } } + if (group.space) + group.space->setVisible(groupAny); group.title->setVisible(groupAny); any |= groupAny; } diff --git a/src/widgets/settingspages/GeneralPage.hpp b/src/widgets/settingspages/GeneralPage.hpp index 76e3dc46..d0dc0e4e 100644 --- a/src/widgets/settingspages/GeneralPage.hpp +++ b/src/widgets/settingspages/GeneralPage.hpp @@ -17,6 +17,11 @@ class QComboBox; namespace chatterino { +class Space : public QLabel +{ + Q_OBJECT +}; + class TitleLabel : public QLabel { Q_OBJECT @@ -162,6 +167,7 @@ private: struct Group { QString name; QWidget *title{}; + Space *space{}; std::vector widgets; };