Skip to content

Commit

Permalink
GUI: improve App::PropertyPath directory selector
Browse files Browse the repository at this point in the history
Editing direcotry in lineEdit was open to escaped character problems
i.e. \t or \n which can be pert of notmal directory path were converted
to tab or new line. Also leaving the lineEdit without hitting Enter was
discarding changes.

Signed-off-by: Przemo Firszt <przemo@firszt.eu>
  • Loading branch information
PrzemoF authored and wwmayer committed Oct 25, 2015
1 parent 15dbd10 commit 89b74a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Gui/FileDialog.cpp
Expand Up @@ -534,6 +534,8 @@ FileChooser::FileChooser ( QWidget * parent )

connect(lineEdit, SIGNAL(textChanged(const QString &)),
this, SIGNAL(fileNameChanged(const QString &)));

connect(lineEdit, SIGNAL(editingFinished()), this, SLOT(editingFinished()));

button = new QPushButton(QLatin1String("..."), this);
button->setFixedWidth(2*button->fontMetrics().width(QLatin1String(" ... ")));
Expand Down Expand Up @@ -561,6 +563,15 @@ QString FileChooser::fileName() const
return lineEdit->text();
}

void FileChooser::editingFinished()
{
QString le_converted = lineEdit->text();
le_converted.replace(QString::fromStdString("\\"), QString::fromStdString("/"));
lineEdit->setText(le_converted);
FileDialog::setWorkingDirectory(le_converted);
fileNameSelected(le_converted);
}

/**
* Sets the file name \a s.
*/
Expand Down
1 change: 1 addition & 0 deletions src/Gui/FileDialog.h
Expand Up @@ -176,6 +176,7 @@ public Q_SLOTS:

private Q_SLOTS:
void chooseFile();
void editingFinished();

private:
QLineEdit *lineEdit;
Expand Down

0 comments on commit 89b74a5

Please sign in to comment.