diff --git a/discover/qml/ApplicationPage.qml b/discover/qml/ApplicationPage.qml --- a/discover/qml/ApplicationPage.qml +++ b/discover/qml/ApplicationPage.qml @@ -157,6 +157,15 @@ Layout.fillWidth: true wrapMode: Text.WordWrap text: appInfo.application.longDescription + onLinkActivated: Qt.openUrlExternally(link); + // Since Text (and Label) lack cursor-changing abilities of their own, + // as suggested by QTBUG-30804, use a MouseAra to do our dirty work. + // See comment https://bugreports.qt.io/browse/QTBUG-30804?#comment-206287 + MouseArea { + anchors.fill: parent + cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor + acceptedButtons: Qt.NoButton // Not actually accepting clicks, just changing the cursor + } } Kirigami.Heading { diff --git a/libdiscover/backends/KNSBackend/KNSResource.cpp b/libdiscover/backends/KNSBackend/KNSResource.cpp --- a/libdiscover/backends/KNSBackend/KNSResource.cpp +++ b/libdiscover/backends/KNSBackend/KNSResource.cpp @@ -79,7 +79,7 @@ if(newLine>0) { ret=ret.left(newLine); } - ret = ret.replace(QRegularExpression(QStringLiteral("\\[/?[a-z]*\\]")), QString()); + ret = ret.replace(QRegularExpression(QStringLiteral("\\[\\/?[a-z]*\\]")), QString()); ret = ret.remove(QRegularExpression(QStringLiteral("<[^>]*>"))); } return ret; @@ -97,7 +97,12 @@ } ret = ret.replace(QLatin1Char('\r'), QString()); ret = ret.replace(QStringLiteral("[li]"), QStringLiteral("\n* ")); - ret = ret.replace(QRegularExpression(QStringLiteral("\\[/?[a-z]*\\]")), QString()); + // Get rid of all BBCode markup we don't handle above + ret = ret.replace(QRegularExpression(QStringLiteral("\\[\\/?[a-z]*\\]")), QString()); + // Find anything that looks like a link (but which also is not some html + // tag value or another already) and make it a link + static const QRegularExpression urlRegExp(QStringLiteral("(^|\\s)([-a-zA-Z0-9@:%_\\+.~#?&//=]{2,256}\\.[a-z]{2,4}\\b(\\/[-a-zA-Z0-9@:;%_\\+.~#?&//=]*)?)"), QRegularExpression::CaseInsensitiveOption); + ret = ret.replace(urlRegExp, QStringLiteral("\\2")); return ret; }