changeset 294:99cbc51433e4

*: 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
author Paper <paper@paper.us.eu.org>
date Sun, 12 May 2024 18:16:08 -0400
parents 703fb7d7c917
children b82841e76e79
files include/gui/widgets/sidebar.h src/gui/dialog/about.cc src/gui/dialog/information.cc src/gui/dialog/settings.cc src/gui/dialog/settings/recognition.cc src/gui/widgets/sidebar.cc
diffstat 6 files changed, 10 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- 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);
--- 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 @@
 	    "  </ul>"
 	    "</body>";
 
-	{
-		QPalette pal = QPalette();
-		pal.setColor(QPalette::Window, pal.color(QPalette::Base));
-		setPalette(pal);
-	}
+	setBackgroundRole(QPalette::Base);
 
 	{
 		QTextBrowser* paragraph = new QTextBrowser(this);
--- 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);
 	}
 
--- 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);
--- 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;
 }
--- 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) {