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-size: 24px;
color: #4FC3F7;
margin-top: 16px;
}
chatterino--DescriptionLabel {

View file

@ -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<QVBoxLayout>().withoutMargin().withoutSpacing();
{
right.emplace<QStackedLayout>()
.assign(&this->ui_.pageStack)
.withoutMargin();
}
centerBox.emplace<QStackedLayout>()
.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);
}

View file

@ -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;
}

View file

@ -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<Widget> widgets;
};