diff options
-rw-r--r-- | framework/domain/composercontroller.cpp | 20 | ||||
-rw-r--r-- | framework/domain/composercontroller.h | 11 | ||||
-rw-r--r-- | framework/domain/controller.h | 7 | ||||
-rw-r--r-- | framework/domain/foldercontroller.cpp | 3 | ||||
-rw-r--r-- | framework/domain/mailcontroller.cpp | 16 | ||||
-rw-r--r-- | framework/domain/outboxcontroller.cpp | 3 |
6 files changed, 20 insertions, 40 deletions
diff --git a/framework/domain/composercontroller.cpp b/framework/domain/composercontroller.cpp index 75396735..7122f201 100644 --- a/framework/domain/composercontroller.cpp +++ b/framework/domain/composercontroller.cpp | |||
@@ -82,12 +82,11 @@ public: | |||
82 | 82 | ||
83 | ComposerController::ComposerController() | 83 | ComposerController::ComposerController() |
84 | : Kube::Controller(), | 84 | : Kube::Controller(), |
85 | mSendAction{new Kube::ControllerAction}, | 85 | action_send{new Kube::ControllerAction{this, &ComposerController::send}}, |
86 | mSaveAsDraftAction{new Kube::ControllerAction}, | 86 | action_saveAsDraft{new Kube::ControllerAction{this, &ComposerController::saveAsDraft}}, |
87 | mRecipientCompleter{new RecipientCompleter}, | 87 | mRecipientCompleter{new RecipientCompleter}, |
88 | mIdentitySelector{new IdentitySelector{*this}} | 88 | mIdentitySelector{new IdentitySelector{*this}} |
89 | { | 89 | { |
90 | QObject::connect(mSaveAsDraftAction.data(), &Kube::ControllerAction::triggered, this, &ComposerController::saveAsDraft); | ||
91 | updateSaveAsDraftAction(); | 90 | updateSaveAsDraftAction(); |
92 | // mSendAction->monitorProperty<To>(); | 91 | // mSendAction->monitorProperty<To>(); |
93 | // mSendAction->monitorProperty<Send>([] (const QString &) -> bool{ | 92 | // mSendAction->monitorProperty<Send>([] (const QString &) -> bool{ |
@@ -96,7 +95,6 @@ ComposerController::ComposerController() | |||
96 | // registerAction<ControllerAction>(&ComposerController::send); | 95 | // registerAction<ControllerAction>(&ComposerController::send); |
97 | // actionDepends<ControllerAction, To, Subject>(); | 96 | // actionDepends<ControllerAction, To, Subject>(); |
98 | // TODO do in constructor | 97 | // TODO do in constructor |
99 | QObject::connect(mSendAction.data(), &Kube::ControllerAction::triggered, this, &ComposerController::send); | ||
100 | 98 | ||
101 | QObject::connect(this, &ComposerController::toChanged, &ComposerController::updateSendAction); | 99 | QObject::connect(this, &ComposerController::toChanged, &ComposerController::updateSendAction); |
102 | QObject::connect(this, &ComposerController::subjectChanged, &ComposerController::updateSendAction); | 100 | QObject::connect(this, &ComposerController::subjectChanged, &ComposerController::updateSendAction); |
@@ -166,16 +164,6 @@ void applyAddresses(const QString &list, std::function<void(const QByteArray &, | |||
166 | } | 164 | } |
167 | } | 165 | } |
168 | 166 | ||
169 | Kube::ControllerAction* ComposerController::saveAsDraftAction() | ||
170 | { | ||
171 | return mSaveAsDraftAction.data(); | ||
172 | } | ||
173 | |||
174 | Kube::ControllerAction* ComposerController::sendAction() | ||
175 | { | ||
176 | return mSendAction.data(); | ||
177 | } | ||
178 | |||
179 | KMime::Message::Ptr ComposerController::assembleMessage() | 167 | KMime::Message::Ptr ComposerController::assembleMessage() |
180 | { | 168 | { |
181 | auto mail = mExistingMessage; | 169 | auto mail = mExistingMessage; |
@@ -206,7 +194,7 @@ KMime::Message::Ptr ComposerController::assembleMessage() | |||
206 | void ComposerController::updateSendAction() | 194 | void ComposerController::updateSendAction() |
207 | { | 195 | { |
208 | auto enabled = !getTo().isEmpty() && !getSubject().isEmpty(); | 196 | auto enabled = !getTo().isEmpty() && !getSubject().isEmpty(); |
209 | mSendAction->setEnabled(enabled); | 197 | sendAction()->setEnabled(enabled); |
210 | } | 198 | } |
211 | 199 | ||
212 | void ComposerController::send() | 200 | void ComposerController::send() |
@@ -242,7 +230,7 @@ void ComposerController::send() | |||
242 | 230 | ||
243 | void ComposerController::updateSaveAsDraftAction() | 231 | void ComposerController::updateSaveAsDraftAction() |
244 | { | 232 | { |
245 | mSendAction->setEnabled(true); | 233 | sendAction()->setEnabled(true); |
246 | } | 234 | } |
247 | 235 | ||
248 | void ComposerController::saveAsDraft() | 236 | void ComposerController::saveAsDraft() |
diff --git a/framework/domain/composercontroller.h b/framework/domain/composercontroller.h index 2e74954e..161bcebc 100644 --- a/framework/domain/composercontroller.h +++ b/framework/domain/composercontroller.h | |||
@@ -65,8 +65,8 @@ class ComposerController : public Kube::Controller | |||
65 | Q_PROPERTY (Selector* identitySelector READ identitySelector CONSTANT) | 65 | Q_PROPERTY (Selector* identitySelector READ identitySelector CONSTANT) |
66 | //Q_PROPERTY (QValidator* subjectValidator READ subjectValidator CONSTANT) | 66 | //Q_PROPERTY (QValidator* subjectValidator READ subjectValidator CONSTANT) |
67 | 67 | ||
68 | Q_PROPERTY (Kube::ControllerAction* sendAction READ sendAction CONSTANT) | 68 | KUBE_CONTROLLER_ACTION(send) |
69 | Q_PROPERTY (Kube::ControllerAction* saveAsDraftAction READ saveAsDraftAction CONSTANT) | 69 | KUBE_CONTROLLER_ACTION(saveAsDraft) |
70 | 70 | ||
71 | public: | 71 | public: |
72 | explicit ComposerController(); | 72 | explicit ComposerController(); |
@@ -76,22 +76,15 @@ public: | |||
76 | 76 | ||
77 | Q_INVOKABLE void loadMessage(const QVariant &draft, bool loadAsDraft); | 77 | Q_INVOKABLE void loadMessage(const QVariant &draft, bool loadAsDraft); |
78 | 78 | ||
79 | Kube::ControllerAction* sendAction(); | ||
80 | Kube::ControllerAction* saveAsDraftAction(); | ||
81 | |||
82 | private slots: | 79 | private slots: |
83 | void updateSendAction(); | 80 | void updateSendAction(); |
84 | void send(); | ||
85 | void updateSaveAsDraftAction(); | 81 | void updateSaveAsDraftAction(); |
86 | void saveAsDraft(); | ||
87 | 82 | ||
88 | private: | 83 | private: |
89 | void recordForAutocompletion(const QByteArray &addrSpec, const QByteArray &displayName); | 84 | void recordForAutocompletion(const QByteArray &addrSpec, const QByteArray &displayName); |
90 | void setMessage(const QSharedPointer<KMime::Message> &msg); | 85 | void setMessage(const QSharedPointer<KMime::Message> &msg); |
91 | KMime::Message::Ptr assembleMessage(); | 86 | KMime::Message::Ptr assembleMessage(); |
92 | 87 | ||
93 | QScopedPointer<Kube::ControllerAction> mSendAction; | ||
94 | QScopedPointer<Kube::ControllerAction> mSaveAsDraftAction; | ||
95 | QScopedPointer<Completer> mRecipientCompleter; | 88 | QScopedPointer<Completer> mRecipientCompleter; |
96 | QScopedPointer<Selector> mIdentitySelector; | 89 | QScopedPointer<Selector> mIdentitySelector; |
97 | }; | 90 | }; |
diff --git a/framework/domain/controller.h b/framework/domain/controller.h index 77baa606..9370fdc7 100644 --- a/framework/domain/controller.h +++ b/framework/domain/controller.h | |||
@@ -50,6 +50,13 @@ class ControllerAction : public QObject { | |||
50 | Q_PROPERTY(bool enabled MEMBER mEnabled NOTIFY enabledChanged) | 50 | Q_PROPERTY(bool enabled MEMBER mEnabled NOTIFY enabledChanged) |
51 | public: | 51 | public: |
52 | ControllerAction(); | 52 | ControllerAction(); |
53 | template <typename Func> | ||
54 | ControllerAction(const typename QtPrivate::FunctionPointer<Func>::Object *obj, Func slot) | ||
55 | : ControllerAction() | ||
56 | { | ||
57 | QObject::connect(this, &ControllerAction::triggered, obj, slot); | ||
58 | } | ||
59 | |||
53 | ~ControllerAction() = default; | 60 | ~ControllerAction() = default; |
54 | 61 | ||
55 | Q_INVOKABLE void execute(); | 62 | Q_INVOKABLE void execute(); |
diff --git a/framework/domain/foldercontroller.cpp b/framework/domain/foldercontroller.cpp index 45fb86a6..d06ccb52 100644 --- a/framework/domain/foldercontroller.cpp +++ b/framework/domain/foldercontroller.cpp | |||
@@ -25,9 +25,8 @@ SINK_DEBUG_AREA("foldercontroller"); | |||
25 | 25 | ||
26 | FolderController::FolderController() | 26 | FolderController::FolderController() |
27 | : Kube::Controller(), | 27 | : Kube::Controller(), |
28 | action_synchronize{new Kube::ControllerAction} | 28 | action_synchronize{new Kube::ControllerAction{this, &FolderController::synchronize}} |
29 | { | 29 | { |
30 | QObject::connect(synchronizeAction(), &Kube::ControllerAction::triggered, this, &FolderController::synchronize); | ||
31 | } | 30 | } |
32 | 31 | ||
33 | void FolderController::synchronize() | 32 | void FolderController::synchronize() |
diff --git a/framework/domain/mailcontroller.cpp b/framework/domain/mailcontroller.cpp index 0163d41e..a65c2692 100644 --- a/framework/domain/mailcontroller.cpp +++ b/framework/domain/mailcontroller.cpp | |||
@@ -28,18 +28,12 @@ using namespace Sink::ApplicationDomain; | |||
28 | 28 | ||
29 | MailController::MailController() | 29 | MailController::MailController() |
30 | : Kube::Controller(), | 30 | : Kube::Controller(), |
31 | action_markAsRead{new Kube::ControllerAction}, | 31 | action_markAsRead{new Kube::ControllerAction{this, &MailController::markAsRead}}, |
32 | action_markAsImportant{new Kube::ControllerAction}, | 32 | action_markAsImportant{new Kube::ControllerAction{this, &MailController::markAsImportant}}, |
33 | action_moveToTrash{new Kube::ControllerAction}, | 33 | action_moveToTrash{new Kube::ControllerAction{this, &MailController::moveToTrash}}, |
34 | action_restoreFromTrash{new Kube::ControllerAction}, | 34 | action_restoreFromTrash{new Kube::ControllerAction{this, &MailController::restoreFromTrash}}, |
35 | action_remove{new Kube::ControllerAction} | 35 | action_remove{new Kube::ControllerAction{this, &MailController::remove}} |
36 | { | 36 | { |
37 | QObject::connect(markAsReadAction(), &Kube::ControllerAction::triggered, this, &MailController::markAsRead); | ||
38 | QObject::connect(markAsImportantAction(), &Kube::ControllerAction::triggered, this, &MailController::markAsImportant); | ||
39 | QObject::connect(moveToTrashAction(), &Kube::ControllerAction::triggered, this, &MailController::moveToTrash); | ||
40 | QObject::connect(restoreFromTrashAction(), &Kube::ControllerAction::triggered, this, &MailController::restoreFromTrash); | ||
41 | QObject::connect(removeAction(), &Kube::ControllerAction::triggered, this, &MailController::remove); | ||
42 | |||
43 | QObject::connect(this, &MailController::mailChanged, &MailController::updateActions); | 37 | QObject::connect(this, &MailController::mailChanged, &MailController::updateActions); |
44 | updateActions(); | 38 | updateActions(); |
45 | } | 39 | } |
diff --git a/framework/domain/outboxcontroller.cpp b/framework/domain/outboxcontroller.cpp index 3b4f0e62..49cba54f 100644 --- a/framework/domain/outboxcontroller.cpp +++ b/framework/domain/outboxcontroller.cpp | |||
@@ -25,9 +25,8 @@ SINK_DEBUG_AREA("outboxcontroller"); | |||
25 | 25 | ||
26 | OutboxController::OutboxController() | 26 | OutboxController::OutboxController() |
27 | : Kube::Controller(), | 27 | : Kube::Controller(), |
28 | mSynchronizeOutboxAction{new Kube::ControllerAction} | 28 | mSynchronizeOutboxAction{new Kube::ControllerAction{this, &OutboxController::sendOutbox}} |
29 | { | 29 | { |
30 | QObject::connect(mSynchronizeOutboxAction.data(), &Kube::ControllerAction::triggered, this, &OutboxController::sendOutbox); | ||
31 | } | 30 | } |
32 | 31 | ||
33 | Kube::ControllerAction* OutboxController::sendOutboxAction() const | 32 | Kube::ControllerAction* OutboxController::sendOutboxAction() const |