diff --git a/plugins/lunchmealplugin/lunchmealsettingswidget.cpp b/plugins/lunchmealplugin/lunchmealsettingswidget.cpp index 2b43df6..a1edbb2 100644 --- a/plugins/lunchmealplugin/lunchmealsettingswidget.cpp +++ b/plugins/lunchmealplugin/lunchmealsettingswidget.cpp @@ -31,9 +31,6 @@ bool LunchMealSettingsWidget::isValid(QString &message) const void LunchMealSettingsWidget::apply() { - if(m_settings.url() != m_lineEditUrl->text()) - m_settings.setUrl(m_lineEditUrl->text()); - - if(m_settings.dateFormat() != m_lineEditDateFormat->text()) - m_settings.setDateFormat(m_lineEditDateFormat->text()); + m_settings.setUrl(m_lineEditUrl->text()); + m_settings.setDateFormat(m_lineEditDateFormat->text()); } diff --git a/plugins/weatherplugin/weathersettings.cpp b/plugins/weatherplugin/weathersettings.cpp index 52f4062..00ce224 100644 --- a/plugins/weatherplugin/weathersettings.cpp +++ b/plugins/weatherplugin/weathersettings.cpp @@ -2,6 +2,9 @@ #include "zeiterfassungsettings.h" +const QString WeatherSettings::m_url("WeatherPlugin/url"); +const QUrl WeatherSettings::m_defaultUrl(QStringLiteral("http://api.openweathermap.org/data/2.5/weather?q=Graz,AT&units=metric&APPID=40f6c892c6162680c6c9235169dc9f83")); + WeatherSettings::WeatherSettings(ZeiterfassungSettings &settings) : m_settings(settings) { @@ -10,12 +13,14 @@ WeatherSettings::WeatherSettings(ZeiterfassungSettings &settings) : QUrl WeatherSettings::url() const { - return m_settings.value(QStringLiteral("WeatherPlugin/url"), - QUrl(QStringLiteral("http://api.openweathermap.org/data/2.5/weather?q=Graz,AT&units=metric&APPID=40f6c892c6162680c6c9235169dc9f83"))) - .toUrl(); + return m_settings.value(m_url, m_defaultUrl).toUrl(); } void WeatherSettings::setUrl(const QUrl &url) { - m_settings.setValue(QStringLiteral("WeatherPlugin/url"), url); + if(this->url() != url) + { + m_settings.setValue(m_url, url); + Q_EMIT urlChanged(url); + } } diff --git a/plugins/weatherplugin/weathersettings.h b/plugins/weatherplugin/weathersettings.h index eaa0ff4..175bb2a 100644 --- a/plugins/weatherplugin/weathersettings.h +++ b/plugins/weatherplugin/weathersettings.h @@ -13,8 +13,14 @@ public: QUrl url() const; void setUrl(const QUrl &url); +Q_SIGNALS: + void urlChanged(const QUrl &url); + private: ZeiterfassungSettings &m_settings; + + static const QString m_url; + static const QUrl m_defaultUrl; }; #endif // WEATHERSETTINGS_H diff --git a/plugins/weatherplugin/weathersettingswidget.cpp b/plugins/weatherplugin/weathersettingswidget.cpp index 5be082a..2e14db6 100644 --- a/plugins/weatherplugin/weathersettingswidget.cpp +++ b/plugins/weatherplugin/weathersettingswidget.cpp @@ -28,7 +28,5 @@ bool WeatherSettingsWidget::isValid(QString &message) const void WeatherSettingsWidget::apply() { - auto url = QUrl::fromUserInput(m_lineEdit->text()); - if(m_settings.url() != url) - m_settings.setUrl(url); + m_settings.setUrl(QUrl::fromUserInput(m_lineEdit->text())); }