Skip to content

Commit

Permalink
Merge pull request #59 from NathanW2/window_theme
Browse files Browse the repository at this point in the history
[FEATURE] Allow the user to select the Qt windows style they want
  • Loading branch information
timlinux committed Nov 22, 2011
2 parents 1b3c383 + a0dad9c commit ae0771e
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 49 deletions.
14 changes: 9 additions & 5 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
11 changes: 11 additions & 0 deletions src/app/qgsoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <QLocale>
#include <QToolBar>
#include <QSize>
#include <QStyleFactory>

#if QT_VERSION >= 0x40500
#include <QNetworkDiskCache>
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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() );
Expand Down Expand Up @@ -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();
Expand Down
118 changes: 74 additions & 44 deletions src/ui/qgsoptionsbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,6 @@
</property>
</widget>
</item>
<item row="1" column="2">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="3">
<widget class="QgsColorButton" name="pbnCanvasColor">
<property name="minimumSize">
Expand All @@ -153,7 +140,20 @@
</property>
</widget>
</item>
<item row="0" column="2">
<item row="0" column="4">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="4">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
Expand All @@ -176,22 +176,22 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<layout class="QHBoxLayout" name="horizontalLayout_9">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="textLabel1_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<widget class="QLabel" name="label_18">
<property name="text">
<string>Icon theme</string>
<string>Style &lt;i&gt;(QGIS restart required)&lt;/i&gt;</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<widget class="QComboBox" name="cmbStyle"/>
</item>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
Expand All @@ -203,6 +203,23 @@
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="textLabel1_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Icon theme</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cmbTheme">
<property name="duplicatesEnabled">
Expand All @@ -215,6 +232,19 @@
</item>
</widget>
</item>
<item>
<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>
<item>
Expand All @@ -232,6 +262,13 @@
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cmbSize">
<property name="duplicatesEnabled">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
Expand All @@ -245,13 +282,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="cmbSize">
<property name="duplicatesEnabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand All @@ -263,19 +293,6 @@
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="cmbLegendDoubleClickAction">
<item>
Expand All @@ -290,6 +307,19 @@
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<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>
<item>
Expand Down

0 comments on commit ae0771e

Please sign in to comment.