1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-24 05:17:46 +00:00

Add link indicators for news

This commit is contained in:
Joshua Goins 2023-08-18 22:13:41 -04:00
parent e9f8580675
commit 01293edb60
2 changed files with 41 additions and 0 deletions

View file

@ -61,8 +61,11 @@ Controls.Control {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
onClicked: applicationWindow().openUrl(LauncherCore.headline.banners[page.currentBannerIndex].link)
onEntered: applicationWindow().hoverLinkIndicator.text = LauncherCore.headline.banners[page.currentBannerIndex].link
onExited: applicationWindow().hoverLinkIndicator.text = ""
}
layer.enabled: true
@ -103,6 +106,13 @@ Controls.Control {
description: Qt.formatDate(modelData.date)
onClicked: applicationWindow().openUrl(modelData.url)
onHoveredChanged: {
if (hovered) {
applicationWindow().hoverLinkIndicator.text = modelData.url;
} else {
applicationWindow().hoverLinkIndicator.text = "";
}
}
}
}
@ -135,7 +145,15 @@ Controls.Control {
text: modelData.title
description: Qt.formatDate(modelData.date)
hoverEnabled: true
onClicked: applicationWindow().openUrl(modelData.url)
onHoveredChanged: {
if (hovered) {
applicationWindow().hoverLinkIndicator.text = modelData.url;
} else {
applicationWindow().hoverLinkIndicator.text = "";
}
}
}
}

View file

@ -101,4 +101,27 @@ Kirigami.ApplicationWindow {
}
Component.onCompleted: checkSetup()
property Item hoverLinkIndicator: Controls.Control {
parent: overlay.parent
property alias text: linkText.text
opacity: text.length > 0 ? 1 : 0
Behavior on opacity {
OpacityAnimator {
duration: Kirigami.Units.longDuration
}
}
z: 999990
x: 0
y: parent.height - implicitHeight
contentItem: Controls.Label {
id: linkText
}
Kirigami.Theme.colorSet: Kirigami.Theme.View
background: Rectangle {
color: Kirigami.Theme.backgroundColor
}
}
}