Added isValid() to SettingsWidget
This commit is contained in:
@@ -15,6 +15,14 @@ WeatherSettings::WeatherSettings(QWidget *parent) :
|
|||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WeatherSettings::isValid(QString &message) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(message)
|
||||||
|
|
||||||
|
qDebug() << "called";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void WeatherSettings::apply()
|
void WeatherSettings::apply()
|
||||||
{
|
{
|
||||||
qDebug() << "called";
|
qDebug() << "called";
|
||||||
|
@@ -11,6 +11,8 @@ class WeatherSettings : public SettingsWidget
|
|||||||
public:
|
public:
|
||||||
explicit WeatherSettings(QWidget *parent = Q_NULLPTR);
|
explicit WeatherSettings(QWidget *parent = Q_NULLPTR);
|
||||||
|
|
||||||
|
bool isValid(QString &message) const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void apply() Q_DECL_OVERRIDE;
|
void apply() Q_DECL_OVERRIDE;
|
||||||
};
|
};
|
||||||
|
@@ -72,10 +72,21 @@ void SettingsDialog::submit()
|
|||||||
return;
|
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())
|
if(ui->comboBoxLanguage->currentData().value<QLocale::Language>() != m_settings.language())
|
||||||
{
|
{
|
||||||
m_settings.setLanguage(ui->comboBoxLanguage->currentData().value<QLocale::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();
|
auto theme = ui->comboBoxTheme->currentData().toString();
|
||||||
@@ -108,8 +119,8 @@ void SettingsDialog::submit()
|
|||||||
m_settings.setTheme(theme);
|
m_settings.setTheme(theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(warning)
|
for(const auto widget : m_settingsWidgets)
|
||||||
QMessageBox::information(this, tr("Restart required!"), tr("To apply the new settings a restart is required!"));
|
widget->apply();
|
||||||
|
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
|
@@ -12,6 +12,8 @@ class ZEITERFASSUNGGUILIBSHARED_EXPORT SettingsWidget : public QWidget
|
|||||||
public:
|
public:
|
||||||
explicit SettingsWidget(QWidget *parent = Q_NULLPTR);
|
explicit SettingsWidget(QWidget *parent = Q_NULLPTR);
|
||||||
|
|
||||||
|
virtual bool isValid(QString &message) const { Q_UNUSED(message) return true; }
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
virtual void apply() { }
|
virtual void apply() { }
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user