Skip to content

Commit

Permalink
use applications default font instead of style sheet to set options a…
Browse files Browse the repository at this point in the history
…nd determine default size (fixes 5155176)
  • Loading branch information
jef-n committed Jan 18, 2012
1 parent b94b4b4 commit 2664dbf
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 44 deletions.
6 changes: 4 additions & 2 deletions src/app/qgisapp.cpp 100644 → 100755
Expand Up @@ -425,7 +425,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
qApp->processEvents();

QSettings settings;
setFontSize( settings.value( "/fontSize", QGIS_FONT_SIZE ).toInt() );
setFontSize( settings.value( "/fontPointSize", font().pointSize() ).toInt() );

// "theMapCanvas" used to find this canonical instance later
mMapCanvas = new QgsMapCanvas( this, "theMapCanvas" );
Expand Down Expand Up @@ -1024,7 +1024,9 @@ void QgisApp::createActionGroups()

void QgisApp::setFontSize( int fontSize )
{
setStyleSheet( QString( "font-size: %1pt;" ).arg( fontSize ) );
QFont theFont = font();
theFont.setPointSize( fontSize );
setFont( theFont );
}

void QgisApp::createMenus()
Expand Down
2 changes: 0 additions & 2 deletions src/app/qgisapp.h
Expand Up @@ -1154,10 +1154,8 @@ class QgisApp : public QMainWindow, private Ui::MainWindow

#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
12 changes: 5 additions & 7 deletions src/app/qgsoptions.cpp 100644 → 100755
Expand Up @@ -62,9 +62,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
connect( cmbIconSize, SIGNAL( highlighted( const QString& ) ), this, SLOT( iconSizeChanged( const QString& ) ) );
connect( cmbIconSize, SIGNAL( textChanged( const QString& ) ), this, SLOT( iconSizeChanged( const QString& ) ) );

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& ) ) );
connect( spinFontSize, SIGNAL( valueChanged( const QString& ) ), this, SLOT( fontSizeChanged( const QString& ) ) );

connect( this, SIGNAL( accepted() ), this, SLOT( saveOptions() ) );

Expand Down Expand Up @@ -282,7 +280,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
// set the theme combo
cmbTheme->setCurrentIndex( cmbTheme->findText( settings.value( "/Themes", "default" ).toString() ) );
cmbIconSize->setCurrentIndex( cmbIconSize->findText( settings.value( "/IconSize", QGIS_ICON_SIZE ).toString() ) );
cmbFontSize->setCurrentIndex( cmbFontSize->findText( settings.value( "/menuSize", QGIS_FONT_SIZE ).toString() ) );
spinFontSize->setValue( settings.value( "/fontPointSize", QgisApp::instance()->font().pointSize() ).toInt() );
QString name = QApplication::style()->objectName();
cmbStyle->setCurrentIndex( cmbStyle->findText( name, Qt::MatchFixedString ) );
//set the state of the checkboxes
Expand Down Expand Up @@ -522,9 +520,9 @@ void QgsOptions::iconSizeChanged( const QString &iconSize )
QgisApp::instance()->setIconSizes( iconSize.toInt() );
}

void QgsOptions::fontSizeChanged( const QString &menuSize )
void QgsOptions::fontSizeChanged( const QString &fontSize )
{
QgisApp::instance()->setFontSize( menuSize.toInt() );
QgisApp::instance()->setFontSize( fontSize.toInt() );
}

QString QgsOptions::theme()
Expand Down Expand Up @@ -651,7 +649,7 @@ void QgsOptions::saveOptions()
}

settings.setValue( "/IconSize", cmbIconSize->currentText() );
settings.setValue( "/fontSize", cmbFontSize->currentText() );
settings.setValue( "/fontPointSize", spinFontSize->value() );

settings.setValue( "/Map/updateThreshold", spinBoxUpdateThreshold->value() );
//check behaviour so default projection when new layer is added with no
Expand Down
53 changes: 20 additions & 33 deletions src/ui/qgsoptionsbase.ui
Expand Up @@ -66,8 +66,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>803</width>
<height>763</height>
<width>779</width>
<height>791</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
Expand Down Expand Up @@ -322,22 +322,10 @@
</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 class="QSpinBox" name="spinFontSize">
<property name="minimum">
<number>4</number>
</property>
</widget>
</item>
</layout>
Expand Down Expand Up @@ -696,8 +684,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>803</width>
<height>763</height>
<width>604</width>
<height>494</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_8">
Expand Down Expand Up @@ -870,8 +858,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>803</width>
<height>763</height>
<width>483</width>
<height>478</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_4">
Expand Down Expand Up @@ -1156,8 +1144,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>803</width>
<height>763</height>
<width>257</width>
<height>93</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_10">
Expand Down Expand Up @@ -1231,8 +1219,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>781</width>
<height>741</height>
<width>569</width>
<height>510</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_13">
Expand Down Expand Up @@ -1577,8 +1565,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>803</width>
<height>763</height>
<width>412</width>
<height>411</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_15">
Expand Down Expand Up @@ -1751,8 +1739,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>803</width>
<height>763</height>
<width>523</width>
<height>560</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_17">
Expand Down Expand Up @@ -1848,8 +1836,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>803</width>
<height>763</height>
<width>321</width>
<height>541</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_20">
Expand Down Expand Up @@ -2086,7 +2074,6 @@
<tabstop>pbnCanvasColor</tabstop>
<tabstop>cmbTheme</tabstop>
<tabstop>cmbIconSize</tabstop>
<tabstop>cmbFontSize</tabstop>
<tabstop>cmbLegendDoubleClickAction</tabstop>
<tabstop>capitaliseCheckBox</tabstop>
<tabstop>cbxLegendClassifiers</tabstop>
Expand Down

0 comments on commit 2664dbf

Please sign in to comment.