Skip to content
Permalink
Browse files

fix style name + fix tab width on mac

  • Loading branch information
3nids committed Mar 23, 2020
1 parent 7660242 commit 44bf36760bf80b79ea4a46952cfa74e98b952ffd
Showing with 18 additions and 7 deletions.
  1. +16 −7 src/app/qgisappstylesheet.cpp
  2. +2 −0 src/gui/qgsproxystyle.h
@@ -16,14 +16,16 @@
* *
***************************************************************************/

#include <QFont>
#include <QStyle>

#include "qgisappstylesheet.h"
#include "qgsapplication.h"
#include "qgisapp.h"
#include "qgsproxystyle.h"
#include "qgslogger.h"
#include "qgssettings.h"

#include <QFont>
#include <QStyle>

QgisAppStyleSheet::QgisAppStyleSheet( QObject *parent )
: QObject( parent )
@@ -106,18 +108,24 @@ void QgisAppStyleSheet::buildStyleSheet( const QMap<QString, QVariant> &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<QString, QVariant> &opts )

void QgisAppStyleSheet::setActiveValues()
{
mStyle = qApp->style()->objectName(); // active style name (lowercase)
QgsAppStyle *style = dynamic_cast<QgsAppStyle *>( 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)
@@ -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.
*

0 comments on commit 44bf367

Please sign in to comment.
You can’t perform that action at this time.