Plugin settings (weather & lunch) #74

Merged
0xFEEDC0DE64 merged 15 commits from plugin-settings into master 2018-03-13 08:35:57 +01:00
15 changed files with 190 additions and 51 deletions
Showing only changes of commit 18be548da2 - Show all commits

View File

@@ -15,6 +15,14 @@ WeatherSettings::WeatherSettings(QWidget *parent) :
setLayout(layout);
}
bool WeatherSettings::isValid(QString &message) const
{
Q_UNUSED(message)
qDebug() << "called";
return true;
}
void WeatherSettings::apply()
{
qDebug() << "called";

View File

@@ -11,6 +11,8 @@ class WeatherSettings : public SettingsWidget
public:
explicit WeatherSettings(QWidget *parent = Q_NULLPTR);
bool isValid(QString &message) const Q_DECL_OVERRIDE;
public Q_SLOTS:
void apply() Q_DECL_OVERRIDE;
};

View File

@@ -72,10 +72,21 @@ void SettingsDialog::submit()
return;
}
for(const auto widget : m_settingsWidgets)
{
QString message;
if(!widget->isValid(message))
{
QMessageBox::warning(this, tr("Invalid settings!"), tr("Invalid settings!") % "\n\n" % message);
return;
}
}
if(ui->comboBoxLanguage->currentData().value<QLocale::Language>() != m_settings.language())
{
m_settings.setLanguage(ui->comboBoxLanguage->currentData().value<QLocale::Language>());
warning = true;
//TODO #73 Allow changing of the language without restart
QMessageBox::information(this, tr("Restart required!"), tr("To apply the new settings a restart is required!"));
}
auto theme = ui->comboBoxTheme->currentData().toString();
@@ -108,8 +119,8 @@ void SettingsDialog::submit()
m_settings.setTheme(theme);
}
if(warning)
QMessageBox::information(this, tr("Restart required!"), tr("To apply the new settings a restart is required!"));
for(const auto widget : m_settingsWidgets)
widget->apply();
accept();
}

View File

@@ -12,6 +12,8 @@ class ZEITERFASSUNGGUILIBSHARED_EXPORT SettingsWidget : public QWidget
public:
explicit SettingsWidget(QWidget *parent = Q_NULLPTR);
virtual bool isValid(QString &message) const { Q_UNUSED(message) return true; }
public Q_SLOTS:
virtual void apply() { }
};