Port most of the selectable TextEdits to SelectableLabel

This fixes the selectable labels looking weird, makes them look native along with other goodies built-in to this Kirigami component. Also changes the links in the podcast description to use UrlButton.
This commit is contained in:
Joshua Goins 2025-01-30 14:12:51 +00:00 committed by Bart De Vries
parent 7472277a34
commit cdafdbe5b4
2 changed files with 24 additions and 68 deletions

View File

@ -223,7 +223,7 @@ Kirigami.ScrollablePage {
}
}
TextEdit {
Kirigami.SelectableLabel {
id: textLabel
Layout.topMargin: Kirigami.Units.gridUnit
Layout.leftMargin: Kirigami.Units.gridUnit
@ -232,14 +232,12 @@ Kirigami.ScrollablePage {
Layout.fillWidth: true
Layout.fillHeight: true
readOnly: true
selectByMouse: !kastsMainWindow.isMobile
text: page.entry.content
baseUrl: page.entry.baseUrl
textFormat: Text.RichText
wrapMode: Text.WordWrap
font.pointSize: SettingsManager && !(SettingsManager.articleFontUseSystem) ? SettingsManager.articleFontSize : Kirigami.Theme.defaultFont.pointSize
color: Kirigami.Theme.textColor
onLinkActivated: (link) => {
if (link.split("://")[0] === "timestamp") {
@ -257,9 +255,6 @@ Kirigami.ScrollablePage {
Qt.openUrlExternally(link)
}
}
onLinkHovered: {
cursorShape: Qt.PointingHandCursor;
}
onWidthChanged: { text = entry.adjustedContent(width, font.pixelSize) }
}

View File

@ -174,7 +174,7 @@ Kirigami.ScrollablePage {
text: i18n("Show Details")
checkable: true
checked: showMoreInfo
onCheckedChanged: {
onCheckedChanged: (checked) => {
showMoreInfo = checked;
}
}
@ -226,50 +226,25 @@ Kirigami.ScrollablePage {
lineHeight: 1.2
}
Item {
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop
Layout.preferredHeight: Math.max(feedUrlLayout.height, feedUrlCopyButton.width)
visible: page.showMoreInfo
height: visible ? implicitHeight : 0
RowLayout {
id: feedUrlLayout
anchors.left: parent.left
anchors.right: feedUrlCopyButton.left
anchors.verticalCenter: parent.verticalCenter
spacing: Kirigami.Units.smallSpacing
TextEdit {
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop
spacing: Kirigami.Units.smallSpacing
visible: page.showMoreInfo
Controls.Label {
Layout.alignment: Qt.AlignTop
readOnly: true
textFormat: TextEdit.RichText
text: i18n("Podcast URL:")
wrapMode: TextEdit.Wrap
color: Kirigami.Theme.textColor
}
TextEdit {
Kirigami.UrlButton {
id: feedUrl
Layout.alignment: Qt.AlignTop
readOnly: true
selectByMouse: !kastsMainWindow.isMobile
textFormat:TextEdit.RichText
text: "<a href='%1'>%1</a>".arg(feed.url)
url: feed.url
wrapMode: TextEdit.Wrap
horizontalAlignment: Text.AlignLeft
Layout.fillWidth: true
color: Kirigami.Theme.textColor
}
}
Controls.Button {
id: feedUrlCopyButton
anchors.right: parent.right
anchors.top: parent.top
anchors.leftMargin: Kirigami.Units.smallSpacing
icon.name: "edit-copy"
onClicked: {
feedUrl.selectAll();
feedUrl.copy();
feedUrl.deselect();
}
}
}
RowLayout {
@ -278,67 +253,53 @@ Kirigami.ScrollablePage {
visible: page.showMoreInfo
height: visible ? implicitHeight : 0
spacing: Kirigami.Units.smallSpacing
TextEdit {
Controls.Label {
Layout.alignment: Qt.AlignTop
readOnly: true
textFormat: TextEdit.RichText
text: i18n("Weblink:")
wrapMode: TextEdit.Wrap
color: Kirigami.Theme.textColor
}
TextEdit {
readOnly: true
Kirigami.UrlButton {
Layout.alignment: Qt.AlignTop
selectByMouse: !kastsMainWindow.isMobile
textFormat:TextEdit.RichText
text: "<a href='%1'>%1</a>".arg(feed.link)
onLinkActivated: (link) => {
Qt.openUrlExternally(link);
}
url: feed.link
wrapMode: Text.WordWrap
Layout.fillWidth: true
color: Kirigami.Theme.textColor
horizontalAlignment: Text.AlignLeft
}
}
TextEdit {
Kirigami.SelectableLabel {
Layout.alignment: Qt.AlignTop
Layout.fillWidth: true
visible: isSubscribed && page.showMoreInfo
height: visible ? implicitHeight : 0
readOnly: true
selectByMouse: !kastsMainWindow.isMobile
textFormat:TextEdit.RichText
text: isSubscribed ? i18n("Subscribed since: %1", feed.subscribed.toLocaleString(Qt.locale(), Locale.ShortFormat)) : ""
wrapMode: Text.WordWrap
color: Kirigami.Theme.textColor
}
TextEdit {
Kirigami.SelectableLabel {
Layout.alignment: Qt.AlignTop
Layout.fillWidth: true
visible: isSubscribed && page.showMoreInfo
height: visible ? implicitHeight : 0
readOnly: true
selectByMouse: !kastsMainWindow.isMobile
textFormat:TextEdit.RichText
text: isSubscribed ? i18n("Last updated: %1", feed.lastUpdated.toLocaleString(Qt.locale(), Locale.ShortFormat)) : ""
wrapMode: Text.WordWrap
color: Kirigami.Theme.textColor
}
TextEdit {
Kirigami.SelectableLabel {
Layout.alignment: Qt.AlignTop
Layout.fillWidth: true
visible: isSubscribed && page.showMoreInfo
height: visible ? implicitHeight : 0
readOnly: true
selectByMouse: !kastsMainWindow.isMobile
textFormat:TextEdit.RichText
text: i18np("1 Episode", "%1 Episodes", feed.entryCount) + ", " + i18np("1 Unplayed", "%1 Unplayed", feed.unreadEntryCount)
wrapMode: Text.WordWrap
color: Kirigami.Theme.textColor
}
Item { Layout.fillHeight: true }