From 66deb4bb227c1efbb48bc2d3979ff4ea92eec44f Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Mon, 23 Mar 2020 14:19:24 +0100 Subject: [PATCH] fix style name + fix tab width on mac --- src/app/qgisappstylesheet.cpp | 23 ++++++++++++++++------- src/gui/qgsproxystyle.h | 2 ++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/app/qgisappstylesheet.cpp b/src/app/qgisappstylesheet.cpp index c4dde545df4e..c824378e7eb6 100644 --- a/src/app/qgisappstylesheet.cpp +++ b/src/app/qgisappstylesheet.cpp @@ -16,14 +16,16 @@ * * ***************************************************************************/ +#include +#include + #include "qgisappstylesheet.h" #include "qgsapplication.h" #include "qgisapp.h" +#include "qgsproxystyle.h" #include "qgslogger.h" #include "qgssettings.h" -#include -#include QgisAppStyleSheet::QgisAppStyleSheet( QObject *parent ) : QObject( parent ) @@ -106,18 +108,24 @@ void QgisAppStyleSheet::buildStyleSheet( const QMap &opts ) if ( fontSize != defaultSize || fontFamily != defaultFamily ) ss += QStringLiteral( "* { font: %1pt \"%2\"} " ).arg( fontSize, fontFamily ); +#if QT_VERSION < QT_VERSION_CHECK(5, 12, 2) // Fix for macOS Qt 5.9+, where close boxes do not show on document mode tab bar tabs - // See: https://bugreports.qt.io/browse/QTBUG-61092 - // https://bugreports.qt.io/browse/QTBUG-61742 + // See: https://bugreports.qt.io/browse/QTBUG-61092 => fixed in 5.12.2 / 5.14 + // https://bugreports.qt.io/browse/QTBUG-61742 => fixed in 5.9.2 // Setting any stylesheet makes the default close button disappear. // Specifically setting a custom close button temporarily works around issue. - // TODO: Remove when regression is fixed (Qt 5.9.3 or 5.10?); though hard to tell, - // since we are overriding the default close button image now. if ( mMacStyle ) { ss += QLatin1String( "QTabBar::close-button{ image: url(:/images/themes/default/mIconCloseTab.svg); }" ); ss += QLatin1String( "QTabBar::close-button:hover{ image: url(:/images/themes/default/mIconCloseTabHover.svg); }" ); } +#endif + if ( mMacStyle ) + { + ss += QLatin1String( "QWidget#QgsTextFormatWidgetBase QTabWidget#mOptionsTab QTabBar::tab," ); + ss += QLatin1String( "QWidget#QgsRendererMeshPropsWidgetBase QTabWidget#mStyleOptionsTab" ); + ss += QLatin1String( "QTabBar::tab { width: 1.2em; }" ); + } ss += QLatin1String( "QGroupBox{ font-weight: 600; }" ); @@ -191,7 +199,8 @@ void QgisAppStyleSheet::saveToSettings( const QMap &opts ) void QgisAppStyleSheet::setActiveValues() { - mStyle = qApp->style()->objectName(); // active style name (lowercase) + QgsAppStyle *style = dynamic_cast( qApp->style() ); + mStyle = style ? style->baseStyle() : qApp->style()->objectName(); // active style name (lowercase) QgsDebugMsgLevel( QStringLiteral( "Style name: %1" ).arg( mStyle ), 2 ); mMacStyle = mStyle.contains( QLatin1String( "macintosh" ) ); // macintosh (aqua) diff --git a/src/gui/qgsproxystyle.h b/src/gui/qgsproxystyle.h index cc7c58435f70..15cd3445e331 100644 --- a/src/gui/qgsproxystyle.h +++ b/src/gui/qgsproxystyle.h @@ -57,6 +57,8 @@ class GUI_EXPORT QgsAppStyle : public QProxyStyle explicit QgsAppStyle( const QString &base ); QPixmap generatedIconPixmap( QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt ) const override; + QString baseStyle() const {return mBaseStyle;} + /** * Returns a new QgsAppStyle instance, with the same base style as this instance. *