Skip to content
Permalink
Browse files

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@15136 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
gsherman
gsherman committed Feb 8, 2011
1 parent 2941838 commit 4c53217a5b102f2ab8330d4956c3100a229089de
Showing with 96 additions and 30 deletions.
  1. +16 −11 src/app/qgisapp.cpp
  2. +3 −0 src/app/qgisapp.h
  3. +22 −2 src/app/qgsoptions.cpp
  4. +1 −0 src/app/qgsoptions.h
  5. +54 −17 src/ui/qgsoptionsbase.ui
@@ -418,6 +418,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
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::createMenus()

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 @@ void QgisApp::createToolBars()
//
// File Toolbar
mFileToolBar = addToolBar( tr( "File" ) );
mFileToolBar->setIconSize( myIconSize );
mFileToolBar->setObjectName( "FileToolBar" );
mFileToolBar->addAction( mActionNewProject );
mFileToolBar->addAction( mActionOpenProject );
@@ -1680,7 +1682,6 @@ void QgisApp::createToolBars()
//
// Layer Toolbar
mLayerToolBar = addToolBar( tr( "Manage Layers" ) );
mLayerToolBar->setIconSize( myIconSize );
mLayerToolBar->setObjectName( "LayerToolBar" );
mLayerToolBar->addAction( mActionAddOgrLayer );
mLayerToolBar->addAction( mActionAddRasterLayer );
@@ -1701,7 +1702,6 @@ void QgisApp::createToolBars()
//
// Digitizing Toolbar
mDigitizeToolBar = addToolBar( tr( "Digitizing" ) );
mDigitizeToolBar->setIconSize( myIconSize );
mDigitizeToolBar->setObjectName( "Digitizing" );
mDigitizeToolBar->addAction( mActionToggleEditing );
mDigitizeToolBar->addAction( mActionSaveEdits );
@@ -1722,7 +1722,6 @@ void QgisApp::createToolBars()
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 @@ void QgisApp::createToolBars()
//
// 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 @@ void QgisApp::createToolBars()
//
// Attributes Toolbar
mAttributesToolBar = addToolBar( tr( "Attributes" ) );
mAttributesToolBar->setIconSize( myIconSize );
mAttributesToolBar->setObjectName( "Attributes" );
mAttributesToolBar->addAction( mActionIdentify );

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

QSettings settings;
switch ( settings.value( "/UI/selectTool", 0 ).toInt() )
{
default:
@@ -1859,21 +1855,18 @@ void QgisApp::createToolBars()
//
// 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() );
mToolbarMenu->addAction( mHelpToolBar->toggleViewAction() );

//Label Toolbar
mLabelToolBar = addToolBar( tr( "Label" ) );
mLabelToolBar->setIconSize( myIconSize );
mLabelToolBar->setObjectName( "Label" );
mLabelToolBar->addAction( mActionLabeling );
mLabelToolBar->addAction( mActionMoveLabel );
@@ -2015,6 +2008,18 @@ void QgisApp::createStatusBar()
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 )
{
@@ -162,6 +162,9 @@ class QgisApp : public QMainWindow

//! 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
@@ -29,6 +29,8 @@
#include <QSettings>
#include <QColorDialog>
#include <QLocale>
#include <QToolBar>
#include <QSize>

#if QT_VERSION >= 0x40500
#include <QNetworkDiskCache>
@@ -51,8 +53,16 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
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 @@ 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").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 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
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 @@ void QgsOptions::themeChanged( const QString &newThemeName )
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 @@ void QgsOptions::saveOptions()
{
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...
@@ -57,6 +57,7 @@ class QgsOptions : public QDialog, private Ui::QgsOptionsBase
// 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
@@ -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">
@@ -211,6 +211,43 @@
</item>
</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">
@@ -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">

0 comments on commit 4c53217

Please sign in to comment.
You can’t perform that action at this time.