Skip to content

Commit 5155176

Browse files
committedJan 17, 2012
fix setting of icon size and allow to set global fontsize
1 parent db95089 commit 5155176

File tree

5 files changed

+102
-25
lines changed

5 files changed

+102
-25
lines changed
 

‎src/app/qgisapp.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,6 @@ class QTreeWidgetItem;
265265
const int BEFORE_RECENT_PATHS = 123;
266266
const int AFTER_RECENT_PATHS = 321;
267267

268-
269-
270268
/** set the application title bar text
271269
272270
If the current project title is null
@@ -426,6 +424,9 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
426424
mSplash->showMessage( tr( "Setting up the GUI" ), Qt::AlignHCenter | Qt::AlignBottom );
427425
qApp->processEvents();
428426

427+
QSettings settings;
428+
setFontSize( settings.value( "/fontSize", QGIS_FONT_SIZE ).toInt() );
429+
429430
// "theMapCanvas" used to find this canonical instance later
430431
mMapCanvas = new QgsMapCanvas( this, "theMapCanvas" );
431432
mMapCanvas->setWhatsThis( tr( "Map canvas. This is where raster and vector "
@@ -542,7 +543,6 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
542543
}
543544

544545
// Also restore plugins from user specified plugin directories - added for 1.7
545-
QSettings settings;
546546
QString myPaths = settings.value( "plugins/searchPathsForPlugins", "" ).toString();
547547
if ( !myPaths.isEmpty() )
548548
{
@@ -1022,8 +1022,14 @@ void QgisApp::createActionGroups()
10221022
mMapToolGroup->addAction( mActionChangeLabelProperties );
10231023
}
10241024

1025+
void QgisApp::setFontSize( int fontSize )
1026+
{
1027+
setStyleSheet( QString( "font-size: %1pt;" ).arg( fontSize ) );
1028+
}
1029+
10251030
void QgisApp::createMenus()
10261031
{
1032+
10271033
/*
10281034
* The User Interface Guidelines for each platform specify different locations
10291035
* for the following items.
@@ -1119,7 +1125,7 @@ void QgisApp::createMenus()
11191125
void QgisApp::createToolBars()
11201126
{
11211127
QSettings settings;
1122-
int size = settings.value( "/IconSize", 24 ).toInt();
1128+
int size = settings.value( "/IconSize", QGIS_ICON_SIZE ).toInt();
11231129
setIconSize( QSize( size, size ) );
11241130
// QSize myIconSize ( 32,32 ); //large icons
11251131
// Note: we need to set each object name to ensure that

‎src/app/qgisapp.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
162162
void setTheme( QString themeName = "default" );
163163

164164
void setIconSizes( int size );
165+
void setFontSize( int size );
165166

166167
//! Setup the toolbar popup menus for a given theme
167168
void setupToolbarPopups( QString themeName );
@@ -1151,4 +1152,12 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
11511152
bool cmpByText( QAction* a, QAction* b );
11521153
};
11531154

1155+
#ifdef ANDROID
1156+
#define QGIS_ICON_SIZE 32
1157+
#define QGIS_FONT_SIZE 8
1158+
#else
1159+
#define QGIS_ICON_SIZE 24
1160+
#define QGIS_FONT_SIZE 12
1161+
#endif
1162+
11541163
#endif

‎src/app/qgsoptions.cpp

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,15 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
5858
connect( cmbTheme, SIGNAL( highlighted( const QString& ) ), this, SLOT( themeChanged( const QString& ) ) );
5959
connect( cmbTheme, SIGNAL( textChanged( const QString& ) ), this, SLOT( themeChanged( const QString& ) ) );
6060

61-
connect( cmbSize, SIGNAL( activated( const QString& ) ), this, SLOT( iconSizeChanged( const QString& ) ) );
62-
connect( cmbSize, SIGNAL( highlighted( const QString& ) ), this, SLOT( iconSizeChanged( const QString& ) ) );
63-
connect( cmbSize, SIGNAL( textChanged( const QString& ) ), this, SLOT( iconSizeChanged( const QString& ) ) );
61+
connect( cmbIconSize, SIGNAL( activated( const QString& ) ), this, SLOT( iconSizeChanged( const QString& ) ) );
62+
connect( cmbIconSize, SIGNAL( highlighted( const QString& ) ), this, SLOT( iconSizeChanged( const QString& ) ) );
63+
connect( cmbIconSize, SIGNAL( textChanged( const QString& ) ), this, SLOT( iconSizeChanged( const QString& ) ) );
6464

65-
connect( this, SIGNAL( accepted() ), this, SLOT( saveOptions() ) );
65+
connect( cmbFontSize, SIGNAL( activated( const QString& ) ), this, SLOT( fontSizeChanged( const QString& ) ) );
66+
connect( cmbFontSize, SIGNAL( highlighted( const QString& ) ), this, SLOT( fontSizeChanged( const QString& ) ) );
67+
connect( cmbFontSize, SIGNAL( textChanged( const QString& ) ), this, SLOT( fontSizeChanged( const QString& ) ) );
6668

67-
cmbSize->addItem( "16" );
68-
cmbSize->addItem( "24" );
69-
cmbSize->addItem( "32" );
70-
#ifdef ANDROID
71-
int defaultCmbSize = 32;
72-
#else
73-
int defaultCmbSize = 24;
74-
#endif
69+
connect( this, SIGNAL( accepted() ), this, SLOT( saveOptions() ) );
7570

7671
QStringList styles = QStyleFactory::keys();
7772
foreach( QString style, styles )
@@ -286,7 +281,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
286281

287282
// set the theme combo
288283
cmbTheme->setCurrentIndex( cmbTheme->findText( settings.value( "/Themes", "default" ).toString() ) );
289-
cmbSize->setCurrentIndex( cmbSize->findText( settings.value( "/IconSize", defaultCmbSize ).toString() ) );
284+
cmbIconSize->setCurrentIndex( cmbIconSize->findText( settings.value( "/IconSize", QGIS_ICON_SIZE ).toString() ) );
285+
cmbFontSize->setCurrentIndex( cmbFontSize->findText( settings.value( "/menuSize", QGIS_FONT_SIZE ).toString() ) );
290286
QString name = QApplication::style()->objectName();
291287
cmbStyle->setCurrentIndex( cmbStyle->findText( name, Qt::MatchFixedString ) );
292288
//set the state of the checkboxes
@@ -518,15 +514,17 @@ void QgsOptions::on_mLineColorToolButton_clicked()
518514
void QgsOptions::themeChanged( const QString &newThemeName )
519515
{
520516
// Slot to change the theme as user scrolls through the choices
521-
QString newt = newThemeName;
522-
QgisApp::instance()->setTheme( newt );
517+
QgisApp::instance()->setTheme( newThemeName );
523518
}
524519

525520
void QgsOptions::iconSizeChanged( const QString &iconSize )
526521
{
527-
int icon = iconSize.toInt();
528-
QgisApp::instance()->setIconSizes( icon );
522+
QgisApp::instance()->setIconSizes( iconSize.toInt() );
523+
}
529524

525+
void QgsOptions::fontSizeChanged( const QString &menuSize )
526+
{
527+
QgisApp::instance()->setFontSize( menuSize.toInt() );
530528
}
531529

532530
QString QgsOptions::theme()
@@ -652,7 +650,8 @@ void QgsOptions::saveOptions()
652650
settings.setValue( "/Themes", cmbTheme->currentText() );
653651
}
654652

655-
settings.setValue( "/IconSize", cmbSize->currentText() );
653+
settings.setValue( "/IconSize", cmbIconSize->currentText() );
654+
settings.setValue( "/fontSize", cmbFontSize->currentText() );
656655

657656
settings.setValue( "/Map/updateThreshold", spinBoxUpdateThreshold->value() );
658657
//check behaviour so default projection when new layer is added with no

‎src/app/qgsoptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include "ui_qgsoptionsbase.h"
2222
#include "qgisgui.h"
23+
#include "qgisapp.h"
2324
#include "qgscontexthelp.h"
2425

2526
#include <qgscoordinatereferencesystem.h>
@@ -59,6 +60,9 @@ class QgsOptions : public QDialog, private Ui::QgsOptionsBase
5960
void themeChanged( const QString & );
6061

6162
void iconSizeChanged( const QString &iconSize );
63+
64+
void fontSizeChanged( const QString &fontSize );
65+
6266
/**
6367
* Return the desired state of newly added layers. If a layer
6468
* is to be drawn when added to the map, this function returns

‎src/ui/qgsoptionsbase.ui

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
<height>763</height>
7171
</rect>
7272
</property>
73-
<layout class="QGridLayout" name="gridLayout_12">
73+
<layout class="QGridLayout" name="gridLayout">
7474
<item row="0" column="0">
7575
<widget class="QGroupBox" name="groupBox_11">
7676
<property name="title">
@@ -276,10 +276,68 @@
276276
</spacer>
277277
</item>
278278
<item>
279-
<widget class="QComboBox" name="cmbSize">
279+
<widget class="QComboBox" name="cmbIconSize">
280280
<property name="duplicatesEnabled">
281281
<bool>false</bool>
282282
</property>
283+
<item>
284+
<property name="text">
285+
<string>16</string>
286+
</property>
287+
</item>
288+
<item>
289+
<property name="text">
290+
<string>24</string>
291+
</property>
292+
</item>
293+
<item>
294+
<property name="text">
295+
<string>32</string>
296+
</property>
297+
</item>
298+
</widget>
299+
</item>
300+
</layout>
301+
</item>
302+
<item>
303+
<layout class="QHBoxLayout" name="horizontalLayout_11">
304+
<item>
305+
<widget class="QLabel" name="label_20">
306+
<property name="text">
307+
<string>Menu size</string>
308+
</property>
309+
</widget>
310+
</item>
311+
<item>
312+
<spacer name="horizontalSpacer_9">
313+
<property name="orientation">
314+
<enum>Qt::Horizontal</enum>
315+
</property>
316+
<property name="sizeHint" stdset="0">
317+
<size>
318+
<width>40</width>
319+
<height>20</height>
320+
</size>
321+
</property>
322+
</spacer>
323+
</item>
324+
<item>
325+
<widget class="QComboBox" name="cmbFontSize">
326+
<item>
327+
<property name="text">
328+
<string>8</string>
329+
</property>
330+
</item>
331+
<item>
332+
<property name="text">
333+
<string>12</string>
334+
</property>
335+
</item>
336+
<item>
337+
<property name="text">
338+
<string>16</string>
339+
</property>
340+
</item>
283341
</widget>
284342
</item>
285343
</layout>
@@ -2027,7 +2085,8 @@
20272085
<tabstop>pbnSelectionColor</tabstop>
20282086
<tabstop>pbnCanvasColor</tabstop>
20292087
<tabstop>cmbTheme</tabstop>
2030-
<tabstop>cmbSize</tabstop>
2088+
<tabstop>cmbIconSize</tabstop>
2089+
<tabstop>cmbFontSize</tabstop>
20312090
<tabstop>cmbLegendDoubleClickAction</tabstop>
20322091
<tabstop>capitaliseCheckBox</tabstop>
20332092
<tabstop>cbxLegendClassifiers</tabstop>

0 commit comments

Comments
 (0)
Please sign in to comment.