forked from qt-creator/qt-creator
Utils: Change macro expander to use FilePath
Change-Id: Ib7787d1b7f72f6b4728893636f6844e4297fcecd Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -377,40 +377,44 @@ void MacroExpander::registerIntVariable(const QByteArray &variable,
|
|||||||
void MacroExpander::registerFileVariables(const QByteArray &prefix,
|
void MacroExpander::registerFileVariables(const QByteArray &prefix,
|
||||||
const QString &heading, const FileFunction &base, bool visibleInChooser)
|
const QString &heading, const FileFunction &base, bool visibleInChooser)
|
||||||
{
|
{
|
||||||
registerVariable(prefix + kFilePathPostfix,
|
registerVariable(
|
||||||
|
prefix + kFilePathPostfix,
|
||||||
Tr::tr("%1: Full path including file name.").arg(heading),
|
Tr::tr("%1: Full path including file name.").arg(heading),
|
||||||
[base]() -> QString { QString tmp = base().toString(); return tmp.isEmpty() ? QString() : QFileInfo(tmp).filePath(); },
|
[base]() -> QString { return base().toUserOutput(); },
|
||||||
visibleInChooser);
|
visibleInChooser);
|
||||||
|
|
||||||
registerVariable(prefix + kPathPostfix,
|
registerVariable(
|
||||||
|
prefix + kPathPostfix,
|
||||||
Tr::tr("%1: Full path excluding file name.").arg(heading),
|
Tr::tr("%1: Full path excluding file name.").arg(heading),
|
||||||
[base]() -> QString { QString tmp = base().toString(); return tmp.isEmpty() ? QString() : QFileInfo(tmp).path(); },
|
[base]() -> QString { return base().parentDir().toUserOutput(); },
|
||||||
visibleInChooser);
|
visibleInChooser);
|
||||||
|
|
||||||
registerVariable(prefix + kNativeFilePathPostfix,
|
registerVariable(
|
||||||
Tr::tr("%1: Full path including file name, with native path separator (backslash on Windows).").arg(heading),
|
prefix + kNativeFilePathPostfix,
|
||||||
[base]() -> QString {
|
Tr::tr(
|
||||||
QString tmp = base().toString();
|
"%1: Full path including file name, with native path separator (backslash on Windows).")
|
||||||
return tmp.isEmpty() ? QString() : QDir::toNativeSeparators(QFileInfo(tmp).filePath());
|
.arg(heading),
|
||||||
},
|
[base]() -> QString { return base().nativePath(); },
|
||||||
visibleInChooser);
|
visibleInChooser);
|
||||||
|
|
||||||
registerVariable(prefix + kNativePathPostfix,
|
registerVariable(
|
||||||
Tr::tr("%1: Full path excluding file name, with native path separator (backslash on Windows).").arg(heading),
|
prefix + kNativePathPostfix,
|
||||||
[base]() -> QString {
|
Tr::tr(
|
||||||
QString tmp = base().toString();
|
"%1: Full path excluding file name, with native path separator (backslash on Windows).")
|
||||||
return tmp.isEmpty() ? QString() : QDir::toNativeSeparators(QFileInfo(tmp).path());
|
.arg(heading),
|
||||||
},
|
[base]() -> QString { return base().parentDir().nativePath(); },
|
||||||
visibleInChooser);
|
visibleInChooser);
|
||||||
|
|
||||||
registerVariable(prefix + kFileNamePostfix,
|
registerVariable(
|
||||||
|
prefix + kFileNamePostfix,
|
||||||
Tr::tr("%1: File name without path.").arg(heading),
|
Tr::tr("%1: File name without path.").arg(heading),
|
||||||
[base]() -> QString { QString tmp = base().toString(); return tmp.isEmpty() ? QString() : FilePath::fromString(tmp).fileName(); },
|
[base]() -> QString { return base().fileName(); },
|
||||||
visibleInChooser);
|
visibleInChooser);
|
||||||
|
|
||||||
registerVariable(prefix + kFileBaseNamePostfix,
|
registerVariable(
|
||||||
|
prefix + kFileBaseNamePostfix,
|
||||||
Tr::tr("%1: File base name without path and suffix.").arg(heading),
|
Tr::tr("%1: File base name without path and suffix.").arg(heading),
|
||||||
[base]() -> QString { QString tmp = base().toString(); return tmp.isEmpty() ? QString() : QFileInfo(tmp).baseName(); },
|
[base]() -> QString { return base().baseName(); },
|
||||||
visibleInChooser);
|
visibleInChooser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user