forked from qt-creator/qt-creator
Utils: Introduce a OsSpecificAspect::pathWithNativeSeparators(QString)
... and use it in the ExecutableAspect implementation. Change-Id: I0d242d9969323e495e16997e1ca46cfc10e8eb4b Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -29,6 +29,8 @@
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#define QTC_WIN_EXE_SUFFIX ".exe"
|
||||
|
||||
namespace Utils {
|
||||
@@ -60,6 +62,18 @@ public:
|
||||
return m_osType == OsTypeMac ? Qt::MetaModifier : Qt::ControlModifier;
|
||||
}
|
||||
|
||||
QString pathWithNativeSeparators(const QString &pathName) const {
|
||||
if (m_osType == OsTypeWindows) {
|
||||
const int pos = pathName.indexOf('/');
|
||||
if (pos >= 0) {
|
||||
QString n = pathName;
|
||||
std::replace(std::begin(n) + pos, std::end(n), '/', '\\');
|
||||
return n;
|
||||
}
|
||||
}
|
||||
return pathName;
|
||||
}
|
||||
|
||||
private:
|
||||
const OsType m_osType;
|
||||
};
|
||||
|
@@ -461,29 +461,9 @@ ExecutableAspect::ExecutableAspect(RunConfiguration *rc)
|
||||
|
||||
void ExecutableAspect::setExecutablePathStyle(OsType osType)
|
||||
{
|
||||
if (osType == OsTypeWindows) {
|
||||
// Stolen from QDir::toNativeSeparators which cannot be used directly as it
|
||||
// depends on host type, whereas we need a configurable value here.
|
||||
m_executable.setDisplayFilter([&](const QString &pathName) {
|
||||
int i = pathName.indexOf(QLatin1Char('/'));
|
||||
if (i != -1) {
|
||||
QString n(pathName);
|
||||
|
||||
QChar * const data = n.data();
|
||||
data[i++] = QLatin1Char('\\');
|
||||
|
||||
for (; i < n.length(); ++i) {
|
||||
if (data[i] == QLatin1Char('/'))
|
||||
data[i] = QLatin1Char('\\');
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
return pathName;
|
||||
});
|
||||
} else {
|
||||
m_executable.setDisplayFilter({});
|
||||
}
|
||||
m_executable.setDisplayFilter([osType](const QString &pathName) {
|
||||
return OsSpecificAspects(osType).pathWithNativeSeparators(pathName);
|
||||
});
|
||||
}
|
||||
|
||||
void ExecutableAspect::makeOverridable(const QString &overridingKey, const QString &useOverridableKey)
|
||||
|
Reference in New Issue
Block a user