Skip to content

Commit

Permalink
fix setting of icon size and allow to set global fontsize
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jan 17, 2012
1 parent db95089 commit 5155176
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 25 deletions.
14 changes: 10 additions & 4 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 "
Expand Down Expand Up @@ -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() )
{
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions src/app/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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
35 changes: 17 additions & 18 deletions src/app/qgsoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/app/qgsoptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "ui_qgsoptionsbase.h"
#include "qgisgui.h"
#include "qgisapp.h"
#include "qgscontexthelp.h"

#include <qgscoordinatereferencesystem.h>
Expand Down Expand Up @@ -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
Expand Down
65 changes: 62 additions & 3 deletions src/ui/qgsoptionsbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<height>763</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">
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -2027,7 +2085,8 @@
<tabstop>pbnSelectionColor</tabstop>
<tabstop>pbnCanvasColor</tabstop>
<tabstop>cmbTheme</tabstop>
<tabstop>cmbSize</tabstop>
<tabstop>cmbIconSize</tabstop>
<tabstop>cmbFontSize</tabstop>
<tabstop>cmbLegendDoubleClickAction</tabstop>
<tabstop>capitaliseCheckBox</tabstop>
<tabstop>cbxLegendClassifiers</tabstop>
Expand Down

0 comments on commit 5155176

Please sign in to comment.