GUI: improve App::PropertyPath directory selector

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>
This commit is contained in:
Przemo Firszt
2015-10-20 11:39:21 +01:00
committed by wmayer
parent cf4e7167d7
commit a4c8a562ff
2 changed files with 12 additions and 0 deletions

View File

@@ -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(" ... ")));
@@ -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.
*/

View File

@@ -176,6 +176,7 @@ Q_SIGNALS:
private Q_SLOTS:
void chooseFile();
void editingFinished();
private:
QLineEdit *lineEdit;