From eaf84540fda78823233e3ae0204279c28e4f7cb1 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 15 Jul 2024 11:40:17 +1000 Subject: [PATCH] Ensure QgsPropertyOverrideButtons always look correct We shouldn't require the main window stylesheet to be applied for these buttons to look right --- src/app/qgisappstylesheet.cpp | 5 ----- src/gui/qgspropertyoverridebutton.cpp | 6 ++++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/app/qgisappstylesheet.cpp b/src/app/qgisappstylesheet.cpp index dd283eadd39..964bbe66ed2 100644 --- a/src/app/qgisappstylesheet.cpp +++ b/src/app/qgisappstylesheet.cpp @@ -171,11 +171,6 @@ void QgisAppStyleSheet::applyStyleSheet( const QMap &opts ) "}" ) .arg( palette.highlight().color().name(), palette.highlightedText().color().name() ); - - ss += QLatin1String( "QgsPropertyOverrideButton { background: none; border: 1px solid rgba(0, 0, 0, 0%); } QgsPropertyOverrideButton:focus { border: 1px solid palette(highlight); }" ); -#ifdef Q_OS_MACX - ss += QLatin1String( "QgsPropertyOverrideButton::menu-indicator { width: 5px; }" ); -#endif } QgsDebugMsgLevel( QStringLiteral( "Stylesheet built: %1" ).arg( ss ), 2 ); diff --git a/src/gui/qgspropertyoverridebutton.cpp b/src/gui/qgspropertyoverridebutton.cpp index c573d098d63..927780959f4 100644 --- a/src/gui/qgspropertyoverridebutton.cpp +++ b/src/gui/qgspropertyoverridebutton.cpp @@ -42,6 +42,12 @@ QgsPropertyOverrideButton::QgsPropertyOverrideButton( QWidget *parent, { setFocusPolicy( Qt::StrongFocus ); + QString ss = QStringLiteral( "QgsPropertyOverrideButton { background: none; border: 1px solid rgba(0, 0, 0, 0%); } QgsPropertyOverrideButton:focus { border: 1px solid palette(highlight); }" ); +#ifdef Q_OS_MACX + ss += QLatin1String( "QgsPropertyOverrideButton::menu-indicator { width: 5px; }" ); +#endif + setStyleSheet( ss ); + int iconSize = QgsGuiUtils::scaleIconSize( 24 ); // button width is 1.25 * icon size, height 1.1 * icon size. But we round to ensure even pixel sizes for equal margins