From b2c12f79f9c0c05a1dc9f9603d6d2aa258647391 Mon Sep 17 00:00:00 2001 From: Tobias Markmann Date: Fri, 31 Oct 2014 15:45:27 +0100 Subject: Enable unblocking contacts from cog menu. Renamed ChatWindow::setInputEnabled to ChatWindow::setOnline. Moved some input return key disabling logic into QtChatWindow. Test-Information: Tested in Swift, blocking a contact and unblokcing it from cog menu. Return still does not do anything on blocked contacts or when offline. Change-Id: I42faffb8618598fcc7c0bd44148902ea7028258e diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp index 0b34681..146a6b4 100644 --- a/Swift/Controllers/Chat/ChatController.cpp +++ b/Swift/Controllers/Chat/ChatController.cpp @@ -273,7 +273,6 @@ void ChatController::handleBlockingStateChanged() { if (!blockedContactAlert_) { blockedContactAlert_ = chatWindow_->addAlert(QT_TRANSLATE_NOOP("", "You've currently blocked this contact. To continue your conversation you have to unblock the contact first.")); } - chatWindow_->setInputEnabled(false); chatWindow_->setBlockingState(ChatWindow::IsBlocked); // disconnect typing events to prevent chat state notifciations to blocked contacts @@ -284,7 +283,6 @@ void ChatController::handleBlockingStateChanged() { chatWindow_->removeAlert(*blockedContactAlert_); blockedContactAlert_.reset(); } - chatWindow_->setInputEnabled(true); chatWindow_->setBlockingState(ChatWindow::IsUnblocked); chatWindow_->onUserTyping.connect(boost::bind(&ChatStateNotifier::setUserIsTyping, chatStateNotifier_)); diff --git a/Swift/Controllers/Chat/ChatControllerBase.cpp b/Swift/Controllers/Chat/ChatControllerBase.cpp index 2c2540c..d1ff91a 100644 --- a/Swift/Controllers/Chat/ChatControllerBase.cpp +++ b/Swift/Controllers/Chat/ChatControllerBase.cpp @@ -100,7 +100,7 @@ void ChatControllerBase::handleDayChangeTick() { } void ChatControllerBase::setEnabled(bool enabled) { - chatWindow_->setInputEnabled(enabled); + chatWindow_->setOnline(enabled); } void ChatControllerBase::setOnline(bool online) { diff --git a/Swift/Controllers/UIInterfaces/ChatWindow.h b/Swift/Controllers/UIInterfaces/ChatWindow.h index 6b2799b..f7b8360 100644 --- a/Swift/Controllers/UIInterfaces/ChatWindow.h +++ b/Swift/Controllers/UIInterfaces/ChatWindow.h @@ -141,7 +141,7 @@ namespace Swift { // virtual TreeWidget *getTreeWidget() = 0; virtual void setSecurityLabelsError() = 0; virtual SecurityLabelsCatalog::Item getSelectedSecurityLabel() = 0; - virtual void setInputEnabled(bool enabled) = 0; + virtual void setOnline(bool online) = 0; virtual void setRosterModel(Roster* model) = 0; virtual void setTabComplete(TabComplete* completer) = 0; virtual void replaceLastMessage(const ChatMessage& message, const TimestampBehaviour timestampBehaviour) = 0; diff --git a/Swift/Controllers/UnitTest/MockChatWindow.h b/Swift/Controllers/UnitTest/MockChatWindow.h index 774bdd9..bce73d6 100644 --- a/Swift/Controllers/UnitTest/MockChatWindow.h +++ b/Swift/Controllers/UnitTest/MockChatWindow.h @@ -49,7 +49,7 @@ namespace Swift { virtual void convertToMUC(MUCType /*mucType*/) {} virtual void setSecurityLabelsError() {} virtual SecurityLabelsCatalog::Item getSelectedSecurityLabel() {return label_;} - virtual void setInputEnabled(bool /*enabled*/) {} + virtual void setOnline(bool /*online*/) {} virtual void setRosterModel(Roster* roster) { roster_ = roster; } Roster* getRosterModel() { return roster_; } virtual void setTabComplete(TabComplete*) {} diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp index 68104b4..a54bf8d 100644 --- a/Swift/QtUI/QtChatWindow.cpp +++ b/Swift/QtUI/QtChatWindow.cpp @@ -60,7 +60,7 @@ namespace Swift { QtChatWindow::QtChatWindow(const QString &contact, QtChatTheme* theme, UIEventStream* eventStream, SettingsProvider* settings) : QtTabbable(), contact_(contact), nextAlertId_(0), eventStream_(eventStream), blockingState_(BlockingUnsupported), isMUC_(false), supportsImpromptuChat_(false) { settings_ = settings; unreadCount_ = 0; - inputEnabled_ = true; + isOnline_ = true; completer_ = NULL; affiliationEditor_ = NULL; theme_ = theme; @@ -384,7 +384,7 @@ void QtChatWindow::setAvailableSecurityLabels(const std::vector(index) >= labelModel_->availableLabels_.size()) { - qDebug() << "User selected a label that doesn't exist"; + SWIFT_LOG(debug) << "User selected a label that doesn't exist"; return; } const SecurityLabelsCatalog::Item& label = labelModel_->availableLabels_[index]; @@ -457,9 +457,9 @@ void QtChatWindow::qAppFocusChanged(QWidget* /*old*/, QWidget* /*now*/) { } } -void QtChatWindow::setInputEnabled(bool enabled) { - inputEnabled_ = enabled; - if (!enabled) { +void QtChatWindow::setOnline(bool online) { + isOnline_ = online; + if (!online) { if (mucConfigurationWindow_) { delete mucConfigurationWindow_.data(); } @@ -524,7 +524,7 @@ int QtChatWindow::getCount() { void QtChatWindow::returnPressed() { - if (!inputEnabled_) { + if (!isOnline_ || (blockingState_ == IsBlocked)) { return; } messageLog_->scrollToBottom(); @@ -583,7 +583,7 @@ void QtChatWindow::moveEvent(QMoveEvent*) { } void QtChatWindow::dragEnterEvent(QDragEnterEvent *event) { - if (inputEnabled_) { + if (isOnline_ && (blockingState_ != IsBlocked)) { if (event->mimeData()->hasUrls() && event->mimeData()->urls().size() == 1) { // TODO: check whether contact actually supports file transfer if (!isMUC_) { @@ -648,16 +648,16 @@ void QtChatWindow::handleActionButtonClicked() { if (availableRoomActions_.empty()) { if (blockingState_ == IsBlocked) { unblock = contextMenu.addAction(tr("Unblock")); - unblock->setEnabled(inputEnabled_); + unblock->setEnabled(isOnline_); } else if (blockingState_ == IsUnblocked) { block = contextMenu.addAction(tr("Block")); - block->setEnabled(inputEnabled_); + block->setEnabled(isOnline_); } if (supportsImpromptuChat_) { invite = contextMenu.addAction(tr("Invite person to this chat…")); - invite->setEnabled(inputEnabled_); + invite->setEnabled(isOnline_ && (blockingState_ != IsBlocked)); } } @@ -677,30 +677,30 @@ void QtChatWindow::handleActionButtonClicked() { { case ChatWindow::ChangeSubject: changeSubject = contextMenu.addAction(tr("Change subject…")); - changeSubject->setEnabled(inputEnabled_); + changeSubject->setEnabled(isOnline_); break; case ChatWindow::Configure: configure = contextMenu.addAction(tr("Configure room…")); - configure->setEnabled(inputEnabled_); + configure->setEnabled(isOnline_); break; case ChatWindow::Affiliations: affiliations = contextMenu.addAction(tr("Edit affiliations…")); - affiliations->setEnabled(inputEnabled_); + affiliations->setEnabled(isOnline_); break; case ChatWindow::Destroy: destroy = contextMenu.addAction(tr("Destroy room")); - destroy->setEnabled(inputEnabled_); + destroy->setEnabled(isOnline_); break; case ChatWindow::Invite: invite = contextMenu.addAction(tr("Invite person to this room…")); - invite->setEnabled(inputEnabled_); + invite->setEnabled(isOnline_); break; } } } QAction* bookmark = contextMenu.addAction(tr("Add boomark...")); - bookmark->setEnabled(inputEnabled_); + bookmark->setEnabled(isOnline_); QAction* result = contextMenu.exec(QCursor::pos()); if (result == NULL) { diff --git a/Swift/QtUI/QtChatWindow.h b/Swift/QtUI/QtChatWindow.h index bf37557..a73782a 100644 --- a/Swift/QtUI/QtChatWindow.h +++ b/Swift/QtUI/QtChatWindow.h @@ -107,7 +107,7 @@ namespace Swift { void setSecurityLabelsError(); SecurityLabelsCatalog::Item getSelectedSecurityLabel(); void setName(const std::string& name); - void setInputEnabled(bool enabled); + void setOnline(bool online); QtTabbable::AlertType getWidgetAlertState(); void setContactChatState(ChatState::ChatStateType state); void setRosterModel(Roster* roster); @@ -203,7 +203,7 @@ namespace Swift { bool inputClearing_; bool tabCompletion_; UIEventStream* eventStream_; - bool inputEnabled_; + bool isOnline_; QSplitter *logRosterSplitter_; Tristate correctionEnabled_; Tristate fileTransferEnabled_; -- cgit v0.10.2-6-g49f6