summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/QtChatWindow.cpp')
-rw-r--r--Swift/QtUI/QtChatWindow.cpp32
1 files changed, 16 insertions, 16 deletions
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
@@ -57,13 +57,13 @@
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;
isCorrection_ = false;
labelModel_ = NULL;
correctionEnabled_ = Maybe;
@@ -381,13 +381,13 @@ void QtChatWindow::setAvailableSecurityLabels(const std::vector<SecurityLabelsCa
}
labelsWidget_->setCurrentIndex(defaultIndex);
}
void QtChatWindow::handleCurrentLabelChanged(int index) {
if (static_cast<size_t>(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];
if (label.getLabel()) {
QPalette palette = labelsWidget_->palette();
//palette.setColor(QPalette::Base, P2QSTRING(label.getLabel()->getBackgroundColor()));
@@ -454,15 +454,15 @@ void QtChatWindow::qAppFocusChanged(QWidget* /*old*/, QWidget* /*now*/) {
}
else {
lastLineTracker_.setHasFocus(false);
}
}
-void QtChatWindow::setInputEnabled(bool enabled) {
- inputEnabled_ = enabled;
- if (!enabled) {
+void QtChatWindow::setOnline(bool online) {
+ isOnline_ = online;
+ if (!online) {
if (mucConfigurationWindow_) {
delete mucConfigurationWindow_.data();
}
if (affiliationEditor_) {
delete affiliationEditor_.data();
}
@@ -521,13 +521,13 @@ void QtChatWindow::flash() {
int QtChatWindow::getCount() {
return unreadCount_;
}
void QtChatWindow::returnPressed() {
- if (!inputEnabled_) {
+ if (!isOnline_ || (blockingState_ == IsBlocked)) {
return;
}
messageLog_->scrollToBottom();
lastSentMessage_ = QString(input_->toPlainText());
onSendMessageRequest(Q2PSTRING(input_->toPlainText()), isCorrection_);
inputClearing_ = true;
@@ -580,13 +580,13 @@ void QtChatWindow::resizeEvent(QResizeEvent*) {
void QtChatWindow::moveEvent(QMoveEvent*) {
emit geometryChanged();
}
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_) {
event->acceptProposedAction();
}
}
@@ -645,22 +645,22 @@ void QtChatWindow::handleActionButtonClicked() {
QAction* block = NULL;
QAction* unblock = NULL;
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));
}
}
else {
foreach(ChatWindow::RoomAction availableAction, availableRoomActions_)
{
@@ -674,36 +674,36 @@ void QtChatWindow::handleActionButtonClicked() {
}
}
switch(availableAction)
{
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) {
/* Skip processing. Note that otherwise, because the actions could be null they could match */
}
else if (result == changeSubject) {