Plugin settings (weather & lunch) #74
@@ -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";
|
||||
|
@@ -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;
|
||||
};
|
||||
|
@@ -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();
|
||||
}
|
||||
|
@@ -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() { }
|
||||
};
|
||||
|
Reference in New Issue
Block a user