Skip to content

Commit

Permalink
[needs-docs][ux] Remove custom group box styling and option for QGIS …
Browse files Browse the repository at this point in the history
…styled group boxes

This setting is causing issues on newer operating systems, e.g. MacOS
on dark themes. It's a 6 year old workaround for styling issues
which have likely since been fixed in Qt and the DEs themselves.

(cherry picked from commit 8f06b5a)
  • Loading branch information
nyalldawson committed Dec 15, 2018
1 parent 06c5bee commit c8a7e4d
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 81 deletions.
40 changes: 1 addition & 39 deletions src/app/qgisappstylesheet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ QMap<QString, QVariant> QgisAppStyleSheet::defaultOptions()
QgsDebugMsg( QStringLiteral( "fontFamily: %1" ).arg( fontFamily ) );
opts.insert( QStringLiteral( "fontFamily" ), QVariant( fontFamily ) );

bool gbxCustom = ( mMacStyle );
opts.insert( QStringLiteral( "groupBoxCustom" ), settings.value( QStringLiteral( "groupBoxCustom" ), QVariant( gbxCustom ) ) );

opts.insert( QStringLiteral( "toolbarSpacing" ), settings.value( QStringLiteral( "toolbarSpacing" ), QString() ) );

settings.endGroup(); // "qgis/stylesheet"
Expand Down Expand Up @@ -123,42 +120,7 @@ void QgisAppStyleSheet::buildStyleSheet( const QMap<QString, QVariant> &opts )
}
#endif

// QGroupBox and QgsCollapsibleGroupBox, mostly for Ubuntu and Mac
bool gbxCustom = opts.value( QStringLiteral( "groupBoxCustom" ) ).toBool();
QgsDebugMsg( QStringLiteral( "groupBoxCustom: %1" ).arg( gbxCustom ) );

ss += QLatin1String( "QGroupBox{" );
// doesn't work for QGroupBox::title
ss += QStringLiteral( "color: rgb(%1,%1,%1);" ).arg( mMacStyle ? 25 : 60 );
ss += QLatin1String( "font-weight: bold;" );

if ( gbxCustom )
{
ss += QStringLiteral( "background-color: rgba(0,0,0,%1%);" )
.arg( mWinOS && mStyle.startsWith( QLatin1String( "windows" ) ) ? 0 : 3 );
ss += QLatin1String( "border: 1px solid rgba(0,0,0,20%);" );
ss += QLatin1String( "border-radius: 5px;" );
ss += QLatin1String( "margin-top: 2.5ex;" );
ss += QStringLiteral( "margin-bottom: %1ex;" ).arg( mMacStyle ? 1.5 : 1 );
}
ss += QLatin1String( "} " );
if ( gbxCustom )
{
ss += QLatin1String( "QGroupBox:flat{" );
ss += QLatin1String( "background-color: rgba(0,0,0,0);" );
ss += QLatin1String( "border: rgba(0,0,0,0);" );
ss += QLatin1String( "} " );

ss += QLatin1String( "QGroupBox::title{" );
ss += QLatin1String( "subcontrol-origin: margin;" );
ss += QLatin1String( "subcontrol-position: top left;" );
ss += QLatin1String( "margin-left: 6px;" );
if ( !( mWinOS && mStyle.startsWith( QLatin1String( "windows" ) ) ) && !mOxyStyle )
{
ss += QLatin1String( "background-color: rgba(0,0,0,0);" );
}
ss += QLatin1String( "} " );
}
ss += QLatin1String( "QGroupBox{ font-weight: 600; }" );

//sidebar style
QString style = "QListWidget#mOptionsListWidget {"
Expand Down
10 changes: 0 additions & 10 deletions src/app/qgsoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,10 +557,6 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
mFontFamilyRadioCustom->blockSignals( false );
mFontFamilyComboBox->blockSignals( false );

// custom group boxes
mCustomGroupBoxChkBx->setChecked( mStyleSheetOldOpts.value( QStringLiteral( "groupBoxCustom" ) ).toBool() );
connect( mCustomGroupBoxChkBx, &QAbstractButton::clicked, this, &QgsOptions::useCustomGroupBox );

mMessageTimeoutSpnBx->setValue( mSettings->value( QStringLiteral( "/qgis/messageTimeout" ), 5 ).toInt() );

QString name = mSettings->value( QStringLiteral( "/qgis/style" ) ).toString();
Expand Down Expand Up @@ -1780,12 +1776,6 @@ void QgsOptions::mFontFamilyComboBox_currentFontChanged( const QFont &font )
}
}

void QgsOptions::useCustomGroupBox( bool chkd )
{
mStyleSheetNewOpts.insert( QStringLiteral( "groupBoxCustom" ), QVariant( chkd ) );
mStyleSheetBuilder->buildStyleSheet( mStyleSheetNewOpts );
}

