Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix style name + fix tab width on mac
  • Loading branch information
3nids committed Mar 23, 2020
1 parent 4679777 commit 66deb4b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/app/qgisappstylesheet.cpp
Expand Up @@ -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 )
Expand Down Expand Up @@ -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; }" );

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/gui/qgsproxystyle.h
Expand Up @@ -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.
*
Expand Down

0 comments on commit 66deb4b

Please sign in to comment.