diff options
Diffstat (limited to 'framework/qml/Outbox.qml')
-rw-r--r-- | framework/qml/Outbox.qml | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/framework/qml/Outbox.qml b/framework/qml/Outbox.qml new file mode 100644 index 00000000..19646459 --- /dev/null +++ b/framework/qml/Outbox.qml | |||
@@ -0,0 +1,151 @@ | |||
1 | /* | ||
2 | Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net> | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License along | ||
15 | with this program; if not, write to the Free Software Foundation, Inc., | ||
16 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | */ | ||
18 | |||
19 | import QtQuick 2.4 | ||
20 | import QtQuick.Layouts 1.1 | ||
21 | import QtQuick.Controls 2.0 | ||
22 | import QtQuick.Controls 1.3 as Controls | ||
23 | |||
24 | import org.kde.kirigami 1.0 as Kirigami | ||
25 | |||
26 | import org.kube.framework.actions 1.0 as KubeAction | ||
27 | import org.kube.framework.domain 1.0 as KubeFramework | ||
28 | import org.kube.components 1.0 as KubeComponents | ||
29 | import org.kube.components.theme 1.0 as KubeTheme | ||
30 | |||
31 | KubeComponents.Button { | ||
32 | id: root | ||
33 | |||
34 | text: outboxModel.count > 0 ? "Outbox (" + outboxModel.count + ")" : "Outbox" | ||
35 | color: "transparent" | ||
36 | textColor: KubeTheme.Colors.highlightedTextColor | ||
37 | iconName: "" | ||
38 | states: [ | ||
39 | State { | ||
40 | name: "busy"; when: outboxModel.status == KubeFramework.OutboxModel.InProgressStatus | ||
41 | PropertyChanges { target: root; iconName: KubeTheme.Icons.busy } | ||
42 | }, | ||
43 | State { | ||
44 | name: "error"; when: outboxModel.status == KubeFramework.OutboxModel.ErrorStatus | ||
45 | PropertyChanges { target: root; iconName: KubeTheme.Icons.error } | ||
46 | } | ||
47 | ] | ||
48 | |||
49 | onClicked: { | ||
50 | dialog.visible = dialog.visible ? false : true | ||
51 | } | ||
52 | |||
53 | KubeFramework.OutboxController { | ||
54 | id: outboxController | ||
55 | } | ||
56 | |||
57 | KubeFramework.OutboxModel { | ||
58 | id: outboxModel | ||
59 | } | ||
60 | |||
61 | Popup { | ||
62 | id: dialog | ||
63 | |||
64 | height: content.height + Kirigami.Units.smallSpacing * 2 | ||
65 | width: content.width + Kirigami.Units.smallSpacing * 2 | ||
66 | |||
67 | y: - dialog.height + root.height | ||
68 | x: root.width | ||
69 | |||
70 | modal: true | ||
71 | |||
72 | Item { | ||
73 | id: content | ||
74 | |||
75 | anchors.centerIn: parent | ||
76 | |||
77 | width: Kirigami.Units.gridUnit * 17 | ||
78 | height: listView.count * Kirigami.Units.gridUnit * 3 + sendNowButton.height + Kirigami.Units.smallSpacing | ||
79 | |||
80 | ListView { | ||
81 | id: listView | ||
82 | |||
83 | width: parent.width | ||
84 | height: count * Kirigami.Units.gridUnit * 3 | ||
85 | |||
86 | model: outboxModel | ||
87 | |||
88 | delegate: Rectangle { | ||
89 | id: delegateRoot | ||
90 | |||
91 | height: Kirigami.Units.gridUnit * 3 | ||
92 | width: listView.width | ||
93 | |||
94 | color: KubeTheme.Colors.viewBackgroundColor | ||
95 | border.color: KubeTheme.Colors.backgroundColor | ||
96 | border.width: 1 | ||
97 | |||
98 | Label { | ||
99 | id: subjectLabel | ||
100 | anchors { | ||
101 | verticalCenter: parent.verticalCenter | ||
102 | left: parent.left | ||
103 | leftMargin: Kirigami.Units.largeSpacing | ||
104 | } | ||
105 | text: model.subject | ||
106 | |||
107 | color: KubeTheme.Colors.textColor | ||
108 | opacity: 1 | ||
109 | states: [ | ||
110 | State { | ||
111 | name: "inprogress"; when: model.status == KubeFramework.OutboxModel.InProgressStatus | ||
112 | PropertyChanges { target: subjectLabel; text: "Sending: " + model.subject } | ||
113 | }, | ||
114 | State { | ||
115 | name: "error"; when: model.status == KubeFramework.OutboxModel.ErrorStatus | ||
116 | PropertyChanges { target: subjectLabel; color: KubeTheme.Colors.warningColor } | ||
117 | } | ||
118 | ] | ||
119 | } | ||
120 | } | ||
121 | |||
122 | clip: true | ||
123 | } | ||
124 | |||
125 | Button { | ||
126 | id: sendNowButton | ||
127 | |||
128 | anchors { | ||
129 | top: listView.bottom | ||
130 | topMargin: Kirigami.Units.smallSpacing | ||
131 | horizontalCenter: parent.horizontalCenter | ||
132 | } | ||
133 | |||
134 | visible: listView.count != 0 | ||
135 | |||
136 | text: qsTr("Send now") | ||
137 | onClicked: { | ||
138 | outboxController.sendOutboxAction.execute() | ||
139 | } | ||
140 | } | ||
141 | |||
142 | Label { | ||
143 | anchors.centerIn: parent | ||
144 | |||
145 | visible: listView.count == 0 | ||
146 | |||
147 | text: qsTr("No pending messages") | ||
148 | } | ||
149 | } | ||
150 | } | ||
151 | } | ||