xconfig: Abort close if configuration cannot be saved
Give the user an opportunity to fix the error or save the configuration under a different path. Reported-by: Hiromu Yakura <hiromu1996@gmail.com> Signed-off-by: Michal Marek <mmarek@suse.cz>
This commit is contained in:
parent
eb4cf5a642
commit
bac6aa865b
2 changed files with 11 additions and 4 deletions
|
@ -1478,10 +1478,13 @@ void ConfigMainWindow::loadConfig(void)
|
||||||
ConfigView::updateListAll();
|
ConfigView::updateListAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigMainWindow::saveConfig(void)
|
bool ConfigMainWindow::saveConfig(void)
|
||||||
{
|
{
|
||||||
if (conf_write(NULL))
|
if (conf_write(NULL)) {
|
||||||
QMessageBox::information(this, "qconf", _("Unable to save configuration!"));
|
QMessageBox::information(this, "qconf", _("Unable to save configuration!"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigMainWindow::saveConfigAs(void)
|
void ConfigMainWindow::saveConfigAs(void)
|
||||||
|
@ -1642,7 +1645,11 @@ void ConfigMainWindow::closeEvent(QCloseEvent* e)
|
||||||
mb.setButtonText(QMessageBox::Cancel, _("Cancel Exit"));
|
mb.setButtonText(QMessageBox::Cancel, _("Cancel Exit"));
|
||||||
switch (mb.exec()) {
|
switch (mb.exec()) {
|
||||||
case QMessageBox::Yes:
|
case QMessageBox::Yes:
|
||||||
saveConfig();
|
if (saveConfig())
|
||||||
|
e->accept();
|
||||||
|
else
|
||||||
|
e->ignore();
|
||||||
|
break;
|
||||||
case QMessageBox::No:
|
case QMessageBox::No:
|
||||||
e->accept();
|
e->accept();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -311,7 +311,7 @@ public slots:
|
||||||
void listFocusChanged(void);
|
void listFocusChanged(void);
|
||||||
void goBack(void);
|
void goBack(void);
|
||||||
void loadConfig(void);
|
void loadConfig(void);
|
||||||
void saveConfig(void);
|
bool saveConfig(void);
|
||||||
void saveConfigAs(void);
|
void saveConfigAs(void);
|
||||||
void searchConfig(void);
|
void searchConfig(void);
|
||||||
void showSingleView(void);
|
void showSingleView(void);
|
||||||
|
|
Loading…
Reference in a new issue