From 90cb009e73898b17cbb48b95d6015b27c9a82a31 Mon Sep 17 00:00:00 2001 From: Alfredo Monclus Date: Tue, 28 Jan 2025 06:37:00 -0300 Subject: [PATCH] fix(Gui): transparencies issues when using overlays refactor: use replace to avoid numbering refactor: fix the lint warnings refactor: fix clazy complaints refactor: apply review recommendation --- src/Gui/QSint/actionpanel/freecadscheme.cpp | 66 +++++++++++++-------- 1 file changed, 40 insertions(+), 26 deletions(-) diff --git a/src/Gui/QSint/actionpanel/freecadscheme.cpp b/src/Gui/QSint/actionpanel/freecadscheme.cpp index 3c22f30de8..4ee033b5ae 100644 --- a/src/Gui/QSint/actionpanel/freecadscheme.cpp +++ b/src/Gui/QSint/actionpanel/freecadscheme.cpp @@ -29,6 +29,7 @@ #include #include #include +#include namespace QSint @@ -262,35 +263,53 @@ QPixmap SystemPanelScheme::drawFoldIcon(const QPalette& palette, bool fold, bool QString SystemPanelScheme::systemStyle(const QPalette& p) const { - QColor headerBackground = p.color(QPalette::Highlight); - QColor headerLabelText = p.color(QPalette::HighlightedText); - QColor headerLabelTextOver = p.color(QPalette::BrightText); - QColor groupBorder = p.color(QPalette::Mid); - QColor disabledActionText = p.color(QPalette::Disabled, QPalette::Text); - QColor actionSelectedBg = p.color(QPalette::Active, QPalette::Light); - QColor actionSelectedText = p.color(QPalette::Active, QPalette::ButtonText); - QColor actionSelectedBorder = p.color(QPalette::Active, QPalette::Highlight); + QHash replacements; + replacements.insert(QStringLiteral("headerBackground"), + p.color(QPalette::Highlight).name()); + replacements.insert(QStringLiteral("headerLabelText"), + p.color(QPalette::HighlightedText).name()); + replacements.insert(QStringLiteral("headerLabelTextOver"), + p.color(QPalette::BrightText).name()); + replacements.insert(QStringLiteral("groupBorder"), + p.color(QPalette::Mid).name()); + replacements.insert(QStringLiteral("disabledActionText"), + p.color(QPalette::Disabled, QPalette::Text).name()); + replacements.insert(QStringLiteral("actionSelectedBg"), + p.color(QPalette::Active, QPalette::Light).name()); + replacements.insert(QStringLiteral("actionSelectedText"), + p.color(QPalette::Active, QPalette::ButtonText).name()); + replacements.insert(QStringLiteral("actionSelectedBorder"), + p.color(QPalette::Active, QPalette::Highlight).name()); + replacements.insert(QStringLiteral("panelBackground"), + p.color(QPalette::Window).name()); + replacements.insert(QStringLiteral("groupBackground"), + p.color(QPalette::Button).name()); QString style = QStringLiteral( + "QFrame[class='panel'] {" + "background-color: {panelBackground};" + "}" + "QSint--ActionGroup QFrame[class='header'] {" "border: 1px solid transparent;" - "background-color: %1;" + "background-color: {headerBackground};" "}" "QSint--ActionGroup QToolButton[class='header'] {" "text-align: left;" - "color: %2;" + "color: {headerLabelText};" "background-color: transparent;" "border: 1px solid transparent;" "font-weight: bold;" "}" "QSint--ActionGroup QToolButton[class='header']:hover {" - "color: %3;" + "color: {headerLabelTextOver};" "}" "QSint--ActionGroup QFrame[class='content'] {" - "border: 1px solid %4;" + "border: 1px solid {groupBorder};" + "background-color: {groupBackground};" "}" "QSint--ActionGroup QFrame[class='content'][header='true'] {" @@ -304,7 +323,7 @@ QString SystemPanelScheme::systemStyle(const QPalette& p) const "}" "QSint--ActionGroup QToolButton[class='action']:!enabled {" - "color: %5;" + "color: {disabledActionText};" "}" "QSint--ActionGroup QToolButton[class='action']:hover {" @@ -312,25 +331,20 @@ QString SystemPanelScheme::systemStyle(const QPalette& p) const "}" "QSint--ActionGroup QToolButton[class='action']:focus {" - "color: %7;" - "border: 1px dotted %8;" + "color: {actionSelectedText};" + "border: 1px dotted {actionSelectedBorder};" "}" "QSint--ActionGroup QToolButton[class='action']:on {" - "background-color: %6;" - "color: %7;" + "background-color: {actionSelectedBg};" + "color: {actionSelectedText};" "}" - ).arg( - headerBackground.name(), - headerLabelText.name(), - headerLabelTextOver.name(), - groupBorder.name(), - disabledActionText.name(), - actionSelectedBg.name(), - actionSelectedText.name(), - actionSelectedBorder.name() ); + for (auto it = replacements.begin(); it != replacements.end(); ++it) { + style.replace("{" + it.key() + "}", it.value()); + } + return style; }