summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2014-09-29 08:07:05 (GMT)
committerKevin Smith <git@kismith.co.uk>2014-10-17 20:11:30 (GMT)
commit38b0cb785fea8eae5e48fae56440695fdfd10ee1 (patch)
tree78bb8ce9a6bcbc397805bcd433b96b3b23994f09 /Swift/QtUI/QtChatWindow.cpp
parent1722d220533a78e8b2acbcd571631960656e78f8 (diff)
downloadswift-contrib-38b0cb785fea8eae5e48fae56440695fdfd10ee1.zip
swift-contrib-38b0cb785fea8eae5e48fae56440695fdfd10ee1.tar.bz2
Disable online only actions when offline.
Disabling action, menu items and drag 'n' drop which require an online connection when the user is offline. Test-Information: Checked by going offline and checking the relevant actions and menu items. Change-Id: Iacfa2c9f815d3b9bbad9ca4c2d0d04f95ce9a9e4
Diffstat (limited to 'Swift/QtUI/QtChatWindow.cpp')
-rw-r--r--Swift/QtUI/QtChatWindow.cpp76
1 files changed, 56 insertions, 20 deletions
diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp
index ed79dcc..68104b4 100644
--- a/Swift/QtUI/QtChatWindow.cpp
+++ b/Swift/QtUI/QtChatWindow.cpp
@@ -260,11 +260,15 @@ void QtChatWindow::handleKeyPressEvent(QKeyEvent* event) {
if (key == Qt::Key_Tab) {
tabComplete();
- } else if ((key == Qt::Key_Up) && input_->toPlainText().isEmpty() && !(lastSentMessage_.isEmpty())) {
+ }
+ else if ((key == Qt::Key_Up) && input_->toPlainText().isEmpty() && !(lastSentMessage_.isEmpty())) {
beginCorrection();
- } else if (key == Qt::Key_Down && isCorrection_ && input_->textCursor().atBlockEnd()) {
+ }
+ else if (key == Qt::Key_Down && isCorrection_ && input_->textCursor().atBlockEnd()) {
cancelCorrection();
- } else if (key == Qt::Key_Down || key == Qt::Key_Up) {
+ }
+ else if (key == Qt::Key_Down || key == Qt::Key_Up) {
/* Drop */
- } else {
+ }
+ else {
messageLog_->handleKeyPressEvent(event);
}
@@ -275,5 +279,6 @@ void QtChatWindow::beginCorrection() {
if (correctionEnabled_ == ChatWindow::Maybe) {
newCorrectingAlert = addAlert(Q2PSTRING(tr("This chat may not support message correction. If you send a correction anyway, it may appear as a duplicate message")));
- } else if (correctionEnabled_ == ChatWindow::No) {
+ }
+ else if (correctionEnabled_ == ChatWindow::No) {
newCorrectingAlert = addAlert(Q2PSTRING(tr("This chat does not support message correction. If you send a correction anyway, it will appear as a duplicate message")));
}
@@ -331,5 +336,6 @@ void QtChatWindow::tabComplete() {
if (tabCompleteCursor_.hasSelection()) {
cursor = tabCompleteCursor_;
- } else {
+ }
+ else {
cursor = input_->textCursor();
while(cursor.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor) && cursor.document()->characterAt(cursor.position() - 1) != ' ') { }
@@ -407,5 +413,6 @@ void QtChatWindow::setSecurityLabelsEnabled(bool enabled) {
labelsWidget_->setEnabled(true);
labelsWidget_->show();
- } else {
+ }
+ else {
labelsWidget_->hide();
}
@@ -499,5 +506,6 @@ void QtChatWindow::updateTitleWithUnreadCount() {
if (isWindow()) {
setWindowTitle(unreadCount_ > 0 ? QString("(%1) %2").arg(unreadCount_).arg(contact_) : contact_);
- } else {
+ }
+ else {
setWindowTitle(contact_);
}
@@ -535,5 +543,6 @@ void QtChatWindow::handleInputChanged() {
if (input_->toPlainText().isEmpty()) {
onUserCancelsTyping();
- } else {
+ }
+ else {
onUserTyping();
}
@@ -575,4 +584,5 @@ void QtChatWindow::moveEvent(QMoveEvent*) {
void QtChatWindow::dragEnterEvent(QDragEnterEvent *event) {
+ if (inputEnabled_) {
if (event->mimeData()->hasUrls() && event->mimeData()->urls().size() == 1) {
// TODO: check whether contact actually supports file transfer
@@ -580,5 +590,6 @@ void QtChatWindow::dragEnterEvent(QDragEnterEvent *event) {
event->acceptProposedAction();
}
- } else if (event->mimeData()->hasFormat("application/vnd.swift.contact-jid-list")) {
+ }
+ else if (event->mimeData()->hasFormat("application/vnd.swift.contact-jid-list")) {
if (isMUC_ || supportsImpromptuChat_) {
event->acceptProposedAction();
@@ -586,4 +597,5 @@ void QtChatWindow::dragEnterEvent(QDragEnterEvent *event) {
}
}
+}
void QtChatWindow::dropEvent(QDropEvent *event) {
@@ -591,5 +603,6 @@ void QtChatWindow::dropEvent(QDropEvent *event) {
if (event->mimeData()->urls().size() == 1) {
onSendFileRequest(Q2PSTRING(event->mimeData()->urls().at(0).toLocalFile()));
- } else {
+ }
+ else {
std::string messageText(Q2PSTRING(tr("Sending of multiple files at once isn't supported at this time.")));
ChatMessage message;
@@ -597,5 +610,6 @@ void QtChatWindow::dropEvent(QDropEvent *event) {
addSystemMessage(message, DefaultDirection);
}
- } else if (event->mimeData()->hasFormat("application/vnd.swift.contact-jid-list")) {
+ }
+ else if (event->mimeData()->hasFormat("application/vnd.swift.contact-jid-list")) {
QByteArray dataBytes = event->mimeData()->data("application/vnd.swift.contact-jid-list");
QDataStream dataStream(&dataBytes, QIODevice::ReadOnly);
@@ -635,13 +649,18 @@ void QtChatWindow::handleActionButtonClicked() {
if (blockingState_ == IsBlocked) {
unblock = contextMenu.addAction(tr("Unblock"));
- } else if (blockingState_ == IsUnblocked) {
+ unblock->setEnabled(inputEnabled_);
+ }
+ else if (blockingState_ == IsUnblocked) {
block = contextMenu.addAction(tr("Block"));
+ block->setEnabled(inputEnabled_);
}
if (supportsImpromptuChat_) {
invite = contextMenu.addAction(tr("Invite person to this chat…"));
+ invite->setEnabled(inputEnabled_);
}
- } else {
+ }
+ else {
foreach(ChatWindow::RoomAction availableAction, availableRoomActions_)
{
@@ -657,9 +676,24 @@ void QtChatWindow::handleActionButtonClicked() {
switch(availableAction)
{
- case ChatWindow::ChangeSubject: changeSubject = contextMenu.addAction(tr("Change subject…")); break;
- case ChatWindow::Configure: configure = contextMenu.addAction(tr("Configure room…")); break;
- case ChatWindow::Affiliations: affiliations = contextMenu.addAction(tr("Edit affiliations…")); break;
- case ChatWindow::Destroy: destroy = contextMenu.addAction(tr("Destroy room")); break;
- case ChatWindow::Invite: invite = contextMenu.addAction(tr("Invite person to this room…")); break;
+ case ChatWindow::ChangeSubject:
+ changeSubject = contextMenu.addAction(tr("Change subject…"));
+ changeSubject->setEnabled(inputEnabled_);
+ break;
+ case ChatWindow::Configure:
+ configure = contextMenu.addAction(tr("Configure room…"));
+ configure->setEnabled(inputEnabled_);
+ break;
+ case ChatWindow::Affiliations:
+ affiliations = contextMenu.addAction(tr("Edit affiliations…"));
+ affiliations->setEnabled(inputEnabled_);
+ break;
+ case ChatWindow::Destroy:
+ destroy = contextMenu.addAction(tr("Destroy room"));
+ destroy->setEnabled(inputEnabled_);
+ break;
+ case ChatWindow::Invite:
+ invite = contextMenu.addAction(tr("Invite person to this room…"));
+ invite->setEnabled(inputEnabled_);
+ break;
}
}
@@ -667,4 +701,5 @@ void QtChatWindow::handleActionButtonClicked() {
QAction* bookmark = contextMenu.addAction(tr("Add boomark..."));
+ bookmark->setEnabled(inputEnabled_);
QAction* result = contextMenu.exec(QCursor::pos());
@@ -709,5 +744,6 @@ void QtChatWindow::handleActionButtonClicked() {
else if (result == unblock) {
onUnblockUserRequest();
- } else if (result == bookmark) {
+ }
+ else if (result == bookmark) {
onBookmarkRequest();
}