# HG changeset patch # User Paper # Date 1715552168 14400 # Node ID 99cbc51433e4f77e4eb669666e9c8a24f7b03772 # Parent 703fb7d7c9170f5435087e56e44d14dd812fb8b8 *: cleanup uses of QPalette I didn't know about setBackgroundRole() which is very useful in 99% of the cases where I even needed to edit the palette diff -r 703fb7d7c917 -r 99cbc51433e4 include/gui/widgets/sidebar.h --- a/include/gui/widgets/sidebar.h Sun May 12 18:06:44 2024 -0400 +++ b/include/gui/widgets/sidebar.h Sun May 12 18:16:08 2024 -0400 @@ -16,7 +16,7 @@ int GetCurrentItem(); bool IndexIsSeparator(QModelIndex index) const; static QIcon CreateIcon(const char* file); - void SetBackgroundColor(QColor color); + void SetBackgroundTransparent(bool yes); signals: void CurrentItemChanged(int index); diff -r 703fb7d7c917 -r 99cbc51433e4 src/gui/dialog/about.cc --- a/src/gui/dialog/about.cc Sun May 12 18:06:44 2024 -0400 +++ b/src/gui/dialog/about.cc Sun May 12 18:16:08 2024 -0400 @@ -113,11 +113,7 @@ " " ""; - { - QPalette pal = QPalette(); - pal.setColor(QPalette::Window, pal.color(QPalette::Base)); - setPalette(pal); - } + setBackgroundRole(QPalette::Base); { QTextBrowser* paragraph = new QTextBrowser(this); diff -r 703fb7d7c917 -r 99cbc51433e4 src/gui/dialog/information.cc --- a/src/gui/dialog/information.cc Sun May 12 18:06:44 2024 -0400 +++ b/src/gui/dialog/information.cc Sun May 12 18:16:08 2024 -0400 @@ -294,6 +294,7 @@ layout->addWidget(main_widget); } layout->setSpacing(12); + layout->setContentsMargins(0, 0, 0, 0); full_layout->addWidget(widget); } diff -r 703fb7d7c917 -r 99cbc51433e4 src/gui/dialog/settings.cc --- a/src/gui/dialog/settings.cc Sun May 12 18:06:44 2024 -0400 +++ b/src/gui/dialog/settings.cc Sun May 12 18:16:08 2024 -0400 @@ -25,7 +25,7 @@ page_title->setFont(font); { - QPalette pal = page_title->palette(); + QPalette pal(page_title->palette()); pal.setColor(QPalette::Window, QColor(0xAB, 0xAB, 0xAB)); pal.setColor(QPalette::WindowText, Qt::white); page_title->setPalette(pal); @@ -98,8 +98,8 @@ sidebar->setIconSize(QSize(24, 24)); sidebar->setFrameShape(QFrame::Box); - QPalette pal(sidebar->palette()); - sidebar->SetBackgroundColor(pal.color(QPalette::Base)); + sidebar->SetBackgroundTransparent(false); + sidebar->setBackgroundRole(QPalette::Base); sidebar->setFixedWidth(158); sidebar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); diff -r 703fb7d7c917 -r 99cbc51433e4 src/gui/dialog/settings/recognition.cc --- a/src/gui/dialog/settings/recognition.cc Sun May 12 18:06:44 2024 -0400 +++ b/src/gui/dialog/settings/recognition.cc Sun May 12 18:16:08 2024 -0400 @@ -64,6 +64,7 @@ } full_layout->setSpacing(10); + full_layout->setContentsMargins(0, 0, 0, 0); return result; } diff -r 703fb7d7c917 -r 99cbc51433e4 src/gui/widgets/sidebar.cc --- a/src/gui/widgets/sidebar.cc Sun May 12 18:06:44 2024 -0400 +++ b/src/gui/widgets/sidebar.cc Sun May 12 18:16:08 2024 -0400 @@ -14,7 +14,7 @@ /* FIXME: is there an easy way to do this with palettes? */ setStyleSheet("QListWidget::item:disabled { background: transparent }"); - SetBackgroundColor(Qt::transparent); + SetBackgroundTransparent(true); connect(this, &QListWidget::currentRowChanged, this, [this](int index) { emit CurrentItemChanged(RemoveSeparatorsFromIndex(index)); }); @@ -28,8 +28,8 @@ return RemoveSeparatorsFromIndex(currentRow()); } -void SideBar::SetBackgroundColor(QColor color) { - viewport()->setAutoFillBackground(color != Qt::transparent); +void SideBar::SetBackgroundTransparent(bool yes) { + viewport()->setAutoFillBackground(!yes); } QListWidgetItem* SideBar::AddItem(QString name, QIcon icon) {