summaryrefslogtreecommitdiff
path: root/src/qml/Main.qml
blob: cef37e9edc79a1fba029d2d49e69bbab847c4314 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// SPDX-License-Identifier: GPL-2.0-or-later
// SPDX-FileCopyrightText: 2024 Alexander Kavon <me+kue@alexkavon.com>

import QtQuick
import QtQuick.Controls as QQC2
import QtQuick.Layouts

import org.kde.kirigami as Kirigami
import org.kde.kirigamiaddons.statefulapp as StatefulApp

import org.kde.kue
import org.kde.kue.settings as Settings

StatefulApp.StatefulWindow {
    id: root

    property int counter: 0

    title: i18nc("@title:window", "Kue")

    windowName: "Kue"

    minimumWidth: Kirigami.Units.gridUnit * 20
    minimumHeight: Kirigami.Units.gridUnit * 20

    application: KueApplication {
        configurationView: Settings.KueConfigurationView {}
    }

    // Connections {
    //     target: root.application

    //     function onIncrementCounter(): void {
    //         root.counter += 1;
    //     }
    // }

    // globalDrawer: Kirigami.GlobalDrawer {
    //     // isMenu: !Kirigami.Settings.isMobile
    //     actions: [
    //         Kirigami.Action {
    //             id: incrementCounterAction
    //             fromQAction: root.application.action("increment_counter")
    //         },
    //         Kirigami.Action {
    //             separator: true
    //         },
    //         Kirigami.Action {
    //             fromQAction: root.application.action("options_configure")
    //         },
    //         Kirigami.Action {
    //             fromQAction: root.application.action("options_configure_keybinding")
    //         },
    //         Kirigami.Action {
    //             separator: true
    //         },
    //         Kirigami.Action {
    //             id: aboutAction
    //             fromQAction: root.application.action("open_about_page")
    //         },
    //         Kirigami.Action {
    //             fromQAction: root.application.action("open_about_kde_page")
    //         },
    //         Kirigami.Action {
    //             fromQAction: root.application.action("file_quit")
    //         }
    //     ]
    // }

    pageStack.initialPage: KueApplication.loading ? loadingPage : mainPage

    Component {
        id: loadingPage
        Kirigami.Page {
            Kirigami.PlaceholderMessage {
                anchors.centerIn: parent
                text: i18n("Loading, please wait...")
            }
        }
    }

    Kirigami.ScrollablePage {
        id: mainPage

        title: i18nc("@title", "Kue")

        supportsRefreshing: true

        ListView {
            model: KueApplication.descendantsProxyModel
            highlight: Rectangle {
                width: parent.width
                color: "blue"
            }
            delegate: Kirigami.SwipeListItem {
                id: task

                required property bool completed

                contentItem: RowLayout {
                    QQC2.CheckBox {
                        id: control
                        checked: task.completed
                        onCheckedChanged: {
                            if (control.checked != task.completed) {
                                task.completed = control.checked;
                            }
                        }
                        indicator: Rectangle {
                            implicitWidth: 30
                            implicitHeight: 30
                            x: control.leftPadding
                            y: parent.height / 2 - height / 2
                            border.color: control.down ? "darkblue" : "gray"
                            border.width: 2
                            Rectangle {
                                visible: control.checked
                                color: "red"
                                radius: 1
                                width: 15
                                height: 15
                                anchors.margins: 5
                                anchors.fill: parent
                            }
                        }
                    }

                    QQC2.TextField {
                        id: taskEdit
                        Layout.fillWidth: true
                        height: Math.max(implicitHeight, Kirigami.Units.iconSizes.smallMedium)
                        placeholderText: "Task Info..."
                        text: model.display + " : " + task.completed
                        wrapMode: TextInput.Wrap
                        background: Rectangle {
                            id: taskEditBg
                            border.color: "transparent"
                            color: "transparent"
                            Rectangle {
                                visible: taskEdit.activeFocus
                                anchors.bottom: taskEditBg.bottom
                                height: 2
                                width: parent.width
                                color: "green"
                            }
                        }
                    }

                    Kirigami.Icon {
                        source: "view-list-details"
                        visible: taskEdit.activeFocus
                        implicitHeight: 20
                        implicitWidth: 20
                    }
                }
            }
            section {
                property: "section"
                delegate: Kirigami.ListSectionHeader {
                    required property string section

                    text: qsTr("Section %1").arg(parseInt(section) + 1)
                    width: ListView.view.width - ListView.view.leftMargin - ListView.view.rightMargin
                }
            }
        }
    }
}