Skip to content

Commit e106293

Browse files
author
gsherman
committedFeb 8, 2011
Option for user to set icon size to 16, 24, or 32 px.
Contributed by madmanwoo (NathanW) git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15136 c8812cc2-4d05-0410-92ff-de0c093fc19c

File tree

5 files changed

+96
-30
lines changed

5 files changed

+96
-30
lines changed
 

‎src/app/qgisapp.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
418418
mUndoWidget = new QgsUndoWidget( NULL, mMapCanvas );
419419
mUndoWidget->setObjectName( "Undo" );
420420

421+
//Set the icon size for all the toolbars.
421422
createActions();
422423
createActionGroups();
423424
createMenus();
@@ -1659,7 +1660,9 @@ void QgisApp::createMenus()
16591660

16601661
void QgisApp::createToolBars()
16611662
{
1662-
QSize myIconSize( 24, 24 );
1663+
QSettings settings;
1664+
int size = settings.value( "/IconSize", 24 ).toInt();
1665+
setIconSize(QSize(size,size));
16631666
// QSize myIconSize ( 32,32 ); //large icons
16641667
// Note: we need to set each object name to ensure that
16651668
// qmainwindow::saveState and qmainwindow::restoreState
@@ -1668,7 +1671,6 @@ void QgisApp::createToolBars()
16681671
//
16691672
// File Toolbar
16701673
mFileToolBar = addToolBar( tr( "File" ) );
1671-
mFileToolBar->setIconSize( myIconSize );
16721674
mFileToolBar->setObjectName( "FileToolBar" );
16731675
mFileToolBar->addAction( mActionNewProject );
16741676
mFileToolBar->addAction( mActionOpenProject );
@@ -1680,7 +1682,6 @@ void QgisApp::createToolBars()
16801682
//
16811683
// Layer Toolbar
16821684
mLayerToolBar = addToolBar( tr( "Manage Layers" ) );
1683-
mLayerToolBar->setIconSize( myIconSize );
16841685
mLayerToolBar->setObjectName( "LayerToolBar" );
16851686
mLayerToolBar->addAction( mActionAddOgrLayer );
16861687
mLayerToolBar->addAction( mActionAddRasterLayer );
@@ -1701,7 +1702,6 @@ void QgisApp::createToolBars()
17011702
//
17021703
// Digitizing Toolbar
17031704
mDigitizeToolBar = addToolBar( tr( "Digitizing" ) );
1704-
mDigitizeToolBar->setIconSize( myIconSize );
17051705
mDigitizeToolBar->setObjectName( "Digitizing" );
17061706
mDigitizeToolBar->addAction( mActionToggleEditing );
17071707
mDigitizeToolBar->addAction( mActionSaveEdits );
@@ -1722,7 +1722,6 @@ void QgisApp::createToolBars()
17221722
mToolbarMenu->addAction( mDigitizeToolBar->toggleViewAction() );
17231723

17241724
mAdvancedDigitizeToolBar = addToolBar( tr( "Advanced Digitizing" ) );
1725-
mAdvancedDigitizeToolBar->setIconSize( myIconSize );
17261725
mAdvancedDigitizeToolBar->setObjectName( "Advanced Digitizing" );
17271726
mAdvancedDigitizeToolBar->addAction( mActionUndo );
17281727
mAdvancedDigitizeToolBar->addAction( mActionRedo );
@@ -1742,7 +1741,6 @@ void QgisApp::createToolBars()
17421741
//
17431742
// Map Navigation Toolbar
17441743
mMapNavToolBar = addToolBar( tr( "Map Navigation" ) );
1745-
mMapNavToolBar->setIconSize( myIconSize );
17461744
mMapNavToolBar->setObjectName( "Map Navigation" );
17471745
mMapNavToolBar->addAction( mActionPan );
17481746
mMapNavToolBar->addAction( mActionZoomIn );
@@ -1758,7 +1756,6 @@ void QgisApp::createToolBars()
17581756
//
17591757
// Attributes Toolbar
17601758
mAttributesToolBar = addToolBar( tr( "Attributes" ) );
1761-
mAttributesToolBar->setIconSize( myIconSize );
17621759
mAttributesToolBar->setObjectName( "Attributes" );
17631760
mAttributesToolBar->addAction( mActionIdentify );
17641761

@@ -1771,7 +1768,6 @@ void QgisApp::createToolBars()
17711768
bt->addAction( mActionSelectFreehand );
17721769
bt->addAction( mActionSelectRadius );
17731770

1774-
QSettings settings;
17751771
switch ( settings.value( "/UI/selectTool", 0 ).toInt() )
17761772
{
17771773
default:
@@ -1859,21 +1855,18 @@ void QgisApp::createToolBars()
18591855
//
18601856
// Plugins Toolbar
18611857
mPluginToolBar = addToolBar( tr( "Plugins" ) );
1862-
mPluginToolBar->setIconSize( myIconSize );
18631858
mPluginToolBar->setObjectName( "Plugins" );
18641859
mToolbarMenu->addAction( mPluginToolBar->toggleViewAction() );
18651860
//
18661861
// Help Toolbar
18671862
mHelpToolBar = addToolBar( tr( "Help" ) );
1868-
mHelpToolBar->setIconSize( myIconSize );
18691863
mHelpToolBar->setObjectName( "Help" );
18701864
mHelpToolBar->addAction( mActionHelpContents );
18711865
mHelpToolBar->addAction( QWhatsThis::createAction() );
18721866
mToolbarMenu->addAction( mHelpToolBar->toggleViewAction() );
18731867

18741868
//Label Toolbar
18751869
mLabelToolBar = addToolBar( tr( "Label" ) );
1876-
mLabelToolBar->setIconSize( myIconSize );
18771870
mLabelToolBar->setObjectName( "Label" );
18781871
mLabelToolBar->addAction( mActionLabeling );
18791872
mLabelToolBar->addAction( mActionMoveLabel );
@@ -2015,6 +2008,18 @@ void QgisApp::createStatusBar()
20152008
statusBar()->showMessage( tr( "Ready" ) );
20162009
}
20172010

2011+
void QgisApp::setIconSizes( int size )
2012+
{
2013+
//Set the icon size of for all the toolbars created in the future.
2014+
setIconSize(QSize(size,size));
2015+
2016+
//Change all current icon sizes.
2017+
QList<QToolBar *> toolbars = findChildren<QToolBar *>();
2018+
foreach(QToolBar * toolbar, toolbars)
2019+
{
2020+
toolbar->setIconSize(QSize(size,size));
2021+
}
2022+
}
20182023

20192024
void QgisApp::setTheme( QString theThemeName )
20202025
{

‎src/app/qgisapp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ class QgisApp : public QMainWindow
162162

163163
//! Set theme (icons)
164164
void setTheme( QString themeName = "default" );
165+
166+
void setIconSizes( int size );
167+
165168
//! Setup the toolbar popup menus for a given theme
166169
void setupToolbarPopups( QString themeName );
167170
//! Returns a pointer to the internal clipboard

‎src/app/qgsoptions.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
#include <QSettings>
3030
#include <QColorDialog>
3131
#include <QLocale>
32+
#include <QToolBar>
33+
#include <QSize>
3234

3335
#if QT_VERSION >= 0x40500
3436
#include <QNetworkDiskCache>
@@ -51,8 +53,16 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
5153
connect( cmbTheme, SIGNAL( activated( const QString& ) ), this, SLOT( themeChanged( const QString& ) ) );
5254
connect( cmbTheme, SIGNAL( highlighted( const QString& ) ), this, SLOT( themeChanged( const QString& ) ) );
5355
connect( cmbTheme, SIGNAL( textChanged( const QString& ) ), this, SLOT( themeChanged( const QString& ) ) );
56+
57+
connect( cmbSize, SIGNAL( activated(const QString& ) ),this,SLOT(iconSizeChanged( const QString& ) ) );
58+
connect( cmbSize, SIGNAL( highlighted(const QString& ) ),this,SLOT(iconSizeChanged( const QString& ) ) );
59+
connect( cmbSize, SIGNAL( textChanged(const QString& ) ),this,SLOT(iconSizeChanged( const QString& ) ) );
5460
connect( this, SIGNAL( accepted() ), this, SLOT( saveOptions() ) );
5561

62+
cmbSize->addItem("16");
63+
cmbSize->addItem("24");
64+
cmbSize->addItem("32");
65+
5666
cmbIdentifyMode->addItem( tr( "Current layer" ), 0 );
5767
cmbIdentifyMode->addItem( tr( "Top down, stop at first" ), 1 );
5868
cmbIdentifyMode->addItem( tr( "Top down" ), 2 );
@@ -234,7 +244,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
234244

235245
// set the theme combo
236246
cmbTheme->setCurrentIndex( cmbTheme->findText( settings.value( "/Themes", "default" ).toString() ) );
237-
247+
cmbSize->setCurrentIndex( cmbSize->findText(settings.value( "/IconSize").toString() ) );
238248
//set the state of the checkboxes
239249
chkAntiAliasing->setChecked( settings.value( "/qgis/enable_anti_aliasing", false ).toBool() );
240250
chkUseRenderCaching->setChecked( settings.value( "/qgis/enable_render_caching", false ).toBool() );
@@ -358,7 +368,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
358368
chkReuseLastValues->setChecked( settings.value( "/qgis/digitizing/reuseLastValues", false ).toBool() );
359369
chkDisableAttributeValuesDlg->setChecked( settings.value( "/qgis/digitizing/disable_enter_attribute_values_dialog", false ).toBool() );
360370

361-
#ifdef Q_WS_MAC //MH: disable incremental update on Mac for now to avoid problems with resizing
371+
#ifdef Q_WS_MAC //MH: disable incremental update on Mac for now to avoid problems with resizing
362372
groupBox_5->setEnabled( false );
363373
#endif //Q_WS_MAC
364374

@@ -451,6 +461,13 @@ void QgsOptions::themeChanged( const QString &newThemeName )
451461
QgisApp::instance()->setTheme( newt );
452462
}
453463

464+
void QgsOptions::iconSizeChanged(const QString &iconSize )
465+
{
466+
int icon = iconSize.toInt();
467+
QgisApp::instance()->setIconSizes(icon);
468+
469+
}
470+
454471
QString QgsOptions::theme()
455472
{
456473
// returns the current theme (as selected in the cmbTheme combo box)
@@ -558,6 +575,9 @@ void QgsOptions::saveOptions()
558575
{
559576
settings.setValue( "/Themes", cmbTheme->currentText() );
560577
}
578+
579+
settings.setValue( "/IconSize",cmbSize->currentText() );
580+
561581
settings.setValue( "/Map/updateThreshold", spinBoxUpdateThreshold->value() );
562582
//check behaviour so default projection when new layer is added with no
563583
//projection defined...

‎src/app/qgsoptions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class QgsOptions : public QDialog, private Ui::QgsOptionsBase
5757
// activates or highlights a theme name in the drop-down list
5858
void themeChanged( const QString & );
5959

60+
void iconSizeChanged(const QString &iconSize );
6061
/**
6162
* Return the desired state of newly added layers. If a layer
6263
* is to be drawn when added to the map, this function returns

‎src/ui/qgsoptionsbase.ui

Lines changed: 54 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@
5959
<property name="geometry">
6060
<rect>
6161
<x>0</x>
62-
<y>-126</y>
63-
<width>744</width>
64-
<height>586</height>
62+
<y>0</y>
63+
<width>746</width>
64+
<height>640</height>
6565
</rect>
6666
</property>
6767
<layout class="QGridLayout" name="gridLayout_12">
@@ -211,6 +211,43 @@
211211
</item>
212212
</layout>
213213
</item>
214+
<item>
215+
<layout class="QHBoxLayout" name="horizontalLayout_7">
216+
<item>
217+
<widget class="QLabel" name="textLabel1_5">
218+
<property name="sizePolicy">
219+
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
220+
<horstretch>0</horstretch>
221+
<verstretch>0</verstretch>
222+
</sizepolicy>
223+
</property>
224+
<property name="text">
225+
<string>Icon size</string>
226+
</property>
227+
</widget>
228+
</item>
229+
<item>
230+
<spacer name="horizontalSpacer_5">
231+
<property name="orientation">
232+
<enum>Qt::Horizontal</enum>
233+
</property>
234+
<property name="sizeHint" stdset="0">
235+
<size>
236+
<width>40</width>
237+
<height>20</height>
238+
</size>
239+
</property>
240+
</spacer>
241+
</item>
242+
<item>
243+
<widget class="QComboBox" name="cmbSize">
244+
<property name="duplicatesEnabled">
245+
<bool>false</bool>
246+
</property>
247+
</widget>
248+
</item>
249+
</layout>
250+
</item>
214251
<item>
215252
<widget class="QCheckBox" name="capitaliseCheckBox">
216253
<property name="text">
@@ -371,8 +408,8 @@
371408
<rect>
372409
<x>0</x>
373410
<y>0</y>
374-
<width>744</width>
375-
<height>466</height>
411+
<width>746</width>
412+
<height>479</height>
376413
</rect>
377414
</property>
378415
<layout class="QGridLayout" name="gridLayout_8">
@@ -542,8 +579,8 @@
542579
<rect>
543580
<x>0</x>
544581
<y>0</y>
545-
<width>744</width>
546-
<height>469</height>
582+
<width>746</width>
583+
<height>500</height>
547584
</rect>
548585
</property>
549586
<layout class="QGridLayout" name="gridLayout_4">
@@ -822,8 +859,8 @@
822859
<rect>
823860
<x>0</x>
824861
<y>0</y>
825-
<width>760</width>
826-
<height>460</height>
862+
<width>762</width>
863+
<height>458</height>
827864
</rect>
828865
</property>
829866
<layout class="QGridLayout" name="gridLayout_10">
@@ -897,8 +934,8 @@
897934
<rect>
898935
<x>0</x>
899936
<y>0</y>
900-
<width>838</width>
901-
<height>444</height>
937+
<width>746</width>
938+
<height>462</height>
902939
</rect>
903940
</property>
904941
<layout class="QGridLayout" name="gridLayout_13">
@@ -1227,8 +1264,8 @@
12271264
<rect>
12281265
<x>0</x>
12291266
<y>0</y>
1230-
<width>416</width>
1231-
<height>568</height>
1267+
<width>746</width>
1268+
<height>531</height>
12321269
</rect>
12331270
</property>
12341271
<layout class="QGridLayout" name="gridLayout_15">
@@ -1323,8 +1360,8 @@
13231360
<rect>
13241361
<x>0</x>
13251362
<y>0</y>
1326-
<width>519</width>
1327-
<height>567</height>
1363+
<width>746</width>
1364+
<height>552</height>
13281365
</rect>
13291366
</property>
13301367
<layout class="QGridLayout" name="gridLayout_17">
@@ -1414,8 +1451,8 @@
14141451
<rect>
14151452
<x>0</x>
14161453
<y>0</y>
1417-
<width>407</width>
1418-
<height>508</height>
1454+
<width>746</width>
1455+
<height>548</height>
14191456
</rect>
14201457
</property>
14211458
<layout class="QGridLayout" name="gridLayout_20">

0 commit comments

Comments
 (0)
Please sign in to comment.