Skip to content

Instantly share code, notes, and snippets.

@jef-n
Created January 17, 2012 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jef-n/1628837 to your computer and use it in GitHub Desktop.
Save jef-n/1628837 to your computer and use it in GitHub Desktop.
diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp
index fd6ef38..dbaa30d 100644
--- a/src/app/qgisapp.cpp
+++ b/src/app/qgisapp.cpp
@@ -265,8 +265,6 @@ class QTreeWidgetItem;
const int BEFORE_RECENT_PATHS = 123;
const int AFTER_RECENT_PATHS = 321;
-
-
/** set the application title bar text
If the current project title is null
@@ -426,6 +424,9 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
mSplash->showMessage( tr( "Setting up the GUI" ), Qt::AlignHCenter | Qt::AlignBottom );
qApp->processEvents();
+ QSettings settings;
+ setFontSize( settings.value( "/fontSize", QGIS_FONT_SIZE ).toInt() );
+
// "theMapCanvas" used to find this canonical instance later
mMapCanvas = new QgsMapCanvas( this, "theMapCanvas" );
mMapCanvas->setWhatsThis( tr( "Map canvas. This is where raster and vector "
@@ -542,7 +543,6 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
}
// Also restore plugins from user specified plugin directories - added for 1.7
- QSettings settings;
QString myPaths = settings.value( "plugins/searchPathsForPlugins", "" ).toString();
if ( !myPaths.isEmpty() )
{
@@ -1022,8 +1022,14 @@ void QgisApp::createActionGroups()
mMapToolGroup->addAction( mActionChangeLabelProperties );
}
+void QgisApp::setFontSize( int fontSize )
+{
+ setStyleSheet( QString( "font-size: %1pt;" ).arg( fontSize ) );
+}
+
void QgisApp::createMenus()
{
+
/*
* The User Interface Guidelines for each platform specify different locations
* for the following items.
@@ -1119,7 +1125,7 @@ void QgisApp::createMenus()
void QgisApp::createToolBars()
{
QSettings settings;
- int size = settings.value( "/IconSize", 24 ).toInt();
+ int size = settings.value( "/IconSize", QGIS_ICON_SIZE ).toInt();
setIconSize( QSize( size, size ) );
// QSize myIconSize ( 32,32 ); //large icons
// Note: we need to set each object name to ensure that
diff --git a/src/app/qgisapp.h b/src/app/qgisapp.h
index 88af51e..e1581a1 100644
--- a/src/app/qgisapp.h
+++ b/src/app/qgisapp.h
@@ -162,6 +162,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
void setTheme( QString themeName = "default" );
void setIconSizes( int size );
+ void setFontSize( int size );
//! Setup the toolbar popup menus for a given theme
void setupToolbarPopups( QString themeName );
@@ -1151,4 +1152,12 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
bool cmpByText( QAction* a, QAction* b );
};
+#ifdef ANDROID
+#define QGIS_ICON_SIZE 32
+#define QGIS_FONT_SIZE 8
+#else
+#define QGIS_ICON_SIZE 24
+#define QGIS_FONT_SIZE 12
+#endif
+
#endif
diff --git a/src/app/qgsoptions.cpp b/src/app/qgsoptions.cpp
index 70406f0..db7d2ce 100644
--- a/src/app/qgsoptions.cpp
+++ b/src/app/qgsoptions.cpp
@@ -58,20 +58,15 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
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( cmbIconSize, SIGNAL( activated( const QString& ) ), this, SLOT( iconSizeChanged( const QString& ) ) );
+ connect( cmbIconSize, SIGNAL( highlighted( const QString& ) ), this, SLOT( iconSizeChanged( const QString& ) ) );
+ connect( cmbIconSize, SIGNAL( textChanged( const QString& ) ), this, SLOT( iconSizeChanged( const QString& ) ) );
- connect( this, SIGNAL( accepted() ), this, SLOT( saveOptions() ) );
+ connect( cmbFontSize, SIGNAL( activated( const QString& ) ), this, SLOT( fontSizeChanged( const QString& ) ) );
+ connect( cmbFontSize, SIGNAL( highlighted( const QString& ) ), this, SLOT( fontSizeChanged( const QString& ) ) );
+ connect( cmbFontSize, SIGNAL( textChanged( const QString& ) ), this, SLOT( fontSizeChanged( const QString& ) ) );
- cmbSize->addItem( "16" );
- cmbSize->addItem( "24" );
- cmbSize->addItem( "32" );
-#ifdef ANDROID
- int defaultCmbSize = 32;
-#else
- int defaultCmbSize = 24;
-#endif
+ connect( this, SIGNAL( accepted() ), this, SLOT( saveOptions() ) );
QStringList styles = QStyleFactory::keys();
foreach( QString style, styles )
@@ -286,7 +281,8 @@ 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", defaultCmbSize ).toString() ) );
+ cmbIconSize->setCurrentIndex( cmbIconSize->findText( settings.value( "/IconSize", QGIS_ICON_SIZE ).toString() ) );
+ cmbFontSize->setCurrentIndex( cmbFontSize->findText( settings.value( "/menuSize", QGIS_FONT_SIZE ).toString() ) );
QString name = QApplication::style()->objectName();
cmbStyle->setCurrentIndex( cmbStyle->findText( name, Qt::MatchFixedString ) );
//set the state of the checkboxes
@@ -518,15 +514,17 @@ void QgsOptions::on_mLineColorToolButton_clicked()
void QgsOptions::themeChanged( const QString &newThemeName )
{
// Slot to change the theme as user scrolls through the choices
- QString newt = newThemeName;
- QgisApp::instance()->setTheme( newt );
+ QgisApp::instance()->setTheme( newThemeName );
}
void QgsOptions::iconSizeChanged( const QString &iconSize )
{
- int icon = iconSize.toInt();
- QgisApp::instance()->setIconSizes( icon );
+ QgisApp::instance()->setIconSizes( iconSize.toInt() );
+}
+void QgsOptions::fontSizeChanged( const QString &menuSize )
+{
+ QgisApp::instance()->setFontSize( menuSize.toInt() );
}
QString QgsOptions::theme()
@@ -652,7 +650,8 @@ void QgsOptions::saveOptions()
settings.setValue( "/Themes", cmbTheme->currentText() );
}
- settings.setValue( "/IconSize", cmbSize->currentText() );
+ settings.setValue( "/IconSize", cmbIconSize->currentText() );
+ settings.setValue( "/fontSize", cmbFontSize->currentText() );
settings.setValue( "/Map/updateThreshold", spinBoxUpdateThreshold->value() );
//check behaviour so default projection when new layer is added with no
diff --git a/src/app/qgsoptions.h b/src/app/qgsoptions.h
index da4ed10..6839a5d 100644
--- a/src/app/qgsoptions.h
+++ b/src/app/qgsoptions.h
@@ -20,6 +20,7 @@
#include "ui_qgsoptionsbase.h"
#include "qgisgui.h"
+#include "qgisapp.h"
#include "qgscontexthelp.h"
#include <qgscoordinatereferencesystem.h>
@@ -59,6 +60,9 @@ class QgsOptions : public QDialog, private Ui::QgsOptionsBase
void themeChanged( const QString & );
void iconSizeChanged( const QString &iconSize );
+
+ void fontSizeChanged( const QString &fontSize );
+
/**
* Return the desired state of newly added layers. If a layer
* is to be drawn when added to the map, this function returns
diff --git a/src/ui/qgsoptionsbase.ui b/src/ui/qgsoptionsbase.ui
index 1a6108d..23758be 100644
--- a/src/ui/qgsoptionsbase.ui
+++ b/src/ui/qgsoptionsbase.ui
@@ -66,11 +66,11 @@
<rect>
<x>0</x>
<y>0</y>
- <width>803</width>
- <height>763</height>
+ <width>788</width>
+ <height>856</height>
</rect>
</property>
- <layout class="QGridLayout" name="gridLayout_12">
+ <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_11">
<property name="title">
@@ -276,10 +276,68 @@
</spacer>
</item>
<item>
- <widget class="QComboBox" name="cmbSize">
+ <widget class="QComboBox" name="cmbIconSize">
<property name="duplicatesEnabled">
<bool>false</bool>
</property>
+ <item>
+ <property name="text">
+ <string>16</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>24</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>32</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_11">
+ <item>
+ <widget class="QLabel" name="label_20">
+ <property name="text">
+ <string>Menu size</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_9">
+ <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="cmbFontSize">
+ <item>
+ <property name="text">
+ <string>8</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>12</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>16</string>
+ </property>
+ </item>
</widget>
</item>
</layout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment