Checking config access errors in settings.

This commit is contained in:
Louis-Bertrand Varin 2017-03-18 14:00:31 -04:00
parent e6b4528028
commit a3840963e1

View File

@ -99,6 +99,12 @@ void SettingsWidget::addSettingsPage(ISettingsPage* page)
void SettingsWidget::loadSettings() void SettingsWidget::loadSettings()
{ {
if (config()->hasAccessError()) {
showMessage(
tr("Access error for config file ") + config()->getFileName(), MessageWidget::Error);
}
m_generalUi->rememberLastDatabasesCheckBox->setChecked(config()->get("RememberLastDatabases").toBool()); m_generalUi->rememberLastDatabasesCheckBox->setChecked(config()->get("RememberLastDatabases").toBool());
m_generalUi->rememberLastKeyFilesCheckBox->setChecked(config()->get("RememberLastKeyFiles").toBool()); m_generalUi->rememberLastKeyFilesCheckBox->setChecked(config()->get("RememberLastKeyFiles").toBool());
m_generalUi->openPreviousDatabasesOnStartupCheckBox->setChecked( m_generalUi->openPreviousDatabasesOnStartupCheckBox->setChecked(
@ -154,6 +160,15 @@ void SettingsWidget::loadSettings()
void SettingsWidget::saveSettings() void SettingsWidget::saveSettings()
{ {
if (config()->hasAccessError()) {
showMessage(
tr("Access error for config file ") + config()->getFileName(), MessageWidget::Error);
// We prevent closing the settings page if we could not write to
// the config file.
return;
}
config()->set("RememberLastDatabases", m_generalUi->rememberLastDatabasesCheckBox->isChecked()); config()->set("RememberLastDatabases", m_generalUi->rememberLastDatabasesCheckBox->isChecked());
config()->set("RememberLastKeyFiles", m_generalUi->rememberLastKeyFilesCheckBox->isChecked()); config()->set("RememberLastKeyFiles", m_generalUi->rememberLastKeyFilesCheckBox->isChecked());
config()->set("OpenPreviousDatabasesOnStartup", config()->set("OpenPreviousDatabasesOnStartup",