Skip to content

Commit 740024c

Browse files
committed
Update to new style side bar style for dialogs.
- New blue-grey with white text style dialog - Side panel runs top to bottom - Icon size is read from settings - Option to disable in options dialog
1 parent 305a42a commit 740024c

11 files changed

+878
-500
lines changed

src/app/qgisappstylesheet.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ QMap<QString, QVariant> QgisAppStyleSheet::defaultOptions()
9292
bool gbxBoldTitle = false;
9393
opts.insert( "groupBoxBoldTitle", settings.value( "groupBoxBoldTitle", QVariant( gbxBoldTitle ) ) );
9494

95+
opts.insert( "sidebarStyle", settings.value( "sidebarStyle", true ) );
96+
9597
settings.endGroup(); // "qgis/stylesheet"
9698

9799
return opts;
@@ -118,6 +120,7 @@ void QgisAppStyleSheet::buildStyleSheet( const QMap<QString, QVariant>& opts )
118120
QgsDebugMsg( QString( "groupBoxCustom: %1" ).arg( gbxCustom ) );
119121
bool gbxBoldTitle = opts.value( "groupBoxBoldTitle" ).toBool();
120122
QgsDebugMsg( QString( "groupBoxBoldTitle: %1" ).arg( gbxBoldTitle ) );
123+
bool sidebar = opts.value( "sidebarStyle" ).toBool();
121124
if ( gbxCustom || gbxBoldTitle )
122125
{
123126
ss += "QGroupBox{";
@@ -156,6 +159,23 @@ void QgisAppStyleSheet::buildStyleSheet( const QMap<QString, QVariant>& opts )
156159
}
157160
}
158161

