From 936ac958ede81de4042a5e50a8e73997d1d29232 Mon Sep 17 00:00:00 2001 From: Patrick Majewski Date: Tue, 11 Feb 2014 19:49:56 +0100 Subject: 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 Signed-off-by: Dirk Hohndel --- qt-ui/preferences.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'qt-ui') diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp index 5969a2d47..f3a88fcd3 100644 --- a/qt-ui/preferences.cpp +++ b/qt-ui/preferences.cpp @@ -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() -- cgit v1.2.3-70-g09d2