Handle cancel in PreferencesDialog::on_chooseFile_clicked

If I click in the Preferences Dialog on the 3 dots to choose a default
file to load and cancel the opening FileDialog an empty string is returned
and set to the coresponding QLineEdit.

The new behavior (and mostly expected) is to update the QLineEdit only
if there is a filename returned from QFileDialog.

Signed-off-by: Patrick Majewski <dive@patrick-majewski.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Patrick Majewski 2014-02-11 19:49:56 +01:00 committed by Dirk Hohndel
parent b839cd4cb0
commit 936ac958ed

View file

@ -307,7 +307,10 @@ void PreferencesDialog::buttonClicked(QAbstractButton* button)
void PreferencesDialog::on_chooseFile_clicked()
{
QFileInfo fi(system_default_filename());
ui.defaultfilename->setText(QFileDialog::getOpenFileName(this, tr("Open Default Log File"), fi.absolutePath(), tr("Subsurface XML files (*.ssrf *.xml *.XML)")));
QString choosenFileName = QFileDialog::getOpenFileName(this, tr("Open Default Log File"), fi.absolutePath(), tr("Subsurface XML files (*.ssrf *.xml *.XML)"));
if(!choosenFileName.isEmpty())
ui.defaultfilename->setText(choosenFileName);
}
void PreferencesDialog::emitSettingsChanged()