forked from qt-creator/qt-creator
ProjectExplorer: Show recent projects with native paths
The paths in the "Recent Projects" menu, in the recent projects list on the welcome screen and those in the sessions list on the welcome screen were shown with non-natice directory separators on Windows. This fixes it for project FilePaths with osType() == OsTypeWindows Change-Id: I26afd56a82e32992f04bb3f2f1e2c1e767208ce5 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -3340,8 +3340,11 @@ void ProjectExplorerPluginPrivate::updateRecentProjectMenu()
|
||||
if (filePath.endsWith(QLatin1String(".qws")))
|
||||
continue;
|
||||
|
||||
const QString actionText = ActionManager::withNumberAccelerator(
|
||||
filePath.withTildeHomePath(), acceleratorKey);
|
||||
const QString displayPath =
|
||||
filePath.osType() == OsTypeWindows ? filePath.displayName()
|
||||
: filePath.withTildeHomePath();
|
||||
const QString actionText =
|
||||
ActionManager::withNumberAccelerator(displayPath, acceleratorKey);
|
||||
QAction *action = menu->addAction(actionText);
|
||||
connect(action, &QAction::triggered, this, [this, filePath] {
|
||||
openRecentProject(filePath);
|
||||
|
@@ -335,9 +335,11 @@ public:
|
||||
yy += 18;
|
||||
|
||||
// Project path.
|
||||
QString pathWithTilde = projectPath.withTildeHomePath();
|
||||
const QString displayPath =
|
||||
projectPath.osType() == OsTypeWindows ? projectPath.displayName()
|
||||
: projectPath.withTildeHomePath();
|
||||
painter->setPen(foregroundPrimaryColor);
|
||||
painter->drawText(x1, yy, fm.elidedText(pathWithTilde, Qt::ElideMiddle, textSpace));
|
||||
painter->drawText(x1, yy, fm.elidedText(displayPath, Qt::ElideMiddle, textSpace));
|
||||
yy += 22;
|
||||
}
|
||||
|
||||
@@ -486,10 +488,12 @@ public:
|
||||
|
||||
painter->setPen(themeColor(Theme::Welcome_ForegroundPrimaryColor));
|
||||
painter->setFont(sizedFont(13, option.widget));
|
||||
QString pathWithTilde = projectPath.withTildeHomePath();
|
||||
const QString pathWithTildeElided =
|
||||
painter->fontMetrics().elidedText(pathWithTilde, Qt::ElideMiddle, textSpace);
|
||||
painter->drawText(x + TEXT_OFFSET_HORIZONTAL, secondBase, pathWithTildeElided);
|
||||
const QString displayPath =
|
||||
projectPath.osType() == OsTypeWindows ? projectPath.displayName()
|
||||
: projectPath.withTildeHomePath();
|
||||
const QString displayPathElided =
|
||||
painter->fontMetrics().elidedText(displayPath, Qt::ElideMiddle, textSpace);
|
||||
painter->drawText(x + TEXT_OFFSET_HORIZONTAL, secondBase, displayPathElided);
|
||||
}
|
||||
|
||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &idx) const final
|
||||
|
Reference in New Issue
Block a user