From 229fbee29883d8f8fd18c7dfffc7c1e214ec201d Mon Sep 17 00:00:00 2001 From: miruka Date: Sat, 11 Jul 2020 23:42:49 -0400 Subject: [PATCH] Remove HRichLabel component Sparsly used and inflexible, just use HLabel --- src/gui/Base/HLabel.qml | 2 ++ src/gui/Base/HRichLabel.qml | 16 ---------------- src/gui/Base/HSelectableLabel.qml | 1 - src/gui/Base/HTile/SubtitleLabel.qml | 15 ++++++++++----- src/gui/Pages/Chat/RoomHeader.qml | 9 ++++++++- 5 files changed, 20 insertions(+), 23 deletions(-) delete mode 100644 src/gui/Base/HRichLabel.qml diff --git a/src/gui/Base/HLabel.qml b/src/gui/Base/HLabel.qml index 49c5024b..50dd865d 100644 --- a/src/gui/Base/HLabel.qml +++ b/src/gui/Base/HLabel.qml @@ -13,4 +13,6 @@ Label { linkColor: theme.colors.link maximumLineCount: elide === Label.ElideNone ? Number.MAX_VALUE : 1 + + onLinkActivated: Qt.openUrlExternally(link) } diff --git a/src/gui/Base/HRichLabel.qml b/src/gui/Base/HRichLabel.qml deleted file mode 100644 index ba9f3bc7..00000000 --- a/src/gui/Base/HRichLabel.qml +++ /dev/null @@ -1,16 +0,0 @@ -// SPDX-License-Identifier: LGPL-3.0-or-later - -import QtQuick 2.12 - -HLabel { - // https://blog.shantanu.io/2015/02/15/creating-working-hyperlinks-in-qtquick-text/ - id: label - textFormat: Text.RichText - onLinkActivated: Qt.openUrlExternally(link) - - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.NoButton - cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor - } -} diff --git a/src/gui/Base/HSelectableLabel.qml b/src/gui/Base/HSelectableLabel.qml index a2b3fb5c..40c23cc8 100644 --- a/src/gui/Base/HSelectableLabel.qml +++ b/src/gui/Base/HSelectableLabel.qml @@ -16,7 +16,6 @@ TextEdit { activeFocusOnPress: false focus: false selectByMouse: true - onLinkActivated: if (enableLinkActivation) Qt.openUrlExternally(link) diff --git a/src/gui/Base/HTile/SubtitleLabel.qml b/src/gui/Base/HTile/SubtitleLabel.qml index 2db578c3..5cca552c 100644 --- a/src/gui/Base/HTile/SubtitleLabel.qml +++ b/src/gui/Base/HTile/SubtitleLabel.qml @@ -4,7 +4,9 @@ import QtQuick 2.12 import QtQuick.Layouts 1.12 import ".." -HRichLabel { +HLabel { + property HTile tile + textFormat: Text.StyledText font.pixelSize: theme.fontSize.small verticalAlignment: Qt.AlignVCenter @@ -16,9 +18,12 @@ HRichLabel { Layout.fillWidth: true Layout.fillHeight: true - - property HTile tile - - Behavior on Layout.maximumHeight { HNumberAnimation {} } + + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.NoButton + cursorShape: + parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor + } } diff --git a/src/gui/Pages/Chat/RoomHeader.qml b/src/gui/Pages/Chat/RoomHeader.qml index 9373a669..678d3564 100644 --- a/src/gui/Pages/Chat/RoomHeader.qml +++ b/src/gui/Pages/Chat/RoomHeader.qml @@ -79,7 +79,7 @@ Rectangle { HoverHandler { id: nameHover } } - HRichLabel { + HLabel { id: topicLabel text: chat.roomInfo.topic textFormat: Text.StyledText @@ -103,6 +103,13 @@ Rectangle { Layout.fillHeight: true HoverHandler { id: topicHover } + + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.NoButton + cursorShape: + parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor + } } HToolTip {