mobile-widgets: move font property to themeInterface

Move setting of font properties used throughout to themeInterface.
Add new settings "currentScale".

The properties are kept in main (subsurfaceTheme) in order not to do
a big search/replace.

Update settings to use currectScale and signal changes in themeinterface.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
jan Iversen 2020-01-14 19:30:47 +01:00 committed by Dirk Hohndel
parent a3e3a30b70
commit 2cc215d3f2
4 changed files with 59 additions and 14 deletions

View file

@ -23,7 +23,7 @@ void themeInterface::setup(QQmlContext *ct)
instance()->m_basePointSize = defaultModelFont().pointSize();
// set initial font size
defaultModelFont().setPointSize(m_basePointSize * qPrefDisplay::mobile_scale());
instance()->set_currentScale(qPrefDisplay::mobile_scale());
}
void themeInterface::set_currentTheme(const QString &theme)
@ -34,6 +34,36 @@ void themeInterface::set_currentTheme(const QString &theme)
emit currentThemeChanged(theme);
}
double themeInterface::currentScale()
{
return qPrefDisplay::mobile_scale();
}
void themeInterface::set_currentScale(double newScale)
{
if (newScale != qPrefDisplay::mobile_scale()) {
qPrefDisplay::set_mobile_scale(newScale);
emit currentScaleChanged(qPrefDisplay::mobile_scale());
}
// Set current font size
defaultModelFont().setPointSize(m_basePointSize * qPrefDisplay::mobile_scale());
// adjust all used font sizes
m_regularPointSize = defaultModelFont().pointSize();
emit regularPointSizeChanged(m_regularPointSize);
m_headingPointSize = m_regularPointSize * 1.2;
emit headingPointSizeChanged(m_headingPointSize);
m_smallPointSize = m_regularPointSize * 0.8;
emit smallPointSizeChanged(m_smallPointSize);
m_titlePointSize = m_regularPointSize * 1.5;
emit titlePointSizeChanged(m_titlePointSize);
}
void themeInterface::update_theme()
{
if (m_currentTheme == "Blue") {