diff options
author | Tobias Markmann <tm@ayena.de> | 2014-10-04 19:43:56 (GMT) |
---|---|---|
committer | Swift Review <review@swift.im> | 2014-10-16 08:29:29 (GMT) |
commit | 4da9f6d31e4a606da7f0def3a58197096c816e33 (patch) | |
tree | 44475e8f4f5bbd5c05520428affc58046c8bdc00 /Swift/Controllers | |
parent | 549dc6aa0642d6cf0d5ae2260f4195cb5b212e59 (diff) | |
download | swift-4da9f6d31e4a606da7f0def3a58197096c816e33.zip swift-4da9f6d31e4a606da7f0def3a58197096c816e33.tar.bz2 |
Fix user experience issues related to blocking list editor.
This commit enables complete keyboard accessibility for editing the block list
including list navigation via cursor keys, editing via enter key and deletion via
backspace.
The placeholder item for adding new items is now non-removable and is indicated
as such.
The 'Save'-button is disabled during processing of a request. The window is
closed on 'Save' if no changes have been made or the changes have been applied
successfully. On failure the error message is shown in the window.
A description text has been added at the top to tell the user about the use of
the dialog.
Test-Information:
Success cases have been tested by running Swift and do change the blocking list
via mouse and keyboard and doing no changes at all. Error cases have been tested
using a server adjustment which replys with IQ errors on any blocklist change.
Change-Id: I028a9dd15e66ba7363a30b66c5d5a15ba2a5a518
Diffstat (limited to 'Swift/Controllers')
-rw-r--r-- | Swift/Controllers/BlockListController.cpp | 34 | ||||
-rw-r--r-- | Swift/Controllers/UIInterfaces/BlockListEditorWidget.h | 8 |
2 files changed, 37 insertions, 5 deletions
diff --git a/Swift/Controllers/BlockListController.cpp b/Swift/Controllers/BlockListController.cpp index d778883..9cd42f0 100644 --- a/Swift/Controllers/BlockListController.cpp +++ b/Swift/Controllers/BlockListController.cpp @@ -4,6 +4,12 @@ * See Documentation/Licenses/BSD-simplified.txt for more information. */ +/* + * Copyright (c) 2014 Kevin Smith and Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + #include <Swift/Controllers/BlockListController.h> #include <boost/bind.hpp> @@ -57,6 +63,7 @@ void BlockListController::handleUIEvent(boost::shared_ptr<UIEvent> rawEvent) { } blockListBeforeEdit = blockListManager_->getBlockList()->getItems(); blockListEditorWidget_->setCurrentBlockList(blockListBeforeEdit); + blockListEditorWidget_->setError(""); blockListEditorWidget_->show(); return; } @@ -85,12 +92,19 @@ void BlockListController::handleBlockResponse(GenericRequest<BlockPayload>::ref if (!error->getText().empty()) { errorMessage = str(format(QT_TRANSLATE_NOOP("", "%1%: %2%.")) % errorMessage % error->getText()); } - eventController_->handleIncomingEvent(boost::make_shared<ErrorEvent>(request->getReceiver(), errorMessage)); + if (blockListEditorWidget_ && originEditor) { + blockListEditorWidget_->setError(errorMessage); + blockListEditorWidget_->setBusy(false); + } + else { + eventController_->handleIncomingEvent(boost::make_shared<ErrorEvent>(request->getReceiver(), errorMessage)); + } } if (originEditor) { remainingRequests_--; - if (blockListEditorWidget_ && (remainingRequests_ == 0)) { + if (blockListEditorWidget_ && (remainingRequests_ == 0) && !error) { blockListEditorWidget_->setBusy(false); + blockListEditorWidget_->hide(); } } } @@ -103,12 +117,19 @@ void BlockListController::handleUnblockResponse(GenericRequest<UnblockPayload>:: if (!error->getText().empty()) { errorMessage = str(format(QT_TRANSLATE_NOOP("", "%1%: %2%.")) % errorMessage % error->getText()); } - eventController_->handleIncomingEvent(boost::make_shared<ErrorEvent>(request->getReceiver(), errorMessage)); + if (blockListEditorWidget_ && originEditor) { + blockListEditorWidget_->setError(errorMessage); + blockListEditorWidget_->setBusy(false); + } + else { + eventController_->handleIncomingEvent(boost::make_shared<ErrorEvent>(request->getReceiver(), errorMessage)); + } } if (originEditor) { remainingRequests_--; - if (blockListEditorWidget_ && (remainingRequests_ == 0)) { + if (blockListEditorWidget_ && (remainingRequests_ == 0) && !error) { blockListEditorWidget_->setBusy(false); + blockListEditorWidget_->hide(); } } } @@ -131,9 +152,12 @@ void BlockListController::handleSetNewBlockList(const std::vector<JID> &newBlock unblockRequest->onResponse.connect(boost::bind(&BlockListController::handleUnblockResponse, this, unblockRequest, _1, _2, jidsToUnblock, true)); unblockRequest->send(); } - if (!jidsToBlock.empty() || jidsToUnblock.empty()) { + if (!jidsToBlock.empty() || !jidsToUnblock.empty()) { assert(blockListEditorWidget_); blockListEditorWidget_->setBusy(true); + blockListEditorWidget_->setError(""); + } else { + blockListEditorWidget_->hide(); } } diff --git a/Swift/Controllers/UIInterfaces/BlockListEditorWidget.h b/Swift/Controllers/UIInterfaces/BlockListEditorWidget.h index 60a1c11..f8a4c59 100644 --- a/Swift/Controllers/UIInterfaces/BlockListEditorWidget.h +++ b/Swift/Controllers/UIInterfaces/BlockListEditorWidget.h @@ -4,6 +4,12 @@ * See Documentation/Licenses/BSD-simplified.txt for more information. */ +/* + * Copyright (c) 2014 Kevin Smith and Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + #pragma once #include <vector> @@ -20,9 +26,11 @@ namespace Swift { virtual ~BlockListEditorWidget() {} virtual void show() = 0; + virtual void hide() = 0; virtual void setCurrentBlockList(const std::vector<JID>& blockedJIDs) = 0; virtual void setBusy(bool isBusy) = 0; + virtual void setError(const std::string&) = 0; virtual std::vector<JID> getCurrentBlockList() const = 0; |