162+
if ( sidebar )
163+
{
164+
QString style = "QListWidget#mOptionsListWidget {"
165+
"background-color: rgb(162, 170, 179);"
166+
"}"
167+
"QListWidget#mOptionsListWidget::item {"
168+
" color: white;"
169+
" padding: 3px;"
170+
"}"
171+
"QListWidget#mOptionsListWidget::item::selected {"
172+
" color: black;"
173+
" background-color:palette(Window);"
174+
" padding-right: 0px; "
175+
"}";
176+
ss += style;
177+
}
178+
159179
//fix background issue for gnome desktop
160180
if ( mLinuxOS && mGtkStyle )
161181
{

src/app/qgsabout.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ std::map<QString, QPixmap> mugs;
3131
*/
3232
#ifdef Q_OS_MACX
3333
QgsAbout::QgsAbout( QWidget *parent )
34-
: QDialog( parent, Qt::WindowSystemMenuHint ) // Modeless dialog with close button only
34+
: QgsOptionsDialogBase( parent, Qt::WindowSystemMenuHint ) // Modeless dialog with close button only
3535
#else
3636
QgsAbout::QgsAbout( QWidget *parent )
37-
: QDialog( parent ) // Normal dialog in non Mac-OS
37+
: QgsOptionsDialogBase( "about", parent ) // Normal dialog in non Mac-OS
3838
#endif
3939
{
4040
setupUi( this );
41+
initOptionsBase();
4142
init();
4243
}
4344

src/app/qgsabout.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
#define QGSABOUT_H
1919

2020
#include "ui_qgsabout.h"
21+
#include "qgsoptionsdialogbase.h"
2122

22-
class APP_EXPORT QgsAbout : public QDialog, private Ui::QgsAbout
23+
class APP_EXPORT QgsAbout : public QgsOptionsDialogBase , private Ui::QgsAbout
2324
{
2425
Q_OBJECT
2526
public:

src/app/qgsoptions.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
546546

547547
// custom group boxes
548548
mCustomGroupBoxChkBx->setChecked( mStyleSheetOldOpts.value( "groupBoxCustom" ).toBool() );
549+
mCustomSideBarSide->setChecked( mStyleSheetOldOpts.value( "sidebarStyle" ).toBool() );
549550
mBoldGroupBoxTitleChkBx->setChecked( mStyleSheetOldOpts.value( "groupBoxBoldTitle" ).toBool() );
550551

551552
mMessageTimeoutSpnBx->setValue( settings.value( "/qgis/messageTimeout", 5 ).toInt() );
@@ -1412,6 +1413,12 @@ void QgsOptions::on_mCustomGroupBoxChkBx_clicked( bool chkd )
14121413
mStyleSheetBuilder->buildStyleSheet( mStyleSheetNewOpts );
14131414
}
14141415

1416+
void QgsOptions::on_mCustomSideBarSide_clicked( bool chkd )
1417+
{
1418+
mStyleSheetNewOpts.insert( "sidebarStyle", chkd );
1419+
mStyleSheetBuilder->buildStyleSheet( mStyleSheetNewOpts );
1420+
}
1421+
14151422
void QgsOptions::on_mBoldGroupBoxTitleChkBx_clicked( bool chkd )
14161423
{
14171424
mStyleSheetNewOpts.insert( "groupBoxBoldTitle", QVariant( chkd ) );

src/app/qgsoptions.h

+5
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ class APP_EXPORT QgsOptions : public QgsOptionsDialogBase, private Ui::QgsOption
129129
*/
130130
void on_mCustomGroupBoxChkBx_clicked( bool chkd );
131131

132+
/** Slot to set whether to use custom side bar style
133+
* @note added in QGIS 2.2
134+
*/
135+
void on_mCustomSideBarSide_clicked( bool chkd );
136+
132137
/** Slot to set whether to bold group box titles
133138
* @note added in QGIS 1.9
134139
*/

src/gui/qgsoptionsdialogbase.cpp

+23-2
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,40 @@ void QgsOptionsDialogBase::initOptionsBase( bool restoreUi )
4949
// don't add to dialog margins
5050
// redefine now, or those in inherited .ui file will be added
5151
if ( layout() )
52-
layout()->setContentsMargins( 12, 12, 12, 12 ); // Qt default spacing
52+
{
53+
layout()->setContentsMargins( 0, 0, 0, 0 ); // Qt default spacing
54+
}
5355

5456
// start with copy of qgsoptionsdialog_template.ui to ensure existence of these objects
5557
mOptListWidget = findChild<QListWidget*>( "mOptionsListWidget" );
58+
QFrame* optionsFrame = findChild<QFrame*>("mOptionsFrame");
5659
mOptStackedWidget = findChild<QStackedWidget*>( "mOptionsStackedWidget" );
5760
mOptSplitter = findChild<QSplitter*>( "mOptionsSplitter" );
5861
mOptButtonBox = findChild<QDialogButtonBox*>( "buttonBox" );
62+
QFrame* buttonBoxFrame = findChild<QFrame*>("mButtonBoxFrame");
5963

60-
if ( !mOptListWidget || !mOptStackedWidget || !mOptSplitter )
64+
if ( !mOptListWidget || !mOptStackedWidget || !mOptSplitter || !optionsFrame )
6165
{
6266
return;
6367
}
6468

69+
QSettings settings;
70+
int size = settings.value( "/IconSize", 24 ).toInt();
71+
mOptListWidget->setIconSize( QSize(size, size) );
72+
73+
optionsFrame->layout()->setContentsMargins(0,3,3,3);
74+
QVBoxLayout* layout = static_cast<QVBoxLayout*>(optionsFrame->layout());
75+
76+
if ( buttonBoxFrame )
77+
{
78+
buttonBoxFrame->layout()->setContentsMargins(0,0,0,0);
79+
layout->insertWidget(layout->count() + 1, buttonBoxFrame );
80+
}
81+
else
82+
{
83+
layout->insertWidget( layout->count() + 1, mOptButtonBox );
84+
}
85+
6586
if ( mOptButtonBox )
6687
{
6788
// enforce only one connection per signal, in case added in Qt Designer

0 commit comments

Comments
 (0)