void QgsOptions::leProjectGlobalCrs_crsChanged( const QgsCoordinateReferenceSystem &crs )
{
mDefaultCrs = crs;
Expand Down
3 changes: 0 additions & 3 deletions src/app/qgsoptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ class APP_EXPORT QgsOptions : public QgsOptionsDialogBase, private Ui::QgsOption
//! Slot to select custom font family choice for app
void mFontFamilyComboBox_currentFontChanged( const QFont &font );

//! Slot to set whether to use custom group boxes
void useCustomGroupBox( bool chkd );

void mProxyTypeComboBox_currentIndexChanged( int idx );

//! Add a new URL to exclude from Proxy
Expand Down
10 changes: 4 additions & 6 deletions src/gui/qgscollapsiblegroupbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,6 @@ void QgsCollapsibleGroupBoxBasic::updateStyle()
setUpdatesEnabled( false );

QgsSettings settings;
// NOTE: QGIS-Style groupbox styled in app stylesheet
bool usingQgsStyle = settings.value( QStringLiteral( "qgis/stylesheet/groupBoxCustom" ), QVariant( false ) ).toBool();

QStyleOptionGroupBox box;
initStyleOption( &box );
Expand All @@ -317,8 +315,8 @@ void QgsCollapsibleGroupBoxBasic::updateStyle()
int marginLeft = 20; // title margin for disclosure triangle
int marginRight = 5; // a little bit of space on the right, to match space on the left
int offsetLeft = 0; // offset for oxygen theme
int offsetStyle = QApplication::style()->objectName().contains( QLatin1String( "macintosh" ) ) ? ( usingQgsStyle ? 1 : 8 ) : 0;
int topBuffer = ( usingQgsStyle ? 3 : 1 ) + offsetStyle; // space between top of title or triangle and widget above
int offsetStyle = QApplication::style()->objectName().contains( QLatin1String( "macintosh" ) ) ? 8 : 0;
int topBuffer = 1 + offsetStyle; // space between top of title or triangle and widget above
int offsetTop = topBuffer;
int offsetTopTri = topBuffer; // offset for triangle

Expand Down Expand Up @@ -366,10 +364,10 @@ void QgsCollapsibleGroupBoxBasic::updateStyle()

// customize style sheet for collapse/expand button and force left-aligned title
QString ss;
if ( usingQgsStyle || QApplication::style()->objectName().contains( QLatin1String( "macintosh" ) ) )
if ( QApplication::style()->objectName().contains( QLatin1String( "macintosh" ) ) )
{
ss += QLatin1String( "QgsCollapsibleGroupBoxBasic, QgsCollapsibleGroupBox {" );
ss += QStringLiteral( " margin-top: %1px;" ).arg( topBuffer + ( usingQgsStyle ? rectTitle.height() + 5 : rectFrame.top() ) );
ss += QStringLiteral( " margin-top: %1px;" ).arg( topBuffer + rectFrame.top() );
ss += '}';
}
ss += QLatin1String( "QgsCollapsibleGroupBoxBasic::title, QgsCollapsibleGroupBox::title {" );
Expand Down
54 changes: 31 additions & 23 deletions src/ui/qgsoptionsbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@
<item>
<widget class="QStackedWidget" name="mOptionsStackedWidget">
<property name="currentIndex">
<number>16</number>
<number>0</number>
</property>
<widget class="QWidget" name="mOptionsPageGeneral">
<layout class="QVBoxLayout" name="verticalLayout_3">
Expand Down Expand Up @@ -695,20 +695,6 @@
<number>0</number>
</property>
<item row="2" column="0">
<widget class="QCheckBox" name="cbxCheckVersion">
<property name="text">
<string>Check QGIS version at startup</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="mNativeColorDialogsChkBx">
<property name="text">
<string>Use native color chooser dialogs</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="mDataSourceManagerNonModal">
<property name="toolTip">
<string>A modeless dialog allows you to interact with QGIS main window and dialogs.</string>
Expand All @@ -718,13 +704,6 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="mCustomGroupBoxChkBx">
<property name="text">
<string>QGIS-styled group boxes</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="cbxHideSplash">
<property name="sizePolicy">
Expand All @@ -738,6 +717,33 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="cbxCheckVersion">
<property name="text">
<string>Check QGIS version at startup</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="mNativeColorDialogsChkBx">
<property name="text">
<string>Use native color chooser dialogs</string>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
Expand Down Expand Up @@ -5575,7 +5581,6 @@ p, li { white-space: pre-wrap; }
<tabstop>cbxHideSplash</tabstop>
<tabstop>mNativeColorDialogsChkBx</tabstop>
<tabstop>mDataSourceManagerNonModal</tabstop>
<tabstop>mCustomGroupBoxChkBx</tabstop>
<tabstop>cbxCheckVersion</tabstop>
<tabstop>mProjectOnLaunchCmbBx</tabstop>
<tabstop>mProjectOnLaunchLineEdit</tabstop>
Expand Down Expand Up @@ -5761,6 +5766,9 @@ p, li { white-space: pre-wrap; }
<tabstop>mRemoveUrlPushButton</tabstop>
<tabstop>mExcludeUrlListWidget</tabstop>
<tabstop>mAdvancedSettingsEnableButton</tabstop>
<tabstop>mGPUEnableCheckBox</tabstop>
<tabstop>mOpenClDevicesCombo</tabstop>
<tabstop>mGPUInfoTextBrowser</tabstop>
</tabstops>
<resources>
<include location="../../images/images.qrc"/>
Expand Down

0 comments on commit c8a7e4d

Please sign in to comment.