[QGIS Commit] r15136 - in trunk/qgis/src: app ui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Feb 7 23:05:06 EST 2011


Author: gsherman
Date: 2011-02-07 20:05:06 -0800 (Mon, 07 Feb 2011)
New Revision: 15136

Modified:
   trunk/qgis/src/app/qgisapp.cpp
   trunk/qgis/src/app/qgisapp.h
   trunk/qgis/src/app/qgsoptions.cpp
   trunk/qgis/src/app/qgsoptions.h
   trunk/qgis/src/ui/qgsoptionsbase.ui
Log:
Option for user to set icon size to 16, 24, or 32 px.
Contributed by madmanwoo (NathanW)

Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp	2011-02-08 00:09:24 UTC (rev 15135)
+++ trunk/qgis/src/app/qgisapp.cpp	2011-02-08 04:05:06 UTC (rev 15136)
@@ -418,6 +418,7 @@
   mUndoWidget = new QgsUndoWidget( NULL, mMapCanvas );
   mUndoWidget->setObjectName( "Undo" );
 
+  //Set the icon size for all the toolbars.
   createActions();
   createActionGroups();
   createMenus();
@@ -1659,7 +1660,9 @@
 
 void QgisApp::createToolBars()
 {
-  QSize myIconSize( 24, 24 );
+  QSettings settings;
+  int size = settings.value( "/IconSize", 24 ).toInt();
+  setIconSize(QSize(size,size));
   // QSize myIconSize ( 32,32 ); //large icons
   // Note: we need to set each object name to ensure that
   // qmainwindow::saveState and qmainwindow::restoreState
@@ -1668,7 +1671,6 @@
   //
   // File Toolbar
   mFileToolBar = addToolBar( tr( "File" ) );
-  mFileToolBar->setIconSize( myIconSize );
   mFileToolBar->setObjectName( "FileToolBar" );
   mFileToolBar->addAction( mActionNewProject );
   mFileToolBar->addAction( mActionOpenProject );
@@ -1680,7 +1682,6 @@
   //
   // Layer Toolbar
   mLayerToolBar = addToolBar( tr( "Manage Layers" ) );
-  mLayerToolBar->setIconSize( myIconSize );
   mLayerToolBar->setObjectName( "LayerToolBar" );
   mLayerToolBar->addAction( mActionAddOgrLayer );
   mLayerToolBar->addAction( mActionAddRasterLayer );
@@ -1701,7 +1702,6 @@
   //
   // Digitizing Toolbar
   mDigitizeToolBar = addToolBar( tr( "Digitizing" ) );
-  mDigitizeToolBar->setIconSize( myIconSize );
   mDigitizeToolBar->setObjectName( "Digitizing" );
   mDigitizeToolBar->addAction( mActionToggleEditing );
   mDigitizeToolBar->addAction( mActionSaveEdits );
@@ -1722,7 +1722,6 @@
   mToolbarMenu->addAction( mDigitizeToolBar->toggleViewAction() );
 
   mAdvancedDigitizeToolBar = addToolBar( tr( "Advanced Digitizing" ) );
-  mAdvancedDigitizeToolBar->setIconSize( myIconSize );
   mAdvancedDigitizeToolBar->setObjectName( "Advanced Digitizing" );
   mAdvancedDigitizeToolBar->addAction( mActionUndo );
   mAdvancedDigitizeToolBar->addAction( mActionRedo );
@@ -1742,7 +1741,6 @@
   //
   // Map Navigation Toolbar
   mMapNavToolBar = addToolBar( tr( "Map Navigation" ) );
-  mMapNavToolBar->setIconSize( myIconSize );
   mMapNavToolBar->setObjectName( "Map Navigation" );
   mMapNavToolBar->addAction( mActionPan );
   mMapNavToolBar->addAction( mActionZoomIn );
@@ -1758,7 +1756,6 @@
   //
   // Attributes Toolbar
   mAttributesToolBar = addToolBar( tr( "Attributes" ) );
-  mAttributesToolBar->setIconSize( myIconSize );
   mAttributesToolBar->setObjectName( "Attributes" );
   mAttributesToolBar->addAction( mActionIdentify );
 
@@ -1771,7 +1768,6 @@
   bt->addAction( mActionSelectFreehand );
   bt->addAction( mActionSelectRadius );
 
-  QSettings settings;
   switch ( settings.value( "/UI/selectTool", 0 ).toInt() )
   {
     default:
@@ -1859,13 +1855,11 @@
   //
   // Plugins Toolbar
   mPluginToolBar = addToolBar( tr( "Plugins" ) );
-  mPluginToolBar->setIconSize( myIconSize );
   mPluginToolBar->setObjectName( "Plugins" );
   mToolbarMenu->addAction( mPluginToolBar->toggleViewAction() );
   //
   // Help Toolbar
   mHelpToolBar = addToolBar( tr( "Help" ) );
-  mHelpToolBar->setIconSize( myIconSize );
   mHelpToolBar->setObjectName( "Help" );
   mHelpToolBar->addAction( mActionHelpContents );
   mHelpToolBar->addAction( QWhatsThis::createAction() );
@@ -1873,7 +1867,6 @@
 
   //Label Toolbar
   mLabelToolBar = addToolBar( tr( "Label" ) );
-  mLabelToolBar->setIconSize( myIconSize );
   mLabelToolBar->setObjectName( "Label" );
   mLabelToolBar->addAction( mActionLabeling );
   mLabelToolBar->addAction( mActionMoveLabel );
@@ -2015,7 +2008,19 @@
   statusBar()->showMessage( tr( "Ready" ) );
 }
 
+void QgisApp::setIconSizes( int size )
+{
+    //Set the icon size of for all the toolbars created in the future.
+    setIconSize(QSize(size,size));
 
+    //Change all current icon sizes.
+    QList<QToolBar *> toolbars = findChildren<QToolBar *>();
+    foreach(QToolBar * toolbar, toolbars)
+    {
+        toolbar->setIconSize(QSize(size,size));
+    }
+}
+
 void QgisApp::setTheme( QString theThemeName )
 {
   /*****************************************************************

Modified: trunk/qgis/src/app/qgisapp.h
===================================================================
--- trunk/qgis/src/app/qgisapp.h	2011-02-08 00:09:24 UTC (rev 15135)
+++ trunk/qgis/src/app/qgisapp.h	2011-02-08 04:05:06 UTC (rev 15136)
@@ -162,6 +162,9 @@
 
     //! Set theme (icons)
     void setTheme( QString themeName = "default" );
+
+    void setIconSizes( int size );
+
     //! Setup the toolbar popup menus for a given theme
     void setupToolbarPopups( QString themeName );
     //! Returns a pointer to the internal clipboard

Modified: trunk/qgis/src/app/qgsoptions.cpp
===================================================================
--- trunk/qgis/src/app/qgsoptions.cpp	2011-02-08 00:09:24 UTC (rev 15135)
+++ trunk/qgis/src/app/qgsoptions.cpp	2011-02-08 04:05:06 UTC (rev 15136)
@@ -29,6 +29,8 @@
 #include <QSettings>
 #include <QColorDialog>
 #include <QLocale>
+#include <QToolBar>
+#include <QSize>
 
 #if QT_VERSION >= 0x40500
 #include <QNetworkDiskCache>
@@ -51,8 +53,16 @@
   connect( cmbTheme, SIGNAL( activated( const QString& ) ), this, SLOT( themeChanged( const QString& ) ) );
   connect( cmbTheme, SIGNAL( highlighted( const QString& ) ), this, SLOT( themeChanged( const QString& ) ) );
   connect( cmbTheme, SIGNAL( textChanged( const QString& ) ), this, SLOT( themeChanged( const QString& ) ) );
+
+  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");
+
   cmbIdentifyMode->addItem( tr( "Current layer" ), 0 );
   cmbIdentifyMode->addItem( tr( "Top down, stop at first" ), 1 );
   cmbIdentifyMode->addItem( tr( "Top down" ), 2 );
@@ -234,7 +244,7 @@
 
   // set the theme combo
   cmbTheme->setCurrentIndex( cmbTheme->findText( settings.value( "/Themes", "default" ).toString() ) );
-
+  cmbSize->setCurrentIndex( cmbSize->findText(settings.value( "/IconSize").toString() ) );
   //set the state of the checkboxes
   chkAntiAliasing->setChecked( settings.value( "/qgis/enable_anti_aliasing", false ).toBool() );
   chkUseRenderCaching->setChecked( settings.value( "/qgis/enable_render_caching", false ).toBool() );
@@ -358,7 +368,7 @@
   chkReuseLastValues->setChecked( settings.value( "/qgis/digitizing/reuseLastValues", false ).toBool() );
   chkDisableAttributeValuesDlg->setChecked( settings.value( "/qgis/digitizing/disable_enter_attribute_values_dialog", false ).toBool() );
 
-#ifdef Q_WS_MAC //MH: disable incremental update on Mac for now to avoid problems with resizing 
+#ifdef Q_WS_MAC //MH: disable incremental update on Mac for now to avoid problems with resizing
   groupBox_5->setEnabled( false );
 #endif //Q_WS_MAC
 
@@ -451,6 +461,13 @@
   QgisApp::instance()->setTheme( newt );
 }
 
+void QgsOptions::iconSizeChanged(const QString &iconSize )
+{
+    int icon = iconSize.toInt();
+    QgisApp::instance()->setIconSizes(icon);
+
+}
+
 QString QgsOptions::theme()
 {
   // returns the current theme (as selected in the cmbTheme combo box)
@@ -558,6 +575,9 @@
   {
     settings.setValue( "/Themes", cmbTheme->currentText() );
   }
+
+  settings.setValue( "/IconSize",cmbSize->currentText() );
+
   settings.setValue( "/Map/updateThreshold", spinBoxUpdateThreshold->value() );
   //check behaviour so default projection when new layer is added with no
   //projection defined...

Modified: trunk/qgis/src/app/qgsoptions.h
===================================================================
--- trunk/qgis/src/app/qgsoptions.h	2011-02-08 00:09:24 UTC (rev 15135)
+++ trunk/qgis/src/app/qgsoptions.h	2011-02-08 04:05:06 UTC (rev 15136)
@@ -57,6 +57,7 @@
     // activates or highlights a theme name in the drop-down list
     void themeChanged( const QString & );
 
+    void iconSizeChanged(const QString &iconSize );
     /**
      * Return the desired state of newly added layers. If a layer
      * is to be drawn when added to the map, this function returns

Modified: trunk/qgis/src/ui/qgsoptionsbase.ui
===================================================================
--- trunk/qgis/src/ui/qgsoptionsbase.ui	2011-02-08 00:09:24 UTC (rev 15135)
+++ trunk/qgis/src/ui/qgsoptionsbase.ui	2011-02-08 04:05:06 UTC (rev 15136)
@@ -59,9 +59,9 @@
           <property name="geometry">
            <rect>
             <x>0</x>
-            <y>-126</y>
-            <width>744</width>
-            <height>586</height>
+            <y>0</y>
+            <width>746</width>
+            <height>640</height>
            </rect>
           </property>
           <layout class="QGridLayout" name="gridLayout_12">
@@ -212,6 +212,43 @@
                </layout>
               </item>
               <item>
+               <layout class="QHBoxLayout" name="horizontalLayout_7">
+                <item>
+                 <widget class="QLabel" name="textLabel1_5">
+                  <property name="sizePolicy">
+                   <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+                    <horstretch>0</horstretch>
+                    <verstretch>0</verstretch>
+                   </sizepolicy>
+                  </property>
+                  <property name="text">
+                   <string>Icon size</string>
+                  </property>
+                 </widget>
+                </item>
+                <item>
+                 <spacer name="horizontalSpacer_5">
+                  <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="cmbSize">
+                  <property name="duplicatesEnabled">
+                   <bool>false</bool>
+                  </property>
+                 </widget>
+                </item>
+               </layout>
+              </item>
+              <item>
                <widget class="QCheckBox" name="capitaliseCheckBox">
                 <property name="text">
                  <string>Capitalise layer names in legend</string>
@@ -371,8 +408,8 @@
            <rect>
             <x>0</x>
             <y>0</y>
-            <width>744</width>
-            <height>466</height>
+            <width>746</width>
+            <height>479</height>
            </rect>
           </property>
           <layout class="QGridLayout" name="gridLayout_8">
@@ -542,8 +579,8 @@
            <rect>
             <x>0</x>
             <y>0</y>
-            <width>744</width>
-            <height>469</height>
+            <width>746</width>
+            <height>500</height>
            </rect>
           </property>
           <layout class="QGridLayout" name="gridLayout_4">
@@ -822,8 +859,8 @@
            <rect>
             <x>0</x>
             <y>0</y>
-            <width>760</width>
-            <height>460</height>
+            <width>762</width>
+            <height>458</height>
            </rect>
           </property>
           <layout class="QGridLayout" name="gridLayout_10">
@@ -897,8 +934,8 @@
            <rect>
             <x>0</x>
             <y>0</y>
-            <width>838</width>
-            <height>444</height>
+            <width>746</width>
+            <height>462</height>
            </rect>
           </property>
           <layout class="QGridLayout" name="gridLayout_13">
@@ -1227,8 +1264,8 @@
            <rect>
             <x>0</x>
             <y>0</y>
-            <width>416</width>
-            <height>568</height>
+            <width>746</width>
+            <height>531</height>
            </rect>
           </property>
           <layout class="QGridLayout" name="gridLayout_15">
@@ -1323,8 +1360,8 @@
            <rect>
             <x>0</x>
             <y>0</y>
-            <width>519</width>
-            <height>567</height>
+            <width>746</width>
+            <height>552</height>
            </rect>
           </property>
           <layout class="QGridLayout" name="gridLayout_17">
@@ -1414,8 +1451,8 @@
            <rect>
             <x>0</x>
             <y>0</y>
-            <width>407</width>
-            <height>508</height>
+            <width>746</width>
+            <height>548</height>
            </rect>
           </property>
           <layout class="QGridLayout" name="gridLayout_20">



More information about the QGIS-commit mailing list