Warning, /network/tokodon/src/content/ui/AnnouncementsPage.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com
0002 // SPDX-License-Identifier: GPL-3.0-only
0003 
0004 import QtQuick
0005 import QtQuick.Controls 2 as QQC2
0006 import QtQuick.Layouts
0007 
0008 import org.kde.kirigami 2 as Kirigami
0009 import org.kde.kirigamiaddons.delegates 1 as Delegates
0010 
0011 import org.kde.tokodon
0012 
0013 import "./StatusDelegate"
0014 
0015 Kirigami.ScrollablePage {
0016     id: root
0017 
0018     title: i18nc("@title Server-wide announcements set by admins.", "Announcements")
0019 
0020     ListView {
0021         id: listview
0022 
0023         model: AnnouncementModel {}
0024         currentIndex: -1
0025 
0026         delegate: Delegates.RoundedItemDelegate {
0027             id: delegate
0028 
0029             required property var index
0030             required property string id
0031             required property string content
0032             required property date publishedAt
0033 
0034             contentItem: ColumnLayout {
0035                 id: layout
0036 
0037                 spacing: 0
0038                 clip: true
0039 
0040                 Kirigami.Heading {
0041                     text: i18nc("@label An announcement was published on a date", "Announcement on %1", delegate.publishedAt.toLocaleDateString())
0042                     type: Kirigami.Heading.Type.Primary
0043                     level: 4
0044                     verticalAlignment: Text.AlignTop
0045                     elide: Text.ElideRight
0046                     Layout.fillWidth: true
0047                 }
0048 
0049                 QQC2.Label {
0050                     Layout.fillWidth: true
0051 
0052                     text: delegate.content
0053                     wrapMode: Text.Wrap
0054                     textFormat: Text.RichText
0055 
0056                     onLinkActivated: (link) => Qt.openUrlExternally(link)
0057                 }
0058             }
0059         }
0060 
0061         QQC2.ProgressBar {
0062             visible: listview.model.loading && listview.count === 0
0063             anchors.centerIn: parent
0064             indeterminate: true
0065         }
0066 
0067         Kirigami.PlaceholderMessage {
0068             anchors.centerIn: parent
0069             text: i18nc("@label", "No announcements")
0070             visible: listview.count === 0 && !listview.model.loading
0071             width: parent.width - Kirigami.Units.gridUnit * 4
0072         }
0073     }
0074 }