Warning, /utilities/daykountdown/src/contents/ui/KountdownsPage.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: (C) 2021 Claudio Cambra <claudio.cambra@gmail.com> 0003 * 0004 * SPDX-LicenseRef: GPL-3.0-or-later 0005 */ 0006 0007 // Includes relevant modules used by the QML 0008 import QtQuick 2.6 0009 import QtQuick.Controls 2.15 as Controls 0010 import QtQuick.Layouts 1.2 0011 import org.kde.kirigami 2.13 as Kirigami 0012 import org.kde.daykountdown.private 1.0 0013 0014 // Page contains the content. This one is scrollable. 0015 // DON'T PUT A SCROLLVIEW IN A SCROLLPAGE - children of a ScrollablePage are already in a ScrollView 0016 Kirigami.ScrollablePage { 0017 id: kountdownsPage 0018 0019 // Title for the current page, placed on the toolbar 0020 title: i18nc("@title", "Kountdowns") 0021 0022 // Kirigami.Action encapsulates a UI action. Inherits from QQC2 Action 0023 actions { 0024 main: Kirigami.Action { 0025 id: addAction 0026 // Name of icon associated with the action 0027 icon.name: "list-add" 0028 // Action text, i18n function returns translated string 0029 tooltip: i18nc("@action:button", "Add kountdown") 0030 // What to do when triggering the action 0031 onTriggered: openPopulateSheet("add") 0032 } 0033 // Kirigami.Actions can have nested actions. 0034 right: Kirigami.Action { 0035 id: sortList 0036 tooltip: i18nc("@action:button", "Sort by") 0037 icon.name: "view-sort" 0038 Kirigami.Action { 0039 text: i18nc("@action:button", "Creation (ascending)") 0040 onTriggered: KountdownModel.sortModel(KountdownModel.CreationAsc) 0041 } 0042 Kirigami.Action { 0043 text: i18nc("@action:button", "Creation (descending)") 0044 onTriggered: KountdownModel.sortModel(KountdownModel.CreationDesc) 0045 } 0046 Kirigami.Action { 0047 text: i18nc("@action:button", "Date (ascending)") 0048 onTriggered: KountdownModel.sortModel(KountdownModel.DateAsc) 0049 } 0050 Kirigami.Action { 0051 text: i18nc("@action:button", "Date (descending)") 0052 onTriggered: KountdownModel.sortModel(KountdownModel.DateDesc) 0053 } 0054 Kirigami.Action { 0055 text: i18nc("@action:button", "Alphabetical (ascending)") 0056 onTriggered: KountdownModel.sortModel(KountdownModel.AlphabeticalAsc) 0057 } 0058 Kirigami.Action { 0059 text: i18nc("@action:button", "Alphabetical (descending)") 0060 onTriggered: KountdownModel.sortModel(KountdownModel.AlphabeticalDesc) 0061 } 0062 } 0063 left: Kirigami.Action { 0064 tooltip: i18n("Show calendar") 0065 icon.name: "view-calendar" 0066 onTriggered: showCalendar() 0067 } 0068 } 0069 0070 Component.onCompleted: { 0071 KountdownModel.sortModel(Config.sortMode) 0072 } 0073 0074 // List view for card elements 0075 Kirigami.CardsListView { 0076 id: layout 0077 // Model contains info to be displayed 0078 model: KountdownModel 0079 // Grabs component from different file specified in resources 0080 delegate: KountdownCard {} 0081 0082 header: Kirigami.Heading { 0083 padding: { 0084 top: Kirigami.Units.largeSpacing 0085 } 0086 width: parent.width 0087 horizontalAlignment: Text.AlignHCenter 0088 // Javascript variables must be prefixed with 'property' 0089 // Use toLocaleDateString, method to convert date object to string 0090 text: i18n("Today is %1", nowDate.toLocaleDateString()) 0091 level: 1 0092 wrapMode: Text.Wrap 0093 } 0094 // Different types of header positioning, this one gets covered up when you scroll 0095 headerPositioning: ListView.PullBackHeader 0096 0097 Kirigami.PlaceholderMessage { 0098 // Center element, horizontally and vertically 0099 anchors.centerIn: parent 0100 width: parent.width - (Kirigami.Units.largeSpacing * 4) 0101 // Hide this if there are list elements to display 0102 visible: layout.count === 0 0103 text: i18n("Add some kountdowns!") 0104 helpfulAction: addAction 0105 } 0106 } 0107 }