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:
parent
15dbd1055a
commit
89b74a5231
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -176,6 +176,7 @@ Q_SIGNALS:
|
|||
|
||||
private Q_SLOTS:
|
||||
void chooseFile();
|
||||
void editingFinished();
|
||||
|
||||
private:
|
||||
QLineEdit *lineEdit;
|
||||
|
|
Loading…
Reference in New Issue
Block a user