mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
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:
parent
a3e3a30b70
commit
2cc215d3f2
4 changed files with 59 additions and 14 deletions
|
@ -315,26 +315,23 @@ Kirigami.ScrollablePage {
|
||||||
spacing: Kirigami.Units.largeSpacing
|
spacing: Kirigami.Units.largeSpacing
|
||||||
SsrfButton {
|
SsrfButton {
|
||||||
text: qsTr("smaller")
|
text: qsTr("smaller")
|
||||||
enabled: subsurfaceTheme.currentScale !== 0.85
|
enabled: ThemeNew.currentScale !== 0.85
|
||||||
onClicked: {
|
onClicked: {
|
||||||
PrefDisplay.mobile_scale = 0.85
|
ThemeNew.currentScale = 0.85
|
||||||
fontMetrics.font.pointSize = themeNew.basePointSize * PrefDisplay.mobile_scale;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SsrfButton {
|
SsrfButton {
|
||||||
text: qsTr("regular")
|
text: qsTr("regular")
|
||||||
enabled: subsurfaceTheme.currentScale !== 1.0
|
enabled: ThemeNew.currentScale !== 1.0
|
||||||
onClicked: {
|
onClicked: {
|
||||||
PrefDisplay.mobile_scale = 1.0
|
ThemeNew.currentScale = 1.0
|
||||||
fontMetrics.font.pointSize = themeNew.basePointSize * PrefDisplay.mobile_scale;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SsrfButton {
|
SsrfButton {
|
||||||
text: qsTr("larger")
|
text: qsTr("larger")
|
||||||
enabled: subsurfaceTheme.currentScale !== 1.15
|
enabled: ThemeNew.currentScale !== 1.15
|
||||||
onClicked: {
|
onClicked: {
|
||||||
PrefDisplay.mobile_scale = 1.15
|
ThemeNew.currentScale = 1.15
|
||||||
fontMetrics.font.pointSize = themeNew.basePointSize * PrefDisplay.mobile_scale;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -596,10 +596,10 @@ if you have network connectivity and want to sync your data to cloud storage."),
|
||||||
QtObject {
|
QtObject {
|
||||||
id: subsurfaceTheme
|
id: subsurfaceTheme
|
||||||
|
|
||||||
property double regularPointSize: fontMetrics.font.pointSize
|
property double regularPointSize: ThemeNew.regularPointSize
|
||||||
property double titlePointSize: regularPointSize * 1.5
|
property double titlePointSize: ThemeNew.titlePointSize
|
||||||
property double headingPointSize: regularPointSize * 1.2
|
property double headingPointSize: ThemeNew.headingPointSize
|
||||||
property double smallPointSize: regularPointSize * 0.8
|
property double smallPointSize: ThemeNew.smallPointSize
|
||||||
|
|
||||||
// colors currently in use
|
// colors currently in use
|
||||||
property color darkerPrimaryColor: ThemeNew.darkerPrimaryColor
|
property color darkerPrimaryColor: ThemeNew.darkerPrimaryColor
|
||||||
|
|
|
@ -23,7 +23,7 @@ void themeInterface::setup(QQmlContext *ct)
|
||||||
instance()->m_basePointSize = defaultModelFont().pointSize();
|
instance()->m_basePointSize = defaultModelFont().pointSize();
|
||||||
|
|
||||||
// set initial font size
|
// set initial font size
|
||||||
defaultModelFont().setPointSize(m_basePointSize * qPrefDisplay::mobile_scale());
|
instance()->set_currentScale(qPrefDisplay::mobile_scale());
|
||||||
}
|
}
|
||||||
|
|
||||||
void themeInterface::set_currentTheme(const QString &theme)
|
void themeInterface::set_currentTheme(const QString &theme)
|
||||||
|
@ -34,6 +34,36 @@ void themeInterface::set_currentTheme(const QString &theme)
|
||||||
emit currentThemeChanged(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()
|
void themeInterface::update_theme()
|
||||||
{
|
{
|
||||||
if (m_currentTheme == "Blue") {
|
if (m_currentTheme == "Blue") {
|
||||||
|
|
|
@ -25,6 +25,11 @@ class themeInterface : public QObject {
|
||||||
|
|
||||||
// Font
|
// Font
|
||||||
Q_PROPERTY(double basePointSize MEMBER m_basePointSize CONSTANT)
|
Q_PROPERTY(double basePointSize MEMBER m_basePointSize CONSTANT)
|
||||||
|
Q_PROPERTY(double headingPointSize MEMBER m_headingPointSize NOTIFY headingPointSizeChanged)
|
||||||
|
Q_PROPERTY(double regularPointSize MEMBER m_regularPointSize NOTIFY regularPointSizeChanged)
|
||||||
|
Q_PROPERTY(double smallPointSize MEMBER m_smallPointSize NOTIFY smallPointSizeChanged)
|
||||||
|
Q_PROPERTY(double titlePointSize MEMBER m_titlePointSize NOTIFY titlePointSizeChanged)
|
||||||
|
Q_PROPERTY(double currentScale READ currentScale WRITE set_currentScale NOTIFY currentScaleChanged)
|
||||||
|
|
||||||
// Support
|
// Support
|
||||||
Q_PROPERTY(QString currentTheme MEMBER m_currentTheme WRITE set_currentTheme NOTIFY currentThemeChanged)
|
Q_PROPERTY(QString currentTheme MEMBER m_currentTheme WRITE set_currentTheme NOTIFY currentThemeChanged)
|
||||||
|
@ -78,6 +83,9 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
void set_currentTheme(const QString &theme);
|
void set_currentTheme(const QString &theme);
|
||||||
|
|
||||||
|
double currentScale();
|
||||||
|
void set_currentScale(double);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void backgroundColorChanged(QColor);
|
void backgroundColorChanged(QColor);
|
||||||
void contrastAccentColorChanged(QColor);
|
void contrastAccentColorChanged(QColor);
|
||||||
|
@ -92,6 +100,12 @@ signals:
|
||||||
void secondaryTextColorChanged(QColor);
|
void secondaryTextColorChanged(QColor);
|
||||||
void textColorChanged(QColor);
|
void textColorChanged(QColor);
|
||||||
|
|
||||||
|
void headingPointSizeChanged(double);
|
||||||
|
void regularPointSizeChanged(double);
|
||||||
|
void smallPointSizeChanged(double);
|
||||||
|
void titlePointSizeChanged(double);
|
||||||
|
void currentScaleChanged(double);
|
||||||
|
|
||||||
void currentThemeChanged(const QString &);
|
void currentThemeChanged(const QString &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -112,6 +126,10 @@ private:
|
||||||
QColor m_textColor;
|
QColor m_textColor;
|
||||||
|
|
||||||
double m_basePointSize;
|
double m_basePointSize;
|
||||||
|
double m_headingPointSize;
|
||||||
|
double m_regularPointSize;
|
||||||
|
double m_smallPointSize;
|
||||||
|
double m_titlePointSize;
|
||||||
|
|
||||||
QString m_currentTheme;
|
QString m_currentTheme;
|
||||||
QString m_iconStyle;
|
QString m_iconStyle;
|
||||||
|
|
Loading…
Reference in a new issue