Add (and use) a LinkLabel component

The component, which is deliberately very simple. just adds the
functionality to Label of ensuring we have a hand cursor when
hovering over a link in the Label component. This is required
due to missing functionality in both Text and QCC2's Label
components, which have no mouse cursor changing abilities. There
is a Qt bug regarding the issue, mentioned in this new
component's code, but so far it looks unlikely to get a "real"
fix anytime soon, so, for less headachiness, this component
(which simply takes code we already had in one place and
applies it slightly more widely and generically)...

BUG:404309
Differential Revision: https://phabricator.kde.org/D19118
parent 1005d45e
......@@ -171,20 +171,12 @@ DiscoverPage {
Layout.fillWidth: true
}
Label {
LinkLabel {
Layout.topMargin: Kirigami.Units.largeSpacing
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 {
......
/*
* Copyright (C) 2019 Dan Leinir Turthra Jensen <admin@leinir.dk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library/Lesser General Public License
* version 2, or (at your option) any later version, as published by the
* Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library/Lesser General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.5
import QtQuick.Controls 2.3
/**
* A label which adds showing a hand cursor if there is a link being hovered in
* the text set on the label.
*/
Label {
// 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
}
}
......@@ -64,7 +64,7 @@ ColumnLayout
text: usefulnessToString(usefulnessFavorable, usefulnessTotal)
}
Label {
LinkLabel {
visible: !item.compact
Layout.alignment: Qt.AlignRight
text: {
......
......@@ -253,7 +253,7 @@ DiscoverPage
Layout.fillWidth: true
implicitHeight: view.contentHeight
visible: layout.extended && changelog.length>0
Label {
LinkLabel {
id: view
anchors {
right: parent.right
......
......@@ -33,6 +33,7 @@
<file>qml/Shadow.qml</file>
<file>qml/DiscoverPopup.qml</file>
<file>qml/AboutPage.qml</file>
<file>qml/LinkLabel.qml</file>
<file>qml/navigation.js</file>
</qresource>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment