Skip to content

Commit e823ab2

Browse files
committed
[themes] Apply OS-specific UI scale factor to em values
1 parent 5a67fb2 commit e823ab2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/core/qgsapplication.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,23 @@ void QgsApplication::setUITheme( const QString &themeName )
759759
}
760760
file.close();
761761

762+
if ( Qgis::UI_SCALE_FACTOR != 1.0 )
763+
{
764+
// apply OS-specific UI scale factor to stylesheet's em values
765+
int index = 0;
766+
QRegularExpression regex( QStringLiteral( "(?<=[\\s:])([0-9\\.]+)(?=em)" ) );
767+
QRegularExpressionMatch match = regex.match( styledata, index );
768+
while ( match.hasMatch() )
769+
{
770+
index = match.capturedStart();
771+
styledata.remove( index, match.captured( 0 ).length() );
772+
QString number = QString::number( match.captured( 0 ).toDouble() * Qgis::UI_SCALE_FACTOR );
773+
styledata.insert( index, number );
774+
index += number.length();
775+
match = regex.match( styledata, index );
776+
}
777+
}
778+
762779
qApp->setStyleSheet( styledata );
763780

764781
QFile palettefile( path + "/palette.txt" );

0 commit comments

Comments
 (0)