fixed spaces and margins in general settings

This commit is contained in:
fourtf 2020-02-21 03:01:48 +01:00
parent 5a2633ef5c
commit 03cf6e81ff
4 changed files with 23 additions and 15 deletions

View file

@ -39,7 +39,6 @@ chatterino--TitleLabel {
font-family: "Segoe UI light"; font-family: "Segoe UI light";
font-size: 24px; font-size: 24px;
color: #4FC3F7; color: #4FC3F7;
margin-top: 16px;
} }
chatterino--DescriptionLabel { chatterino--DescriptionLabel {

View file

@ -33,8 +33,7 @@ SettingsDialog::SettingsDialog()
this->initUi(); this->initUi();
this->addTabs(); this->addTabs();
this->overrideBackgroundColor_ = QColor("#111111"); this->overrideBackgroundColor_ = QColor("#111111");
this->scaleChangedEvent( this->scaleChangedEvent(this->scale()); // execute twice to width of item
this->scale()); // execute twice to fix performance + width of item
} }
void SettingsDialog::initUi() void SettingsDialog::initUi()
@ -67,13 +66,9 @@ void SettingsDialog::initUi()
.assign(&this->ui_.tabContainer); .assign(&this->ui_.tabContainer);
// right side (pages) // right side (pages)
auto right = centerBox.emplace<QStackedLayout>()
centerBox.emplace<QVBoxLayout>().withoutMargin().withoutSpacing(); .assign(&this->ui_.pageStack)
{ .withoutMargin();
right.emplace<QStackedLayout>()
.assign(&this->ui_.pageStack)
.withoutMargin();
}
this->ui_.pageStack->setMargin(0); this->ui_.pageStack->setMargin(0);
@ -155,6 +150,8 @@ void SettingsDialog::addTabs()
this->ui_.tabContainer->setContentsMargins(0, 20, 0, 20); 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 // clang-format off
this->addTab([]{return new GeneralPage;}, "General", ":/settings/about.svg"); this->addTab([]{return new GeneralPage;}, "General", ":/settings/about.svg");
this->ui_.tabContainer->addSpacing(16); this->ui_.tabContainer->addSpacing(16);
@ -268,8 +265,10 @@ void SettingsDialog::showDialog(SettingsDialogPreference preferredTab)
void SettingsDialog::refresh() void SettingsDialog::refresh()
{ {
// Resets the cancel button.
getSettings()->saveSnapshot(); getSettings()->saveSnapshot();
// Updates tabs.
for (auto *tab : this->tabs_) for (auto *tab : this->tabs_)
{ {
tab->page()->onShow(); tab->page()->onShow();
@ -300,7 +299,7 @@ void SettingsDialog::themeChangedEvent()
BaseWindow::themeChangedEvent(); BaseWindow::themeChangedEvent();
QPalette palette; QPalette palette;
palette.setColor(QPalette::Background, QColor("#111")); palette.setColor(QPalette::Window, QColor("#111"));
this->setPalette(palette); this->setPalette(palette);
} }

View file

@ -74,14 +74,16 @@ namespace {
TitleLabel *SettingsLayout::addTitle(const QString &title) 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) // title
label->setStyleSheet("margin-top: 0"); auto label = new TitleLabel(title + ":");
this->addWidget(label); this->addWidget(label);
// groups // groups
this->groups_.push_back(Group{title, label, {}}); this->groups_.push_back(Group{title, label, nullptr, {}});
return label; return label;
} }
@ -228,6 +230,8 @@ bool SettingsLayout::filterElements(const QString &query)
} }
} }
if (group.space)
group.space->setVisible(groupAny);
group.title->setVisible(groupAny); group.title->setVisible(groupAny);
any |= groupAny; any |= groupAny;
} }

View file

@ -17,6 +17,11 @@ class QComboBox;
namespace chatterino { namespace chatterino {
class Space : public QLabel
{
Q_OBJECT
};
class TitleLabel : public QLabel class TitleLabel : public QLabel
{ {
Q_OBJECT Q_OBJECT
@ -162,6 +167,7 @@ private:
struct Group { struct Group {
QString name; QString name;
QWidget *title{}; QWidget *title{};
Space *space{};
std::vector<Widget> widgets; std::vector<Widget> widgets;
}; };