forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/4.7'
Change-Id: I4332eba9f1f66fef185359c79c4d96420d8b78ca
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include "pathchooser.h"
|
||||
|
||||
#include "environment.h"
|
||||
#include "optional.h"
|
||||
#include "qtcassert.h"
|
||||
|
||||
#include "synchronousprocess.h"
|
||||
@@ -340,14 +341,22 @@ QString PathChooser::expandedDirectory(const QString &input, const Environment &
|
||||
return path;
|
||||
}
|
||||
|
||||
void setTextKeepingActiveCursor(QLineEdit *edit, const QString &text)
|
||||
{
|
||||
optional<int> cursor = edit->hasFocus() ? make_optional(edit->cursorPosition()) : nullopt;
|
||||
edit->setText(text);
|
||||
if (cursor)
|
||||
edit->setCursorPosition(*cursor);
|
||||
}
|
||||
|
||||
void PathChooser::setPath(const QString &path)
|
||||
{
|
||||
d->m_lineEdit->setText(QDir::toNativeSeparators(path));
|
||||
setTextKeepingActiveCursor(d->m_lineEdit, QDir::toNativeSeparators(path));
|
||||
}
|
||||
|
||||
void PathChooser::setFileName(const FileName &fn)
|
||||
{
|
||||
d->m_lineEdit->setText(fn.toUserOutput());
|
||||
setTextKeepingActiveCursor(d->m_lineEdit, fn.toUserOutput());
|
||||
}
|
||||
|
||||
void PathChooser::setErrorColor(const QColor &errorColor)
|
||||
|
||||
Reference in New Issue
Block a user