2023-07-30 08:49:34 -04:00
|
|
|
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-12-17 12:47:13 -05:00
|
|
|
pragma ComponentBehavior: Bound
|
|
|
|
|
2023-09-16 18:15:11 -04:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls as QQC2
|
|
|
|
import QtQuick.Layouts
|
2024-04-27 16:38:22 +00:00
|
|
|
import QtQuick.Effects
|
2023-09-16 18:15:11 -04:00
|
|
|
|
|
|
|
import org.kde.kirigami as Kirigami
|
|
|
|
import org.kde.kirigamiaddons.formcard as FormCard
|
|
|
|
|
|
|
|
import zone.xiv.astra
|
|
|
|
|
|
|
|
QQC2.Control {
|
2023-07-30 08:49:34 -04:00
|
|
|
id: page
|
|
|
|
|
|
|
|
property int currentBannerIndex: 0
|
|
|
|
property int numBannerImages: 0
|
|
|
|
|
2024-03-22 20:56:35 -04:00
|
|
|
leftPadding: 0
|
|
|
|
rightPadding: 0
|
|
|
|
topPadding: 0
|
|
|
|
bottomPadding: 0
|
|
|
|
|
2024-03-22 20:41:10 -04:00
|
|
|
Component.onCompleted: LauncherCore.refreshNews()
|
|
|
|
|
2023-07-30 08:49:34 -04:00
|
|
|
Connections {
|
|
|
|
target: LauncherCore
|
|
|
|
|
2025-02-01 10:13:05 -05:00
|
|
|
function onNewsChanged(): void {
|
2023-07-30 08:49:34 -04:00
|
|
|
page.currentBannerIndex = 0
|
|
|
|
page.numBannerImages = LauncherCore.headline.banners.length
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Timer {
|
|
|
|
interval: 10000
|
|
|
|
running: true
|
|
|
|
repeat: true
|
|
|
|
onTriggered: {
|
2023-10-08 13:25:45 -04:00
|
|
|
if (page.numBannerImages === 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-07-30 08:49:34 -04:00
|
|
|
if (page.currentBannerIndex + 1 === page.numBannerImages) {
|
2023-10-08 13:25:45 -04:00
|
|
|
page.currentBannerIndex = 0;
|
2023-07-30 08:49:34 -04:00
|
|
|
} else {
|
2023-10-08 13:25:45 -04:00
|
|
|
page.currentBannerIndex++;
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-22 20:41:10 -04:00
|
|
|
background: Rectangle {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
color: Kirigami.Theme.backgroundColor
|
|
|
|
|
|
|
|
Kirigami.Theme.inherit: false
|
|
|
|
Kirigami.Theme.colorSet: Kirigami.Theme.View
|
|
|
|
}
|
|
|
|
|
2023-07-30 09:14:22 -04:00
|
|
|
contentItem: ColumnLayout {
|
2023-07-31 19:03:15 -04:00
|
|
|
id: layout
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-07-31 19:03:15 -04:00
|
|
|
readonly property real maximumWidth: Kirigami.Units.gridUnit * 50
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-10-08 20:24:35 -04:00
|
|
|
spacing: Kirigami.Units.largeSpacing
|
|
|
|
|
2023-07-31 19:03:15 -04:00
|
|
|
Image {
|
|
|
|
id: bannerImage
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-07-31 19:03:15 -04:00
|
|
|
readonly property real aspectRatio: sourceSize.height / sourceSize.width
|
|
|
|
|
|
|
|
Layout.maximumWidth: layout.maximumWidth
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: aspectRatio * width
|
|
|
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
|
2024-03-22 20:41:10 -04:00
|
|
|
Layout.topMargin: Kirigami.Units.largeSpacing
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-10-08 13:25:45 -04:00
|
|
|
source: {
|
|
|
|
if (LauncherCore.headline === null) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (page.numBannerImages === 0) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
return LauncherCore.headline.banners[page.currentBannerIndex].bannerImage;
|
|
|
|
}
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-07-31 19:03:15 -04:00
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-07-31 19:03:15 -04:00
|
|
|
cursorShape: Qt.PointingHandCursor
|
2023-08-18 22:13:41 -04:00
|
|
|
hoverEnabled: true
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-07-31 19:03:15 -04:00
|
|
|
onClicked: applicationWindow().openUrl(LauncherCore.headline.banners[page.currentBannerIndex].link)
|
|
|
|
}
|
|
|
|
|
2024-04-01 15:23:44 -04:00
|
|
|
layer.enabled: !(bannerImage.width < layout.maximumWidth)
|
2024-04-27 16:38:22 +00:00
|
|
|
layer.effect: MultiEffect {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
maskEnabled: true
|
|
|
|
maskSpreadAtMax: 1
|
|
|
|
maskSpreadAtMin: 1
|
|
|
|
maskThresholdMin: 0.5
|
|
|
|
maskSource: ShaderEffectSource {
|
|
|
|
sourceItem: Rectangle {
|
|
|
|
width: root.width
|
|
|
|
height: root.height
|
|
|
|
radius: Kirigami.Units.mediumSpacing
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
FormCard.FormHeader {
|
|
|
|
title: i18n("News")
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
maximumWidth: layout.maximumWidth
|
|
|
|
}
|
|
|
|
|
|
|
|
FormCard.FormCard {
|
2023-07-30 08:49:34 -04:00
|
|
|
Layout.fillWidth: true
|
2023-07-31 19:03:15 -04:00
|
|
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
|
|
|
|
|
|
|
|
maximumWidth: layout.maximumWidth
|
2023-08-18 21:48:46 -04:00
|
|
|
visible: LauncherCore.headline !== null
|
2023-07-31 19:03:15 -04:00
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
Repeater {
|
|
|
|
model: LauncherCore.headline !== null ? LauncherCore.headline.news : undefined
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
FormCard.FormButtonDelegate {
|
2023-12-17 12:47:13 -05:00
|
|
|
required property var modelData
|
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
text: modelData.title
|
|
|
|
description: Qt.formatDate(modelData.date)
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
onClicked: applicationWindow().openUrl(modelData.url)
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
2023-08-19 10:30:52 -04:00
|
|
|
}
|
2023-08-18 21:48:46 -04:00
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
FormCard.FormTextDelegate {
|
|
|
|
description: i18n("No news.")
|
|
|
|
visible: LauncherCore.headline !== null ? LauncherCore.headline.failedToLoad : false
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
2024-03-22 20:41:10 -04:00
|
|
|
|
|
|
|
Kirigami.Theme.colorSet: Kirigami.Theme.Window
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
FormCard.FormHeader {
|
|
|
|
title: i18n("Topics")
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
maximumWidth: layout.maximumWidth
|
|
|
|
}
|
|
|
|
|
|
|
|
FormCard.FormCard {
|
2023-07-30 08:49:34 -04:00
|
|
|
Layout.fillWidth: true
|
2023-07-31 19:03:15 -04:00
|
|
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
|
|
|
|
|
|
|
|
maximumWidth: layout.maximumWidth
|
2023-08-18 21:48:46 -04:00
|
|
|
visible: LauncherCore.headline !== null
|
2023-07-31 19:03:15 -04:00
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
Repeater {
|
|
|
|
model: LauncherCore.headline !== null ? LauncherCore.headline.topics : undefined
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
FormCard.FormButtonDelegate {
|
2023-12-17 12:47:13 -05:00
|
|
|
required property var modelData
|
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
text: modelData.title
|
|
|
|
description: Qt.formatDate(modelData.date)
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
hoverEnabled: true
|
|
|
|
onClicked: applicationWindow().openUrl(modelData.url)
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
2023-08-19 10:30:52 -04:00
|
|
|
}
|
2023-08-18 21:48:46 -04:00
|
|
|
|
2023-08-19 10:30:52 -04:00
|
|
|
FormCard.FormTextDelegate {
|
|
|
|
description: i18n("No topics.")
|
|
|
|
visible: LauncherCore.headline !== null ? LauncherCore.headline.failedToLoad : false
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
2024-03-22 20:41:10 -04:00
|
|
|
|
|
|
|
Kirigami.Theme.colorSet: Kirigami.Theme.Window
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
2023-07-31 19:03:15 -04:00
|
|
|
|
|
|
|
Item {
|
|
|
|
Layout.fillHeight: true
|
|
|
|
}
|
2023-07-30 08:49:34 -04:00
|
|
|
}
|
2023-08-18 21:48:46 -04:00
|
|
|
|
|
|
|
Kirigami.LoadingPlaceholder {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
visible: LauncherCore.headline === null
|
|
|
|
}
|
2025-02-01 10:13:05 -05:00
|
|
|
}
|