Files
amnezia-client/client/ui/qml/Pages2/PageSettingsNewsDetail.qml
T

124 lines
3.6 KiB
QML
Raw Normal View History

2025-10-06 08:06:36 +04:00
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import PageEnum 1.0
import Style 1.0
import "./"
import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
import SortFilterProxyModel 0.2
PageType {
id: root
property var newsItem
2026-05-04 07:37:19 +03:00
property bool isUpdateItem: newsItem && (newsItem.isUpdate !== undefined ? newsItem.isUpdate : false)
2025-10-06 08:06:36 +04:00
SortFilterProxyModel {
id: proxyNews
sourceModel: NewsModel
filters: [ ValueFilter { roleName: "isProcessed"; value: true } ]
Component.onCompleted: root.newsItem = proxyNews.get(0)
}
Connections {
target: NewsModel
function onProcessedIndexChanged() {
root.newsItem = proxyNews.get(0)
}
}
BackButtonType {
id: backButton
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20 + PageController.safeAreaTopMargin
2025-10-06 08:06:36 +04:00
}
FlickableType {
id: fl
anchors.top: backButton.bottom
anchors.bottom: parent.bottom
contentHeight: content.height
ColumnLayout {
id: content
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
spacing: 0
BaseHeaderType {
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
2026-05-04 07:37:19 +03:00
headerText: newsItem ? newsItem.title : ""
2025-10-06 08:06:36 +04:00
}
ParagraphTextType {
Layout.fillWidth: true
Layout.topMargin: 16
Layout.leftMargin: 16
Layout.rightMargin: 16
2026-05-04 07:37:19 +03:00
text: newsItem ? newsItem.content : ""
2026-05-04 07:37:19 +03:00
textFormat: root.isUpdateItem ? Text.MarkdownText : Text.RichText
onLinkActivated: function(link) {
Qt.openUrlExternally(link)
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.NoButton
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
}
2025-10-06 08:06:36 +04:00
}
2026-05-04 07:37:19 +03:00
BasicButtonType {
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
Layout.topMargin: 24
visible: root.isUpdateItem
text: qsTr("Update")
clickedFunc: function() {
if (!root.isUpdateItem)
return
PageController.showBusyIndicator(true)
UpdateController.runInstaller()
PageController.showBusyIndicator(false)
PageController.closePage()
}
}
BasicButtonType {
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
Layout.topMargin: 8
Layout.bottomMargin: 16
visible: root.isUpdateItem
defaultColor: "transparent"
hoveredColor: Qt.rgba(1, 1, 1, 0.08)
pressedColor: Qt.rgba(1, 1, 1, 0.12)
disabledColor: "#878B91"
textColor: "#D7D8DB"
borderWidth: 1
text: qsTr("Skip")
clickedFunc: function() {
if (!root.isUpdateItem)
return
NewsModel.markUpdateAsSkipped()
PageController.closePage()
}
}
2025-10-06 08:06:36 +04:00
}
}
}