Utils: Skip roundtrip through QUrl in FileCrumbLabel

Change-Id: I4796070ef2a3bb0b4d778c5b0db224574dbf4823
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
hjk
2022-12-13 08:35:55 +01:00
parent dbaade3b47
commit 89403daf4e

View File

@@ -6,9 +6,6 @@
#include "filepath.h" #include "filepath.h"
#include "hostosinfo.h" #include "hostosinfo.h"
#include <QDir>
#include <QUrl>
namespace Utils { namespace Utils {
FileCrumbLabel::FileCrumbLabel(QWidget *parent) FileCrumbLabel::FileCrumbLabel(QWidget *parent)
@@ -16,17 +13,15 @@ FileCrumbLabel::FileCrumbLabel(QWidget *parent)
{ {
setTextFormat(Qt::RichText); setTextFormat(Qt::RichText);
setWordWrap(true); setWordWrap(true);
connect(this, &QLabel::linkActivated, this, [this](const QString &url) { connect(this, &QLabel::linkActivated, this, [this](const QString &filePath) {
emit pathClicked(FilePath::fromUrl(QUrl(url))); emit pathClicked(FilePath::fromString(filePath));
}); });
setPath(FilePath()); setPath(FilePath());
} }
static QString linkForPath(const FilePath &path, const QString &display) static QString linkForPath(const FilePath &path, const QString &display)
{ {
return "<a href=\"" return "<a href=\"" + path.toFSPathString() + "\">" + display + "</a>";
+ path.toUrl().toString(QUrl::FullyEncoded) + "\">"
+ display + "</a>";
} }
void FileCrumbLabel::setPath(const FilePath &path) void FileCrumbLabel::setPath(const FilePath &path)