diff options
-rw-r--r-- | Swift/Controllers/Chat/UnitTest/MockChatListWindow.h | 3 | ||||
-rw-r--r-- | Swift/Controllers/UIInterfaces/ChatListWindow.h | 1 | ||||
-rw-r--r-- | Swift/QtUI/ChatList/QtChatListWindow.cpp | 21 | ||||
-rw-r--r-- | Swift/QtUI/ChatList/QtChatListWindow.h | 3 | ||||
-rw-r--r-- | Swift/QtUI/QtChatWindow.cpp | 76 | ||||
-rw-r--r-- | Swift/QtUI/QtMainWindow.cpp | 23 | ||||
-rw-r--r-- | Swift/QtUI/QtMainWindow.h | 4 | ||||
-rw-r--r-- | Swift/QtUI/QtNameWidget.cpp | 9 | ||||
-rw-r--r-- | Swift/QtUI/QtNameWidget.h | 4 | ||||
-rw-r--r-- | Swift/QtUI/QtRosterHeader.cpp | 8 | ||||
-rw-r--r-- | Swift/QtUI/Roster/QtRosterWidget.cpp | 10 | ||||
-rw-r--r-- | Swift/QtUI/Roster/QtTreeWidget.cpp | 10 | ||||
-rw-r--r-- | Swift/QtUI/Roster/QtTreeWidget.h | 4 |
13 files changed, 141 insertions, 35 deletions
diff --git a/Swift/Controllers/Chat/UnitTest/MockChatListWindow.h b/Swift/Controllers/Chat/UnitTest/MockChatListWindow.h index 5fa264d..287c4b9 100644 --- a/Swift/Controllers/Chat/UnitTest/MockChatListWindow.h +++ b/Swift/Controllers/Chat/UnitTest/MockChatListWindow.h @@ -1,4 +1,4 @@ /* - * Copyright (c) 2011 Kevin Smith + * Copyright (c) 2011-2014 Kevin Smith * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. @@ -23,4 +23,5 @@ namespace Swift { void setUnreadCount(int /*unread*/) {} void clearBookmarks() {} + void setOnline(bool /*isOnline*/) {} }; diff --git a/Swift/Controllers/UIInterfaces/ChatListWindow.h b/Swift/Controllers/UIInterfaces/ChatListWindow.h index f7eb151..5a7b527 100644 --- a/Swift/Controllers/UIInterfaces/ChatListWindow.h +++ b/Swift/Controllers/UIInterfaces/ChatListWindow.h @@ -90,4 +90,5 @@ namespace Swift { virtual void setUnreadCount(int unread) = 0; virtual void clearBookmarks() = 0; + virtual void setOnline(bool isOnline) = 0; boost::signal<void (const MUCBookmark&)> onMUCBookmarkActivated; diff --git a/Swift/QtUI/ChatList/QtChatListWindow.cpp b/Swift/QtUI/ChatList/QtChatListWindow.cpp index 8e75f34..ea65dd6 100644 --- a/Swift/QtUI/ChatList/QtChatListWindow.cpp +++ b/Swift/QtUI/ChatList/QtChatListWindow.cpp @@ -30,5 +30,5 @@ namespace Swift { -QtChatListWindow::QtChatListWindow(UIEventStream *uiEventStream, SettingsProvider* settings, QWidget* parent) : QTreeView(parent) { +QtChatListWindow::QtChatListWindow(UIEventStream *uiEventStream, SettingsProvider* settings, QWidget* parent) : QTreeView(parent), isOnline_(false) { eventStream_ = uiEventStream; settings_ = settings; @@ -87,12 +87,12 @@ void QtChatListWindow::handleClicked(const QModelIndex& index) { void QtChatListWindow::setupContextMenus() { mucMenu_ = new QMenu(); - mucMenu_->addAction(tr("Add New Bookmark"), this, SLOT(handleAddBookmark())); - mucMenu_->addAction(tr("Edit Bookmark"), this, SLOT(handleEditBookmark())); - mucMenu_->addAction(tr("Remove Bookmark"), this, SLOT(handleRemoveBookmark())); + onlineOnlyActions_ << mucMenu_->addAction(tr("Add New Bookmark"), this, SLOT(handleAddBookmark())); + onlineOnlyActions_ << mucMenu_->addAction(tr("Edit Bookmark"), this, SLOT(handleEditBookmark())); + onlineOnlyActions_ << mucMenu_->addAction(tr("Remove Bookmark"), this, SLOT(handleRemoveBookmark())); mucRecentsMenu_ = new QMenu(); - mucRecentsMenu_->addAction(tr("Add to Bookmarks"), this, SLOT(handleAddBookmarkFromRecents())); + onlineOnlyActions_ << mucRecentsMenu_->addAction(tr("Add to Bookmarks"), this, SLOT(handleAddBookmarkFromRecents())); mucRecentsMenu_->addAction(tr("Clear recents"), this, SLOT(handleClearRecentsRequested())); emptyMenu_ = new QMenu(); - emptyMenu_->addAction(tr("Add New Bookmark"), this, SLOT(handleAddBookmark())); + onlineOnlyActions_ << emptyMenu_->addAction(tr("Add New Bookmark"), this, SLOT(handleAddBookmark())); } @@ -144,4 +144,8 @@ void QtChatListWindow::setUnreadCount(int unread) { } +void QtChatListWindow::setOnline(bool isOnline) { + isOnline_ = isOnline; +} + void QtChatListWindow::handleRemoveBookmark() { ChatListMUCItem* mucItem = dynamic_cast<ChatListMUCItem*>(contextMenuItem_); @@ -183,4 +187,9 @@ void QtChatListWindow::contextMenuEvent(QContextMenuEvent* event) { ChatListItem* baseItem = index.isValid() ? static_cast<ChatListItem*>(index.internalPointer()) : NULL; contextMenuItem_ = baseItem; + + foreach(QAction* action, onlineOnlyActions_) { + action->setEnabled(isOnline_); + } + if (!baseItem) { emptyMenu_->exec(QCursor::pos()); diff --git a/Swift/QtUI/ChatList/QtChatListWindow.h b/Swift/QtUI/ChatList/QtChatListWindow.h index 1cba3a4..823e6dc 100644 --- a/Swift/QtUI/ChatList/QtChatListWindow.h +++ b/Swift/QtUI/ChatList/QtChatListWindow.h @@ -29,4 +29,5 @@ namespace Swift { void setUnreadCount(int unread); void clearBookmarks(); + virtual void setOnline(bool isOnline); signals: @@ -57,4 +58,6 @@ namespace Swift { ChatListItem* contextMenuItem_; SettingsProvider* settings_; + QList<QAction*> onlineOnlyActions_; + bool isOnline_; }; 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(); } diff --git a/Swift/QtUI/QtMainWindow.cpp b/Swift/QtUI/QtMainWindow.cpp index 1db8c77..52b6bcc 100644 --- a/Swift/QtUI/QtMainWindow.cpp +++ b/Swift/QtUI/QtMainWindow.cpp @@ -1,4 +1,4 @@ /* - * Copyright (c) 2010-2011 Kevin Smith + * Copyright (c) 2010-2014 Kevin Smith * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. @@ -151,7 +151,9 @@ QtMainWindow::QtMainWindow(SettingsProvider* settings, UIEventStream* uiEventStr connect(editProfileAction, SIGNAL(triggered()), SLOT(handleEditProfileAction())); actionsMenu->addAction(editProfileAction); + onlineOnlyActions_ << editProfileAction; QAction* joinMUCAction = new QAction(tr("Enter &Room…"), this); connect(joinMUCAction, SIGNAL(triggered()), SLOT(handleJoinMUCAction())); actionsMenu->addAction(joinMUCAction); + onlineOnlyActions_ << joinMUCAction; #ifdef SWIFT_EXPERIMENTAL_HISTORY QAction* viewLogsAction = new QAction(tr("&View History…"), this); @@ -162,4 +164,5 @@ QtMainWindow::QtMainWindow(SettingsProvider* settings, UIEventStream* uiEventStr connect(openBlockingListEditor_, SIGNAL(triggered()), SLOT(handleEditBlockingList())); actionsMenu->addAction(openBlockingListEditor_); + onlineOnlyActions_ << openBlockingListEditor_; openBlockingListEditor_->setVisible(false); addUserAction_ = new QAction(tr("&Add Contact…"), this); @@ -168,7 +171,9 @@ QtMainWindow::QtMainWindow(SettingsProvider* settings, UIEventStream* uiEventStr connect(addUserAction_, SIGNAL(triggered(bool)), this, SLOT(handleAddUserActionTriggered(bool))); actionsMenu->addAction(addUserAction_); + onlineOnlyActions_ << addUserAction_; editUserAction_ = new QAction(tr("&Edit Selected Contact…"), this); connect(editUserAction_, SIGNAL(triggered(bool)), treeWidget_, SLOT(handleEditUserActionTriggered(bool))); actionsMenu->addAction(editUserAction_); + onlineOnlyActions_ << editUserAction_; editUserAction_->setEnabled(false); chatUserAction_ = new QAction(tr("Start &Chat…"), this); @@ -177,8 +182,10 @@ QtMainWindow::QtMainWindow(SettingsProvider* settings, UIEventStream* uiEventStr connect(chatUserAction_, SIGNAL(triggered(bool)), this, SLOT(handleChatUserActionTriggered(bool))); actionsMenu->addAction(chatUserAction_); + onlineOnlyActions_ << chatUserAction_; if (enableAdHocCommandOnJID) { otherAdHocAction_ = new QAction(tr("Run Other Command"), this); connect(otherAdHocAction_, SIGNAL(triggered()), this, SLOT(handleOtherAdHocActionTriggered())); actionsMenu->addAction(otherAdHocAction_); + onlineOnlyActions_ << otherAdHocAction_; } serverAdHocMenu_ = new QMenu(tr("Run Server Command"), this); @@ -197,5 +204,5 @@ QtMainWindow::QtMainWindow(SettingsProvider* settings, UIEventStream* uiEventStr loginMenus_.generalMenu->insertAction(generalMenuActions.at(generalMenuActions.count()-2),toggleRequestDeliveryReceipts_); - treeWidget_->onSomethingSelectedChanged.connect(boost::bind(&QAction::setEnabled, editUserAction_, _1)); + treeWidget_->onSomethingSelectedChanged.connect(boost::bind(&QtMainWindow::handleSomethingSelectedChanged, this, _1)); setAvailableAdHocCommands(std::vector<DiscoItems::Item>()); @@ -228,4 +235,9 @@ void QtMainWindow::handleEditBlockingList() { } +void QtMainWindow::handleSomethingSelectedChanged(bool itemSelected) { + bool isOnline = addUserAction_->isEnabled(); + editUserAction_->setEnabled(isOnline && itemSelected); +} + QtEventWindow* QtMainWindow::getEventWindow() { return eventWindow_; @@ -349,4 +361,11 @@ void QtMainWindow::setMyStatusText(const std::string& status) { void QtMainWindow::setMyStatusType(StatusShow::Type type) { meView_->setStatusType(type); + const bool online = (type != StatusShow::None); + treeWidget_->setOnline(online); + chatListWindow_->setOnline(online); + foreach (QAction *action, onlineOnlyActions_) { + action->setEnabled(online); + } + serverAdHocMenu_->setEnabled(online); } diff --git a/Swift/QtUI/QtMainWindow.h b/Swift/QtUI/QtMainWindow.h index 84fab15..ea92c79 100644 --- a/Swift/QtUI/QtMainWindow.h +++ b/Swift/QtUI/QtMainWindow.h @@ -1,4 +1,4 @@ /* - * Copyright (c) 2010-2011 Kevin Smith + * Copyright (c) 2010-2014 Kevin Smith * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. @@ -79,4 +79,5 @@ namespace Swift { void handleShowCertificateInfo(); void handleEditBlockingList(); + void handleSomethingSelectedChanged(bool itemSelected); private: @@ -105,4 +106,5 @@ namespace Swift { std::vector<DiscoItems::Item> serverAdHocCommands_; QList<QAction*> serverAdHocCommandActions_; + QList<QAction*> onlineOnlyActions_; }; } diff --git a/Swift/QtUI/QtNameWidget.cpp b/Swift/QtUI/QtNameWidget.cpp index 08e32f5..c172caa 100644 --- a/Swift/QtUI/QtNameWidget.cpp +++ b/Swift/QtUI/QtNameWidget.cpp @@ -1,4 +1,4 @@ /* - * Copyright (c) 2010-2012 Remko Tronçon + * Copyright (c) 2010-2014 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. @@ -18,5 +18,5 @@ namespace Swift { -QtNameWidget::QtNameWidget(SettingsProvider* settings, QWidget *parent) : QWidget(parent), settings(settings) { +QtNameWidget::QtNameWidget(SettingsProvider* settings, QWidget *parent) : QWidget(parent), settings(settings), isOnline_(false) { QHBoxLayout* mainLayout = new QHBoxLayout(this); mainLayout->setSpacing(0); @@ -42,4 +42,8 @@ void QtNameWidget::setJID(const QString& jid) { } +void QtNameWidget::setOnline(const bool isOnline) { + isOnline_ = isOnline; +} + void QtNameWidget::mousePressEvent(QMouseEvent* event) { QMenu menu; @@ -63,4 +67,5 @@ void QtNameWidget::mousePressEvent(QMouseEvent* event) { QAction* editProfile = new QAction(tr("Edit Profile"), this); menu.addAction(editProfile); + editProfile->setEnabled(isOnline_); QAction* result = menu.exec(event->globalPos()); diff --git a/Swift/QtUI/QtNameWidget.h b/Swift/QtUI/QtNameWidget.h index 3225879..460cc9a 100644 --- a/Swift/QtUI/QtNameWidget.h +++ b/Swift/QtUI/QtNameWidget.h @@ -1,4 +1,4 @@ /* - * Copyright (c) 2010 Remko Tronçon + * Copyright (c) 2010-2014 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. @@ -21,4 +21,5 @@ namespace Swift { void setNick(const QString& text); void setJID(const QString& jid); + void setOnline(const bool isOnline); signals: @@ -40,4 +41,5 @@ namespace Swift { QString jid; QString nick; + bool isOnline_; }; } diff --git a/Swift/QtUI/QtRosterHeader.cpp b/Swift/QtUI/QtRosterHeader.cpp index 69a0ef6..d5029ad 100644 --- a/Swift/QtUI/QtRosterHeader.cpp +++ b/Swift/QtUI/QtRosterHeader.cpp @@ -83,4 +83,12 @@ void QtRosterHeader::setStatusText(const QString& statusMessage) { void QtRosterHeader::setStatusType(StatusShow::Type type) { statusWidget_->setStatusType(type); + if (type == StatusShow::None) { + nameWidget_->setOnline(false); + disconnect(avatarLabel_, SIGNAL(clicked()), this, SIGNAL(onEditProfileRequest())); + } + else { + nameWidget_->setOnline(true); + connect(avatarLabel_, SIGNAL(clicked()), this, SIGNAL(onEditProfileRequest()), Qt::UniqueConnection); + } } diff --git a/Swift/QtUI/Roster/QtRosterWidget.cpp b/Swift/QtUI/Roster/QtRosterWidget.cpp index 4a3c9f3..8c296e5 100644 --- a/Swift/QtUI/Roster/QtRosterWidget.cpp +++ b/Swift/QtUI/Roster/QtRosterWidget.cpp @@ -61,5 +61,7 @@ void QtRosterWidget::contextMenuEvent(QContextMenuEvent* event) { if (ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item)) { QAction* editContact = contextMenu.addAction(tr("Edit…")); + editContact->setEnabled(isOnline()); QAction* removeContact = contextMenu.addAction(tr("Remove")); + removeContact->setEnabled(isOnline()); QAction* showProfileForContact = contextMenu.addAction(tr("Show Profile")); @@ -68,4 +70,5 @@ void QtRosterWidget::contextMenuEvent(QContextMenuEvent* event) { contact->blockState() == ContactRosterItem::IsDomainBlocked) { unblockContact = contextMenu.addAction(tr("Unblock")); + unblockContact->setEnabled(isOnline()); } @@ -73,4 +76,5 @@ void QtRosterWidget::contextMenuEvent(QContextMenuEvent* event) { if (contact->blockState() == ContactRosterItem::IsUnblocked) { blockContact = contextMenu.addAction(tr("Block")); + blockContact->setEnabled(isOnline()); } @@ -79,4 +83,5 @@ void QtRosterWidget::contextMenuEvent(QContextMenuEvent* event) { if (contact->supportsFeature(ContactRosterItem::FileTransferFeature)) { sendFile = contextMenu.addAction(tr("Send File")); + sendFile->setEnabled(isOnline()); } #endif @@ -85,7 +90,7 @@ void QtRosterWidget::contextMenuEvent(QContextMenuEvent* event) { if (contact->supportsFeature(ContactRosterItem::WhiteboardFeature)) { startWhiteboardChat = contextMenu.addAction(tr("Start Whiteboard Chat")); + startWhiteboardChat->setEnabled(isOnline()); } #endif - QAction* result = contextMenu.exec(event->globalPos()); if (result == editContact) { @@ -136,4 +141,7 @@ void QtRosterWidget::contextMenuEvent(QContextMenuEvent* event) { renameGroupAction->setEnabled(false); } + else { + renameGroupAction->setEnabled(isOnline()); + } QAction* result = contextMenu.exec(event->globalPos()); if (result == renameGroupAction) { diff --git a/Swift/QtUI/Roster/QtTreeWidget.cpp b/Swift/QtUI/Roster/QtTreeWidget.cpp index 5333260..f296088 100644 --- a/Swift/QtUI/Roster/QtTreeWidget.cpp +++ b/Swift/QtUI/Roster/QtTreeWidget.cpp @@ -1,4 +1,4 @@ /* - * Copyright (c) 2010-2012 Kevin Smith + * Copyright (c) 2010-2014 Kevin Smith * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. @@ -253,3 +253,11 @@ JID QtTreeWidget::selectedJID() const { } +void QtTreeWidget::setOnline(bool isOnline) { + isOnline_ = isOnline; +} + +bool QtTreeWidget::isOnline() const { + return isOnline_; +} + } diff --git a/Swift/QtUI/Roster/QtTreeWidget.h b/Swift/QtUI/Roster/QtTreeWidget.h index cf2f73e..12d34f5 100644 --- a/Swift/QtUI/Roster/QtTreeWidget.h +++ b/Swift/QtUI/Roster/QtTreeWidget.h @@ -37,4 +37,6 @@ class QtTreeWidget : public QTreeView { JID jidFromIndex(const QModelIndex& index) const; JID selectedJID() const; + void setOnline(bool isOnline); + public: boost::signal<void (RosterItem*)> onSomethingSelectedChanged; @@ -55,4 +57,5 @@ class QtTreeWidget : public QTreeView { bool event(QEvent* event); QModelIndexList getSelectedIndexes() const; + bool isOnline() const; private: @@ -72,4 +75,5 @@ class QtTreeWidget : public QTreeView { bool tooltipShown_; MessageTarget messageTarget_; + bool isOnline_; }; |