Skip to content

Commit

Permalink
Option for user to set icon size to 16, 24, or 32 px.
Browse files Browse the repository at this point in the history
Contributed by madmanwoo (NathanW)

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15136 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
gsherman committed Feb 8, 2011
1 parent 9548bd7 commit e106293
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 30 deletions.
27 changes: 16 additions & 11 deletions src/app/qgisapp.cpp
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand All @@ -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 );
Expand All @@ -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 );
Expand All @@ -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 );
Expand All @@ -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 );
Expand All @@ -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 );
Expand All @@ -1758,7 +1756,6 @@ void QgisApp::createToolBars()
//
// Attributes Toolbar
mAttributesToolBar = addToolBar( tr( "Attributes" ) );
mAttributesToolBar->setIconSize( myIconSize );
mAttributesToolBar->setObjectName( "Attributes" );
mAttributesToolBar->addAction( mActionIdentify );

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

QSettings settings;
switch ( settings.value( "/UI/selectTool", 0 ).toInt() )
{
default:
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 )
{
Expand Down
3 changes: 3 additions & 0 deletions src/app/qgisapp.h
Expand Up @@ -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
Expand Down
24 changes: 22 additions & 2 deletions src/app/qgsoptions.cpp
Expand Up @@ -29,6 +29,8 @@
#include <QSettings>
#include <QColorDialog>
#include <QLocale>
#include <QToolBar>
#include <QSize>

#if QT_VERSION >= 0x40500
#include <QNetworkDiskCache>
Expand All @@ -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 );
Expand Down Expand Up @@ -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() );
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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...
Expand Down
1 change: 1 addition & 0 deletions src/app/qgsoptions.h
Expand Up @@ -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
Expand Down
71 changes: 54 additions & 17 deletions src/ui/qgsoptionsbase.ui
Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand Down

0 comments on commit e106293

Please sign in to comment.