cleanup: don't send values in changed-signals of ThemeInterface

According to the Qt-docs you *may* send the new values in the
NOTIFY signal of Q_PROPERTYs. However, since changes will lead
to a reevaluation of a whole expression, this argument will be
unused. All it does is make the code more verbose and brittle:
What happens if you send the wrong value?

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2020-03-30 21:20:49 +02:00 committed by Dirk Hohndel
parent ce1629ccce
commit 0e9bd27bae
2 changed files with 37 additions and 36 deletions

View file

@ -72,18 +72,19 @@ void ThemeInterface::set_currentTheme(const QString &theme)
m_currentTheme = theme; m_currentTheme = theme;
qPrefDisplay::set_theme(m_currentTheme); qPrefDisplay::set_theme(m_currentTheme);
update_theme(); update_theme();
emit currentThemeChanged(theme); emit currentThemeChanged();
} }
double ThemeInterface::currentScale() double ThemeInterface::currentScale()
{ {
return qPrefDisplay::mobile_scale(); return qPrefDisplay::mobile_scale();
} }
void ThemeInterface::set_currentScale(double newScale) void ThemeInterface::set_currentScale(double newScale)
{ {
if (newScale != qPrefDisplay::mobile_scale()) { if (newScale != qPrefDisplay::mobile_scale()) {
qPrefDisplay::set_mobile_scale(newScale); qPrefDisplay::set_mobile_scale(newScale);
emit currentScaleChanged(qPrefDisplay::mobile_scale()); emit currentScaleChanged();
} }
// Set current font size // Set current font size
@ -91,16 +92,16 @@ void ThemeInterface::set_currentScale(double newScale)
// adjust all used font sizes // adjust all used font sizes
m_regularPointSize = m_basePointSize * qPrefDisplay::mobile_scale(); m_regularPointSize = m_basePointSize * qPrefDisplay::mobile_scale();
emit regularPointSizeChanged(m_regularPointSize); emit regularPointSizeChanged();
m_headingPointSize = m_regularPointSize * 1.2; m_headingPointSize = m_regularPointSize * 1.2;
emit headingPointSizeChanged(m_headingPointSize); emit headingPointSizeChanged();
m_smallPointSize = m_regularPointSize * 0.8; m_smallPointSize = m_regularPointSize * 0.8;
emit smallPointSizeChanged(m_smallPointSize); emit smallPointSizeChanged();
m_titlePointSize = m_regularPointSize * 1.5; m_titlePointSize = m_regularPointSize * 1.5;
emit titlePointSizeChanged(m_titlePointSize); emit titlePointSizeChanged();
} }
void ThemeInterface::update_theme() void ThemeInterface::update_theme()
@ -145,16 +146,16 @@ void ThemeInterface::update_theme()
m_secondaryTextColor = DARK_SECONDARY_TEXT_COLOR; m_secondaryTextColor = DARK_SECONDARY_TEXT_COLOR;
m_textColor = DARK_TEXT_COLOR; m_textColor = DARK_TEXT_COLOR;
} }
emit backgroundColorChanged(m_backgroundColor); emit backgroundColorChanged();
emit contrastAccentColorChanged(m_contrastAccentColor); emit contrastAccentColorChanged();
emit darkerPrimaryColorChanged(m_darkerPrimaryColor); emit darkerPrimaryColorChanged();
emit darkerPrimaryTextColorChanged(m_darkerPrimaryTextColor); emit darkerPrimaryTextColorChanged();
emit drawerColorChanged(m_drawerColor); emit drawerColorChanged();
emit lightDrawerColorChanged(m_lightDrawerColor); emit lightDrawerColorChanged();
emit lightPrimaryColorChanged(m_lightPrimaryColor); emit lightPrimaryColorChanged();
emit lightPrimaryTextColorChanged(m_lightPrimaryTextColor); emit lightPrimaryTextColorChanged();
emit primaryColorChanged(m_primaryColor); emit primaryColorChanged();
emit primaryTextColorChanged(m_primaryTextColor); emit primaryTextColorChanged();
emit secondaryTextColorChanged(m_secondaryTextColor); emit secondaryTextColorChanged();
emit textColorChanged(m_textColor); emit textColorChanged();
} }

View file

@ -44,26 +44,26 @@ public slots:
void set_currentScale(double); void set_currentScale(double);
signals: signals:
void backgroundColorChanged(QColor); void backgroundColorChanged();
void contrastAccentColorChanged(QColor); void contrastAccentColorChanged();
void darkerPrimaryColorChanged(QColor); void darkerPrimaryColorChanged();
void darkerPrimaryTextColorChanged(QColor); void darkerPrimaryTextColorChanged();
void drawerColorChanged(QColor); void drawerColorChanged();
void lightDrawerColorChanged(QColor); void lightDrawerColorChanged();
void lightPrimaryColorChanged(QColor); void lightPrimaryColorChanged();
void lightPrimaryTextColorChanged(QColor); void lightPrimaryTextColorChanged();
void primaryColorChanged(QColor); void primaryColorChanged();
void primaryTextColorChanged(QColor); void primaryTextColorChanged();
void secondaryTextColorChanged(QColor); void secondaryTextColorChanged();
void textColorChanged(QColor); void textColorChanged();
void headingPointSizeChanged(double); void headingPointSizeChanged();
void regularPointSizeChanged(double); void regularPointSizeChanged();
void smallPointSizeChanged(double); void smallPointSizeChanged();
void titlePointSizeChanged(double); void titlePointSizeChanged();
void currentScaleChanged(double); void currentScaleChanged();
void currentThemeChanged(const QString &); void currentThemeChanged();
private: private:
ThemeInterface() {} ThemeInterface() {}