From a02c8ee13598f143d717bdea500ff5dc10bdb555 Mon Sep 17 00:00:00 2001 From: Nathan Woodrow Date: Sun, 13 Nov 2011 17:36:53 +1000 Subject: [PATCH 1/3] Allow user to select Qt app style --- src/app/main.cpp | 14 ++-- src/app/qgsoptions.cpp | 11 +++ src/ui/qgsoptionsbase.ui | 150 +++++++++++++++++++++++---------------- 3 files changed, 110 insertions(+), 65 deletions(-) diff --git a/src/app/main.cpp b/src/app/main.cpp index f4efef2614d6..01e5f47bb500 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -474,13 +474,17 @@ int main( int argc, char *argv[] ) } #endif -#ifdef Q_WS_WIN - //for windows lets use plastique style! - QApplication::setStyle( new QPlastiqueStyle ); -#endif - QSettings mySettings; + // Set the application style. If it's not set QT will use the platform style except on Windows + // as it looks really ugly so we use QPlastiqueStyle. + QString style = mySettings.value("/qgis/style","").toString(); + if ( !style.isNull() ) + QApplication::setStyle( style ); +#ifdef Q_WS_WIN + else + QApplication::setStyle( new QPlastiqueStyle ); +#endif /* Translation file for QGIS. */ diff --git a/src/app/qgsoptions.cpp b/src/app/qgsoptions.cpp index a7ace0a77a02..02f00ca4cfb7 100644 --- a/src/app/qgsoptions.cpp +++ b/src/app/qgsoptions.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #if QT_VERSION >= 0x40500 #include @@ -58,12 +59,19 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) : connect( cmbSize, SIGNAL( activated( const QString& ) ), this, SLOT( iconSizeChanged( const QString& ) ) ); connect( cmbSize, SIGNAL( highlighted( const QString& ) ), this, SLOT( iconSizeChanged( const QString& ) ) ); connect( cmbSize, SIGNAL( textChanged( const QString& ) ), this, SLOT( iconSizeChanged( const QString& ) ) ); + connect( this, SIGNAL( accepted() ), this, SLOT( saveOptions() ) ); cmbSize->addItem( "16" ); cmbSize->addItem( "24" ); cmbSize->addItem( "32" ); + QStringList styles = QStyleFactory::keys(); + foreach(QString style, styles ) + { + cmbStyle->addItem( style ); + } + cmbIdentifyMode->addItem( tr( "Current layer" ), 0 ); cmbIdentifyMode->addItem( tr( "Top down, stop at first" ), 1 ); cmbIdentifyMode->addItem( tr( "Top down" ), 2 ); @@ -270,6 +278,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) : // set the theme combo cmbTheme->setCurrentIndex( cmbTheme->findText( settings.value( "/Themes", "default" ).toString() ) ); cmbSize->setCurrentIndex( cmbSize->findText( settings.value( "/IconSize", 24 ).toString() ) ); + QString name = QApplication::style()->objectName(); + cmbStyle->setCurrentIndex( cmbStyle->findText( name, Qt::MatchFixedString ) ); //set the state of the checkboxes //Changed to default to true as of QGIS 1.7 chkAntiAliasing->setChecked( settings.value( "/qgis/enable_anti_aliasing", true ).toBool() ); @@ -589,6 +599,7 @@ void QgsOptions::saveOptions() settings.setValue( "/qgis/askToSaveProjectChanges", chbAskToSaveProjectChanges->isChecked() ); settings.setValue( "/qgis/warnOldProjectVersion", chbWarnOldProjectVersion->isChecked() ); settings.setValue( "/qgis/nullValue", leNullValue->text() ); + settings.setValue( "/qgis/style", cmbStyle->currentText() ); //overlay placement method int overlayIndex = mOverlayAlgorithmComboBox->currentIndex(); diff --git a/src/ui/qgsoptionsbase.ui b/src/ui/qgsoptionsbase.ui index bc89caa5aaa6..1dc9bcc42b01 100644 --- a/src/ui/qgsoptionsbase.ui +++ b/src/ui/qgsoptionsbase.ui @@ -66,8 +66,8 @@ 0 0 - 979 - 1135 + 851 + 1068 @@ -127,19 +127,6 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - @@ -153,7 +140,20 @@ - + + + + Qt::Horizontal + + + + 40 + 20 + + + + + Qt::Horizontal @@ -176,22 +176,22 @@ - + + + 0 + - - - - 0 - 0 - - + - Icon theme + Style - + + + + Qt::Horizontal @@ -203,6 +203,23 @@ + + + + + + + + + 0 + 0 + + + + Icon theme + + + @@ -215,6 +232,19 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -232,6 +262,13 @@ + + + + false + + + @@ -245,13 +282,6 @@ - - - - false - - - @@ -263,19 +293,6 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - @@ -290,6 +307,19 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -537,8 +567,8 @@ 0 0 - 641 - 512 + 786 + 473 @@ -711,8 +741,8 @@ 0 0 - 567 - 532 + 786 + 473 @@ -997,8 +1027,8 @@ 0 0 - 289 - 94 + 803 + 414 @@ -1072,8 +1102,8 @@ 0 0 - 797 - 490 + 766 + 432 @@ -1408,8 +1438,8 @@ 0 0 - 446 - 420 + 803 + 414 @@ -1582,8 +1612,8 @@ 0 0 - 519 - 583 + 786 + 542 @@ -1679,8 +1709,8 @@ 0 0 - 384 - 573 + 786 + 533 From 87418c2f7b3ba0ae8589a2fc75194e19fba46f67 Mon Sep 17 00:00:00 2001 From: Nathan Woodrow Date: Sun, 13 Nov 2011 17:59:38 +1000 Subject: [PATCH 2/3] Add note about restart required --- src/ui/qgsoptionsbase.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/qgsoptionsbase.ui b/src/ui/qgsoptionsbase.ui index 1dc9bcc42b01..4476bb2d712c 100644 --- a/src/ui/qgsoptionsbase.ui +++ b/src/ui/qgsoptionsbase.ui @@ -65,7 +65,7 @@ 0 - 0 + -147 851 1068 @@ -183,7 +183,7 @@ - Style + Style <i>(QGIS restart required)</i> From aabfdf9d88ca27d9831ca5fc959464e9ff9512cd Mon Sep 17 00:00:00 2001 From: Nathan Woodrow Date: Thu, 17 Nov 2011 23:11:18 +1000 Subject: [PATCH 3/3] Use null string vs empty --- src/app/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/main.cpp b/src/app/main.cpp index 01e5f47bb500..65c06e5e2169 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -478,7 +478,7 @@ int main( int argc, char *argv[] ) // Set the application style. If it's not set QT will use the platform style except on Windows // as it looks really ugly so we use QPlastiqueStyle. - QString style = mySettings.value("/qgis/style","").toString(); + QString style = mySettings.value("/qgis/style").toString(); if ( !style.isNull() ) QApplication::setStyle( style ); #ifdef Q_WS_WIN