Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow a single decimal place for font size setting
On windows hidpi displays this IS required to get nice sizing, eg
when the display scaling is set to a non-integer scaling factor
(ie 150%)
  • Loading branch information
nyalldawson committed May 17, 2023
1 parent d7c78e0 commit 9f78dee
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/app/options/qgsoptions.cpp
Expand Up @@ -142,7 +142,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
connect( leLayerGlobalCrs, &QgsProjectionSelectionWidget::crsChanged, this, &QgsOptions::leLayerGlobalCrs_crsChanged );
connect( lstRasterDrivers, &QTreeWidget::itemDoubleClicked, this, &QgsOptions::lstRasterDrivers_itemDoubleClicked );
connect( mProjectOnLaunchCmbBx, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsOptions::mProjectOnLaunchCmbBx_currentIndexChanged );
connect( spinFontSize, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), this, &QgsOptions::spinFontSize_valueChanged );
connect( spinFontSize, qOverload< double>( &QDoubleSpinBox::valueChanged ), this, &QgsOptions::spinFontSize_valueChanged );
connect( mFontFamilyRadioQt, &QRadioButton::released, this, &QgsOptions::mFontFamilyRadioQt_released );
connect( mFontFamilyRadioCustom, &QRadioButton::released, this, &QgsOptions::mFontFamilyRadioCustom_released );
connect( mFontFamilyComboBox, &QFontComboBox::currentFontChanged, this, &QgsOptions::mFontFamilyComboBox_currentFontChanged );
Expand Down Expand Up @@ -679,7 +679,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
mFontFamilyRadioCustom->blockSignals( true );
mFontFamilyComboBox->blockSignals( true );

spinFontSize->setValue( mStyleSheetOldOpts.value( QStringLiteral( "fontPointSize" ) ).toInt() );
spinFontSize->setValue( mStyleSheetOldOpts.value( QStringLiteral( "fontPointSize" ) ).toDouble() );
QString fontFamily = mStyleSheetOldOpts.value( QStringLiteral( "fontFamily" ) ).toString();
bool isQtDefault = ( fontFamily == mStyleSheetBuilder->defaultFont().family() );
mFontFamilyRadioQt->setChecked( isQtDefault );
Expand Down Expand Up @@ -1885,7 +1885,7 @@ void QgsOptions::rejectOptions()
}
}

void QgsOptions::spinFontSize_valueChanged( int fontSize )
void QgsOptions::spinFontSize_valueChanged( double fontSize )
{
mStyleSheetNewOpts.insert( QStringLiteral( "fontPointSize" ), QVariant( fontSize ) );
mStyleSheetBuilder->buildStyleSheet( mStyleSheetNewOpts );
Expand Down
2 changes: 1 addition & 1 deletion src/app/options/qgsoptions.h
Expand Up @@ -113,7 +113,7 @@ class APP_EXPORT QgsOptions : public QgsOptionsDialogBase, private Ui::QgsOption
void selectProjectOnLaunch();

//! Slot to select the default font point size for app
void spinFontSize_valueChanged( int fontSize );
void spinFontSize_valueChanged(double fontSize );

//! Slot to set font family for app to Qt default
void mFontFamilyRadioQt_released();
Expand Down
15 changes: 6 additions & 9 deletions src/ui/qgsoptionsbase.ui
Expand Up @@ -122,7 +122,7 @@
<item>
<widget class="QStackedWidget" name="mOptionsStackedWidget">
<property name="currentIndex">
<number>7</number>
<number>0</number>
</property>
<widget class="QWidget" name="mOptionsPageGeneral">
<layout class="QVBoxLayout" name="verticalLayout_3">
Expand Down Expand Up @@ -370,7 +370,7 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_27">
<layout class="QHBoxLayout" name="horizontalLayout_27" stretch="0,0,0,4,0,1">
<item>
<widget class="QLabel" name="label_43">
<property name="text">
Expand Down Expand Up @@ -424,15 +424,12 @@
</widget>
</item>
<item>
<widget class="QgsSpinBox" name="spinFontSize">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<widget class="QgsDoubleSpinBox" name="spinFontSize">
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<number>4</number>
<double>2.000000000000000</double>
</property>
</widget>
</item>
Expand Down

0 comments on commit 9f78dee

Please sign in to comment.