diff options
-rw-r--r-- | components/package/contents/ui/Outbox.qml | 69 | ||||
-rw-r--r-- | framework/domain/actions/sinkactions.cpp | 15 |
2 files changed, 71 insertions, 13 deletions
diff --git a/components/package/contents/ui/Outbox.qml b/components/package/contents/ui/Outbox.qml index 4da5feb8..5330cd4e 100644 --- a/components/package/contents/ui/Outbox.qml +++ b/components/package/contents/ui/Outbox.qml | |||
@@ -19,9 +19,11 @@ | |||
19 | import QtQuick 2.4 | 19 | import QtQuick 2.4 |
20 | import QtQuick.Controls 1.3 | 20 | import QtQuick.Controls 1.3 |
21 | import QtQuick.Layouts 1.1 | 21 | import QtQuick.Layouts 1.1 |
22 | import QtQuick.Controls 2.0 as Controls2 | ||
22 | 23 | ||
23 | import org.kde.kirigami 1.0 as Kirigami | 24 | import org.kde.kirigami 1.0 as Kirigami |
24 | 25 | ||
26 | import org.kube.framework.actions 1.0 as KubeAction | ||
25 | import org.kube.framework.domain 1.0 as KubeFramework | 27 | import org.kube.framework.domain 1.0 as KubeFramework |
26 | import org.kube.components 1.0 as KubeComponents | 28 | import org.kube.components 1.0 as KubeComponents |
27 | 29 | ||
@@ -35,6 +37,13 @@ ToolButton { | |||
35 | dialog.visible = dialog.visible ? false : true | 37 | dialog.visible = dialog.visible ? false : true |
36 | } | 38 | } |
37 | 39 | ||
40 | KubeAction.Action { | ||
41 | id: sendNowAction | ||
42 | actionId: "org.kde.kube.actions.sendOutbox" | ||
43 | context: KubeAction.Context { | ||
44 | } | ||
45 | } | ||
46 | |||
38 | //BEGIN Dialog | 47 | //BEGIN Dialog |
39 | Rectangle { | 48 | Rectangle { |
40 | id: dialog | 49 | id: dialog |
@@ -46,8 +55,16 @@ ToolButton { | |||
46 | horizontalCenter: parent.horizontalCenter | 55 | horizontalCenter: parent.horizontalCenter |
47 | } | 56 | } |
48 | 57 | ||
49 | height: modelCount * Kirigami.Units.gridUnit * 3 + 10//scrollView.height height: Kirigami.Units.gridUnit * 15 | 58 | function calculateHeight() { |
50 | width: Kirigami.Units.gridUnit * 20 | 59 | if (modelCount == 0) { |
60 | return Kirigami.Units.gridUnit * 3 + 10 | ||
61 | } else { | ||
62 | return modelCount * Kirigami.Units.gridUnit * 3 + 10 + sendNowButton.height | ||
63 | } | ||
64 | } | ||
65 | |||
66 | height: calculateHeight() | ||
67 | width: Kirigami.Units.gridUnit * 20 | ||
51 | 68 | ||
52 | color: Kirigami.Theme.backgroundColor | 69 | color: Kirigami.Theme.backgroundColor |
53 | border.width: 1 | 70 | border.width: 1 |
@@ -57,33 +74,59 @@ ToolButton { | |||
57 | visible: false | 74 | visible: false |
58 | 75 | ||
59 | //BEGIN Dialog Content | 76 | //BEGIN Dialog Content |
60 | ScrollView { | 77 | Column { |
61 | id: scrollView | ||
62 | |||
63 | anchors { | 78 | anchors { |
64 | fill: parent | 79 | fill: parent |
65 | margins: 5 | 80 | margins: 5 |
66 | } | 81 | } |
67 | 82 | ||
68 | ListView { | 83 | visible: dialog.modelCount != 0 |
69 | id: listView | ||
70 | 84 | ||
71 | model: KubeFramework.OutboxModel { | 85 | Controls2.Button { |
86 | id: sendNowButton | ||
87 | anchors.horizontalCenter: parent.horizontalCenter | ||
88 | height: Kirigami.Units.gridUnit * 2 | ||
89 | text: qsTr("Send now.") | ||
90 | onClicked: { | ||
91 | sendNowAction.execute() | ||
72 | } | 92 | } |
93 | } | ||
73 | 94 | ||
74 | delegate: Kirigami.AbstractListItem { | 95 | ScrollView { |
96 | id: scrollView | ||
75 | 97 | ||
76 | height: Kirigami.Units.gridUnit * 3 | 98 | anchors { |
99 | left: parent.left | ||
100 | right: parent.right | ||
101 | margins: 5 | ||
102 | } | ||
103 | |||
104 | ListView { | ||
105 | id: listView | ||
77 | 106 | ||
78 | Kirigami.Label { | 107 | model: KubeFramework.OutboxModel { |
108 | } | ||
79 | 109 | ||
80 | anchors.verticalCenter: parent.verticalCenter | 110 | delegate: Kirigami.AbstractListItem { |
111 | height: Kirigami.Units.gridUnit * 3 | ||
81 | 112 | ||
82 | text: model.subject | 113 | Kirigami.Label { |
114 | anchors.verticalCenter: parent.verticalCenter | ||
115 | text: model.subject | ||
116 | } | ||
83 | } | 117 | } |
84 | } | 118 | } |
85 | } | 119 | } |
86 | } | 120 | } |
121 | Kirigami.Label { | ||
122 | anchors { | ||
123 | fill: parent | ||
124 | margins: 5 | ||
125 | verticalCenter: parent.verticalCenter | ||
126 | } | ||
127 | visible: dialog.modelCount == 0 | ||
128 | text: qsTr("No pending messages.") | ||
129 | } | ||
87 | //END Dialog Content | 130 | //END Dialog Content |
88 | } | 131 | } |
89 | //END Dialog | 132 | //END Dialog |
diff --git a/framework/domain/actions/sinkactions.cpp b/framework/domain/actions/sinkactions.cpp index 39b39a0a..e8127ee6 100644 --- a/framework/domain/actions/sinkactions.cpp +++ b/framework/domain/actions/sinkactions.cpp | |||
@@ -95,6 +95,21 @@ static ActionHandlerHelper synchronizeHandler("org.kde.kube.actions.synchronize" | |||
95 | } | 95 | } |
96 | ); | 96 | ); |
97 | 97 | ||
98 | static ActionHandlerHelper sendOutboxHandler("org.kde.kube.actions.sendOutbox", | ||
99 | [](Context *context) -> bool { | ||
100 | return true; | ||
101 | }, | ||
102 | ActionHandlerHelper::JobHandler{[](Context *context) -> KAsync::Job<void> { | ||
103 | using namespace Sink::ApplicationDomain; | ||
104 | Query query; | ||
105 | query.containsFilter<SinkResource::Capabilities>(ResourceCapabilities::Mail::transport); | ||
106 | return Store::fetchAll<SinkResource>(query) | ||
107 | .each([=](const SinkResource::Ptr &resource) -> KAsync::Job<void> { | ||
108 | return Store::synchronize(SyncScope{}.resourceFilter(resource->identifier())); | ||
109 | }); | ||
110 | }} | ||
111 | ); | ||
112 | |||
98 | static ActionHandlerHelper sendMailHandler("org.kde.kube.actions.sendmail", | 113 | static ActionHandlerHelper sendMailHandler("org.kde.kube.actions.sendmail", |
99 | [](Context *context) -> bool { | 114 | [](Context *context) -> bool { |
100 | auto accountId = context->property("accountId").value<QByteArray>(); | 115 | auto accountId = context->property("accountId").value<QByteArray>(); |