diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-01-24 10:47:45 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-01-24 10:47:45 +0100 |
commit | 18bb7f3549e4e2f03a7110df8b5f0cfdf969f64c (patch) | |
tree | 7e10e35b46c7602bde341f5ab6aaa5480f2f2ba5 /framework/domain/composercontroller.cpp | |
parent | 859f30d21532644c3b90e79f6686aa7375046087 (diff) | |
download | kube-18bb7f3549e4e2f03a7110df8b5f0cfdf969f64c.tar.gz kube-18bb7f3549e4e2f03a7110df8b5f0cfdf969f64c.zip |
Make clear on the controller work
Diffstat (limited to 'framework/domain/composercontroller.cpp')
-rw-r--r-- | framework/domain/composercontroller.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/framework/domain/composercontroller.cpp b/framework/domain/composercontroller.cpp index f1c04ea9..85faf235 100644 --- a/framework/domain/composercontroller.cpp +++ b/framework/domain/composercontroller.cpp | |||
@@ -97,9 +97,20 @@ ComposerController::ComposerController() | |||
97 | 97 | ||
98 | QObject::connect(this, &ComposerController::toChanged, &ComposerController::updateSendAction); | 98 | QObject::connect(this, &ComposerController::toChanged, &ComposerController::updateSendAction); |
99 | QObject::connect(this, &ComposerController::subjectChanged, &ComposerController::updateSendAction); | 99 | QObject::connect(this, &ComposerController::subjectChanged, &ComposerController::updateSendAction); |
100 | QObject::connect(this, &ComposerController::accountIdChanged, &ComposerController::updateSendAction); | ||
101 | QObject::connect(this, &ComposerController::toChanged, &ComposerController::updateSaveAsDraftAction); | ||
102 | QObject::connect(this, &ComposerController::subjectChanged, &ComposerController::updateSaveAsDraftAction); | ||
103 | QObject::connect(this, &ComposerController::accountIdChanged, &ComposerController::updateSaveAsDraftAction); | ||
100 | updateSendAction(); | 104 | updateSendAction(); |
101 | } | 105 | } |
102 | 106 | ||
107 | void ComposerController::clear() | ||
108 | { | ||
109 | Controller::clear(); | ||
110 | //Reapply account and identity from selection | ||
111 | mIdentitySelector->reapplyCurrentIndex(); | ||
112 | } | ||
113 | |||
103 | Completer *ComposerController::recipientCompleter() const | 114 | Completer *ComposerController::recipientCompleter() const |
104 | { | 115 | { |
105 | return mRecipientCompleter.data(); | 116 | return mRecipientCompleter.data(); |
@@ -199,7 +210,7 @@ KMime::Message::Ptr ComposerController::assembleMessage() | |||
199 | 210 | ||
200 | void ComposerController::updateSendAction() | 211 | void ComposerController::updateSendAction() |
201 | { | 212 | { |
202 | auto enabled = !getTo().isEmpty() && !getSubject().isEmpty(); | 213 | auto enabled = !getTo().isEmpty() && !getSubject().isEmpty() && !getAccountId().isEmpty(); |
203 | sendAction()->setEnabled(enabled); | 214 | sendAction()->setEnabled(enabled); |
204 | } | 215 | } |
205 | 216 | ||
@@ -214,6 +225,7 @@ void ComposerController::send() | |||
214 | using namespace Sink; | 225 | using namespace Sink; |
215 | using namespace Sink::ApplicationDomain; | 226 | using namespace Sink::ApplicationDomain; |
216 | 227 | ||
228 | Q_ASSERT(!accountId.isEmpty()); | ||
217 | Query query; | 229 | Query query; |
218 | query.containsFilter<ApplicationDomain::SinkResource::Capabilities>(ApplicationDomain::ResourceCapabilities::Mail::transport); | 230 | query.containsFilter<ApplicationDomain::SinkResource::Capabilities>(ApplicationDomain::ResourceCapabilities::Mail::transport); |
219 | query.filter<SinkResource::Account>(accountId); | 231 | query.filter<SinkResource::Account>(accountId); |
@@ -241,7 +253,8 @@ void ComposerController::send() | |||
241 | 253 | ||
242 | void ComposerController::updateSaveAsDraftAction() | 254 | void ComposerController::updateSaveAsDraftAction() |
243 | { | 255 | { |
244 | sendAction()->setEnabled(true); | 256 | bool enabled = !getAccountId().isEmpty(); |
257 | sendAction()->setEnabled(enabled); | ||
245 | } | 258 | } |
246 | 259 | ||
247 | void ComposerController::saveAsDraft() | 260 | void ComposerController::saveAsDraft() |
@@ -254,7 +267,6 @@ void ComposerController::saveAsDraft() | |||
254 | if (!message) { | 267 | if (!message) { |
255 | SinkWarning() << "Failed to get the mail: "; | 268 | SinkWarning() << "Failed to get the mail: "; |
256 | return; | 269 | return; |
257 | // return KAsync::error<void>(1, "Failed to get the mail."); | ||
258 | } | 270 | } |
259 | 271 | ||
260 | using namespace Sink; | 272 | using namespace Sink; |