mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Merge pull request #391 from louib/fix/checkPermissions
Adding warning messages when config access error.
This commit is contained in:
commit
7608405a1f
@ -35,6 +35,16 @@ QVariant Config::get(const QString& key, const QVariant& defaultValue)
|
||||
return m_settings->value(key, defaultValue);
|
||||
}
|
||||
|
||||
bool Config::hasAccessError()
|
||||
{
|
||||
return m_settings->status() & QSettings::AccessError;
|
||||
}
|
||||
|
||||
QString Config::getFileName()
|
||||
{
|
||||
return m_settings->fileName();
|
||||
}
|
||||
|
||||
void Config::set(const QString& key, const QVariant& value)
|
||||
{
|
||||
m_settings->setValue(key, value);
|
||||
|
@ -31,7 +31,9 @@ public:
|
||||
~Config();
|
||||
QVariant get(const QString& key);
|
||||
QVariant get(const QString& key, const QVariant& defaultValue);
|
||||
QString getFileName();
|
||||
void set(const QString& key, const QVariant& value);
|
||||
bool hasAccessError();
|
||||
|
||||
static Config* instance();
|
||||
static void createConfigFromFile(const QString& file);
|
||||
|
@ -314,6 +314,12 @@ MainWindow::MainWindow()
|
||||
connect(m_ui->tabWidget, SIGNAL(messageDismissTab()), this, SLOT(hideTabMessage()));
|
||||
|
||||
updateTrayIcon();
|
||||
|
||||
if (config()->hasAccessError()) {
|
||||
m_ui->globalMessageWidget->showMessage(
|
||||
tr("Access error for config file %1").arg(config()->getFileName()), MessageWidget::Error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
@ -68,7 +68,7 @@ SettingsWidget::SettingsWidget(QWidget* parent)
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
// systray not useful on OS X
|
||||
m_generalUi->systraySettings->setVisible(false);
|
||||
m_generalUi->systraySettings->setVisible(false);
|
||||
#endif
|
||||
|
||||
connect(this, SIGNAL(accepted()), SLOT(saveSettings()));
|
||||
@ -99,6 +99,12 @@ void SettingsWidget::addSettingsPage(ISettingsPage* page)
|
||||
|
||||
void SettingsWidget::loadSettings()
|
||||
{
|
||||
|
||||
if (config()->hasAccessError()) {
|
||||
showMessage(
|
||||
tr("Access error for config file %1").arg(config()->getFileName()), MessageWidget::Error);
|
||||
}
|
||||
|
||||
m_generalUi->rememberLastDatabasesCheckBox->setChecked(config()->get("RememberLastDatabases").toBool());
|
||||
m_generalUi->rememberLastKeyFilesCheckBox->setChecked(config()->get("RememberLastKeyFiles").toBool());
|
||||
m_generalUi->openPreviousDatabasesOnStartupCheckBox->setChecked(
|
||||
@ -154,6 +160,15 @@ void SettingsWidget::loadSettings()
|
||||
|
||||
void SettingsWidget::saveSettings()
|
||||
{
|
||||
|
||||
if (config()->hasAccessError()) {
|
||||
showMessage(
|
||||
tr("Access error for config file %1").arg(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("RememberLastKeyFiles", m_generalUi->rememberLastKeyFilesCheckBox->isChecked());
|
||||
config()->set("OpenPreviousDatabasesOnStartup",
|
||||
|
Loading…
Reference in New Issue
Block a user