Skip to content

Commit a111a1c

Browse files
committed
Fix macOS Qt 5.9+ close boxes do not show on document mode tab bar tabs
Setting any stylesheet makes the default close button disappear. Setting a custom close button temporarily works around issue. See: https://bugreports.qt.io/browse/QTBUG-61092 https://bugreports.qt.io/browse/QTBUG-61742
1 parent 4f9e2a5 commit a111a1c

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

images/images.qrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,8 @@
365365
<file>themes/default/mIconColorWheel.svg</file>
366366
<file>themes/default/mIconConnect.png</file>
367367
<file>themes/default/mIconClose.svg</file>
368+
<file>themes/default/mIconCloseTab.svg</file>
369+
<file>themes/default/mIconCloseTabHover.svg</file>
368370
<file>themes/default/mIconCritical.png</file>
369371
<file>themes/default/mIconDataDefine.svg</file>
370372
<file>themes/default/mIconDataDefineError.svg</file>
Lines changed: 5 additions & 0 deletions
Loading
Lines changed: 5 additions & 0 deletions
Loading

src/app/qgisappstylesheet.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,21 @@ void QgisAppStyleSheet::buildStyleSheet( const QMap<QString, QVariant> &opts )
104104

105105
ss += QStringLiteral( "* { font: %1pt \"%2\"} " ).arg( fontSize, fontFamily );
106106

107+
#if QT_VERSION >= 0x050900
108+
// Fix for macOS Qt 5.9+, where close boxes do not show on document mode tab bar tabs
109+
// See: https://bugreports.qt.io/browse/QTBUG-61092
110+
// https://bugreports.qt.io/browse/QTBUG-61742
111+
// Setting any stylesheet makes the default close button disappear.
112+
// Specifically setting a custom close button temporarily works around issue.
113+
// TODO: Remove when regression is fixed (Qt 5.9.3 or 5.10?); though hard to tell,
114+
// since we are overriding the default close button image now.
115+
if ( mMacStyle )
116+
{
117+
ss += QLatin1String( "QTabBar::close-button{ image: url(:/images/themes/default/mIconCloseTab.svg); }" );
118+
ss += QLatin1String( "QTabBar::close-button:hover{ image: url(:/images/themes/default/mIconCloseTabHover.svg); }" );
119+
}
120+
#endif
121+
107122
// QGroupBox and QgsCollapsibleGroupBox, mostly for Ubuntu and Mac
108123
bool gbxCustom = opts.value( QStringLiteral( "groupBoxCustom" ) ).toBool();
109124
QgsDebugMsg( QString( "groupBoxCustom: %1" ).arg( gbxCustom ) );

0 commit comments

Comments
 (0)