From dc10d39da8dc0c739f53c1bdc133eadfd246fd77 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Thu, 14 Mar 2024 08:36:58 +0100 Subject: [PATCH] +comms --- GUI/View/Base/Stylesheet.cpp | 20 +++++++++++--------- GUI/View/Base/Stylesheet.h | 1 + 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/GUI/View/Base/Stylesheet.cpp b/GUI/View/Base/Stylesheet.cpp index 671a3034759..85a89b77b2a 100644 --- a/GUI/View/Base/Stylesheet.cpp +++ b/GUI/View/Base/Stylesheet.cpp @@ -19,17 +19,19 @@ void GUI::Style::setInitialStyle() { + // The palette is used by the style sheet, but cannot be set there. + // Therefore it is hard-coded here: + QPalette p = QGuiApplication::palette(); + p.setColor(QPalette::Text, Qt::black); + p.setColor(QPalette::WindowText, Qt::black); + p.setColor(QPalette::Base, Qt::white); + p.setColor(QPalette::AlternateBase, QColor(255, 255, 255).darker(105)); + p.setColor(QPalette::Dark, QColor(255, 255, 255).darker(110)); + p.setColor(QPalette::ToolTipBase, QColor(174, 248, 255)); + QApplication::setPalette(p); + QFile base(":/styles/Base.stylesheet"); base.open(QFile::ReadOnly); QString stylesheet = base.readAll(); qApp->setStyleSheet(stylesheet); - - QPalette styleSheetPalette = QGuiApplication::palette(); - styleSheetPalette.setColor(QPalette::Text, Qt::black); - styleSheetPalette.setColor(QPalette::WindowText, Qt::black); - styleSheetPalette.setColor(QPalette::Base, Qt::white); - styleSheetPalette.setColor(QPalette::AlternateBase, QColor(255, 255, 255).darker(105)); - styleSheetPalette.setColor(QPalette::Dark, QColor(255, 255, 255).darker(110)); - styleSheetPalette.setColor(QPalette::ToolTipBase, QColor(174, 248, 255)); - QApplication::setPalette(styleSheetPalette); } diff --git a/GUI/View/Base/Stylesheet.h b/GUI/View/Base/Stylesheet.h index 5ee038d1053..a49f4033039 100644 --- a/GUI/View/Base/Stylesheet.h +++ b/GUI/View/Base/Stylesheet.h @@ -17,6 +17,7 @@ namespace GUI::Style { +//! Sets the color palette, and loads the style sheet. void setInitialStyle(); } // namespace GUI::Style -- GitLab