summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--applications/kube-mail/package/contents/ui/main.qml50
-rw-r--r--framework/CMakeLists.txt1
-rw-r--r--framework/mail/CMakeLists.txt3
-rw-r--r--framework/mail/actions/akonadiactions.cpp75
-rw-r--r--framework/mail/actions/akonadiactions.h40
5 files changed, 139 insertions, 30 deletions
diff --git a/applications/kube-mail/package/contents/ui/main.qml b/applications/kube-mail/package/contents/ui/main.qml
index 33744157..ef37ae19 100644
--- a/applications/kube-mail/package/contents/ui/main.qml
+++ b/applications/kube-mail/package/contents/ui/main.qml
@@ -32,16 +32,16 @@ ApplicationWindow {
32 32
33 visible: true 33 visible: true
34 34
35 Action.ActionHandler { 35 // Action.ActionHandler {
36 actionId: "org.kde.kube.actions.mark-as-read" 36 // actionId: "org.kde.kube.actions.mark-as-read"
37 function isReady(context) { 37 // function isReady(context) {
38 return context.mail ? true : false; 38 // return context.mail ? true : false;
39 } 39 // }
40 40 //
41 function handler(context) { 41 // function handler(context) {
42 console.warn("Got message:", context.mail) 42 // console.warn("Got message:", context.mail)
43 } 43 // }
44 } 44 // }
45 45
46 Action.Context { 46 Action.Context {
47 id: "maillistcontext" 47 id: "maillistcontext"
@@ -55,6 +55,12 @@ ApplicationWindow {
55 context: maillistcontext 55 context: maillistcontext
56 } 56 }
57 57
58 Action.Action {
59 id: "deleteAction"
60 actionId: "org.kde.kube.actions.delete"
61 context: maillistcontext
62 }
63
58 //UI 64 //UI
59 toolBar: ToolBar { 65 toolBar: ToolBar {
60 66
@@ -62,48 +68,38 @@ ApplicationWindow {
62 anchors.fill: parent 68 anchors.fill: parent
63 69
64 PlasmaComponents.ToolButton { 70 PlasmaComponents.ToolButton {
65
66 height: parent.height 71 height: parent.height
67
68 iconName: "mail-message-new" 72 iconName: "mail-message-new"
69
70 text: "Compose" 73 text: "Compose"
74 enabled: false
71 } 75 }
72 76
73 PlasmaComponents.ToolButton { 77 PlasmaComponents.ToolButton {
74
75 height: parent.height 78 height: parent.height
76
77 iconName: "mail-mark-unread" 79 iconName: "mail-mark-unread"
78 text: "Mark Unread" 80 text: "Mark As Read"
79 enabled: markAsReadAction.ready 81 enabled: markAsReadAction.ready
80
81 onClicked: { 82 onClicked: {
82 markAsReadAction.execute() 83 markAsReadAction.execute()
83 } 84 }
84 } 85 }
85 86
86 PlasmaComponents.ToolButton { 87 PlasmaComponents.ToolButton {
87
88 height: parent.height 88 height: parent.height
89
90 iconName: "mail-mark-important" 89 iconName: "mail-mark-important"
91 text: "Mark Important" 90 text: "Mark Important"
92 91 enabled: false
93 onClicked: { 92 onClicked: {
94 mailList.markMailImportant(true)
95 } 93 }
96 } 94 }
97 95
98 PlasmaComponents.ToolButton { 96 PlasmaComponents.ToolButton {
99
100 height: parent.height 97 height: parent.height
101
102 iconName: "edit-delete" 98 iconName: "edit-delete"
103 text: "Delete Mail" 99 text: "Delete Mail"
104 100 enabled: deleteAction.ready
105 onClicked: { 101 onClicked: {
106 mailList.deleteMail() 102 deleteAction.execute()
107 } 103 }
108 } 104 }
109 } 105 }
@@ -114,7 +110,6 @@ ApplicationWindow {
114 110
115 FolderListView { 111 FolderListView {
116 id: folderListView 112 id: folderListView
117
118 width: unit.size * 55 113 width: unit.size * 55
119 Layout.maximumWidth: unit.size * 150 114 Layout.maximumWidth: unit.size * 150
120 Layout.minimumWidth: unit.size * 30 115 Layout.minimumWidth: unit.size * 30
@@ -123,7 +118,6 @@ ApplicationWindow {
123 MailListView { 118 MailListView {
124 id: mailListView 119 id: mailListView
125 parentFolder: folderListView.currentFolder 120 parentFolder: folderListView.currentFolder
126
127 width: unit.size * 80 121 width: unit.size * 80
128 Layout.maximumWidth: unit.size * 250 122 Layout.maximumWidth: unit.size * 250
129 Layout.minimumWidth: unit.size * 50 123 Layout.minimumWidth: unit.size * 50
@@ -132,7 +126,6 @@ ApplicationWindow {
132 SingleMailView { 126 SingleMailView {
133 id: mailView 127 id: mailView
134 mail: mailListView.currentMail 128 mail: mailListView.currentMail
135
136 Layout.fillWidth: true 129 Layout.fillWidth: true
137 } 130 }
138 131
@@ -141,7 +134,6 @@ ApplicationWindow {
141 //TODO find a better way to scale UI 134 //TODO find a better way to scale UI
142 Item { 135 Item {
143 id: unit 136 id: unit
144
145 property int size: 5 137 property int size: 5
146 } 138 }
147 139
diff --git a/framework/CMakeLists.txt b/framework/CMakeLists.txt
index 3a441f99..d59061d2 100644
--- a/framework/CMakeLists.txt
+++ b/framework/CMakeLists.txt
@@ -18,6 +18,7 @@ find_package(Qt5 COMPONENTS REQUIRED Core Qml)
18 18
19set(CMAKE_AUTOMOC ON) 19set(CMAKE_AUTOMOC ON)
20add_definitions("-Wall -std=c++0x -g") 20add_definitions("-Wall -std=c++0x -g")
21include_directories(.)
21include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/common) 22include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/common)
22include_directories(SYSTEM /work/install/include/) 23include_directories(SYSTEM /work/install/include/)
23include_directories(SYSTEM /work/install/include/KF5/) 24include_directories(SYSTEM /work/install/include/KF5/)
diff --git a/framework/mail/CMakeLists.txt b/framework/mail/CMakeLists.txt
index 38ba3935..6188c93c 100644
--- a/framework/mail/CMakeLists.txt
+++ b/framework/mail/CMakeLists.txt
@@ -5,13 +5,14 @@ set(mailplugin_SRCS
5 singlemailcontroller.cpp 5 singlemailcontroller.cpp
6 folderlistmodel.cpp 6 folderlistmodel.cpp
7 folderlistcontroller.cpp 7 folderlistcontroller.cpp
8 actions/akonadiactions.cpp
8) 9)
9 10
10add_library(mailplugin SHARED ${mailplugin_SRCS}) 11add_library(mailplugin SHARED ${mailplugin_SRCS})
11 12
12qt5_use_modules(mailplugin Core Quick Qml) 13qt5_use_modules(mailplugin Core Quick Qml)
13 14
14target_link_libraries(mailplugin /work/install/lib64/libakonadi2common.so) 15target_link_libraries(mailplugin /work/install/lib64/libakonadi2common.so actionplugin)
15#target_link_libraries(mailplugin /home/mike/projects/_install/lib/x86_64-linux-gnu/libakonadi2common.so) 16#target_link_libraries(mailplugin /home/mike/projects/_install/lib/x86_64-linux-gnu/libakonadi2common.so)
16 17
17install(TARGETS mailplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/kube/mail) 18install(TARGETS mailplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/kube/mail)
diff --git a/framework/mail/actions/akonadiactions.cpp b/framework/mail/actions/akonadiactions.cpp
new file mode 100644
index 00000000..d0a51deb
--- /dev/null
+++ b/framework/mail/actions/akonadiactions.cpp
@@ -0,0 +1,75 @@
1/*
2 Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com>
3
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18*/
19#include "akonadiactions.h"
20
21#include <actions/context.h>
22
23#include <akonadi2common/clientapi.h>
24
25using namespace Kube;
26
27ActionHandlerHelper::ActionHandlerHelper(const QByteArray &actionId, const std::function<bool(Context*)> &isReady, const std::function<void(Context*)> &handler)
28 : ActionHandler(nullptr),
29 isReadyFunction(isReady),
30 handlerFunction(handler)
31{
32 setActionId(actionId);
33}
34
35bool ActionHandlerHelper::isActionReady(Context *context)
36{
37 return isReadyFunction(context);
38}
39
40void ActionHandlerHelper::execute(Context *context)
41{
42 handlerFunction(context);
43}
44
45static ActionHandlerHelper markAsReadHandler("org.kde.kube.actions.mark-as-read",
46 [](Context *context) -> bool {
47 return context->property("mail").isValid();
48 },
49 [](Context *context) {
50 auto mail = context->property("mail").value<Akonadi2::ApplicationDomain::Mail::Ptr>();
51 if (!mail) {
52 qWarning() << "Failed to get the mail mail: " << context->property("mail");
53 return;
54 }
55 mail->setProperty("unread", false);
56 qDebug() << "Mark as read " << mail->identifier();
57 Akonadi2::Store::modify(*mail).exec();
58 }
59);
60
61static ActionHandlerHelper deleteHandler("org.kde.kube.actions.delete",
62 [](Context *context) -> bool {
63 return context->property("mail").isValid();
64 },
65 [](Context *context) {
66 auto mail = context->property("mail").value<Akonadi2::ApplicationDomain::Mail::Ptr>();
67 if (!mail) {
68 qWarning() << "Failed to get the mail mail: " << context->property("mail");
69 return;
70 }
71 mail->setProperty("unread", false);
72 qDebug() << "Remove " << mail->identifier();
73 Akonadi2::Store::remove(*mail).exec();
74 }
75);
diff --git a/framework/mail/actions/akonadiactions.h b/framework/mail/actions/akonadiactions.h
new file mode 100644
index 00000000..a583ebf8
--- /dev/null
+++ b/framework/mail/actions/akonadiactions.h
@@ -0,0 +1,40 @@
1/*
2 Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com>
3
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18*/
19#pragma once
20
21#include <actions/actionhandler.h>
22#include <functional>
23
24namespace Kube {
25class Context;
26
27class ActionHandlerHelper : public ActionHandler
28{
29 Q_OBJECT
30public:
31 ActionHandlerHelper(const QByteArray &actionId, const std::function<bool(Context*)> &, const std::function<void(Context*)> &);
32
33 bool isActionReady(Context *context) Q_DECL_OVERRIDE;
34 void execute(Context *context) Q_DECL_OVERRIDE;
35private:
36 const std::function<bool(Context*)> isReadyFunction;
37 const std::function<void(Context*)> handlerFunction;
38};
39
40}