diff options
Diffstat (limited to 'Swift/QtUI/Roster')
-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 |
3 files changed, 22 insertions, 2 deletions
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 @@ -57,39 +57,44 @@ void QtRosterWidget::contextMenuEvent(QContextMenuEvent* event) { return; } RosterItem* item = static_cast<RosterItem*>(index.internalPointer()); QMenu contextMenu; 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")); QAction* unblockContact = NULL; if (contact->blockState() == ContactRosterItem::IsBlocked || contact->blockState() == ContactRosterItem::IsDomainBlocked) { unblockContact = contextMenu.addAction(tr("Unblock")); + unblockContact->setEnabled(isOnline()); } QAction* blockContact = NULL; if (contact->blockState() == ContactRosterItem::IsUnblocked) { blockContact = contextMenu.addAction(tr("Block")); + blockContact->setEnabled(isOnline()); } #ifdef SWIFT_EXPERIMENTAL_FT QAction* sendFile = NULL; if (contact->supportsFeature(ContactRosterItem::FileTransferFeature)) { sendFile = contextMenu.addAction(tr("Send File")); + sendFile->setEnabled(isOnline()); } #endif #ifdef SWIFT_EXPERIMENTAL_WB QAction* startWhiteboardChat = NULL; 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) { eventStream_->send(boost::make_shared<RequestContactEditorUIEvent>(contact->getJID())); } else if (result == removeContact) { if (QtContactEditWindow::confirmContactDeletion(contact->getJID())) { @@ -132,12 +137,15 @@ void QtRosterWidget::contextMenuEvent(QContextMenuEvent* event) { } else if (GroupRosterItem* group = dynamic_cast<GroupRosterItem*>(item)) { QAction* renameGroupAction = contextMenu.addAction(tr("Rename")); if (P2QSTRING(group->getDisplayName()) == tr("Contacts")) { renameGroupAction->setEnabled(false); } + else { + renameGroupAction->setEnabled(isOnline()); + } QAction* result = contextMenu.exec(event->globalPos()); if (result == renameGroupAction) { renameGroup(group); } } } 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,8 +1,8 @@ /* - * 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. */ #include <Swift/QtUI/Roster/QtTreeWidget.h> @@ -249,7 +249,15 @@ JID QtTreeWidget::selectedJID() const { if (list.size() != 1) { return JID(); } return jidFromIndex(list[0]); } +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 @@ -33,12 +33,14 @@ class QtTreeWidget : public QTreeView { void setRosterModel(Roster* roster); Roster* getRoster() {return roster_;} void refreshTooltip(); void setMessageTarget(MessageTarget messageTarget); JID jidFromIndex(const QModelIndex& index) const; JID selectedJID() const; + void setOnline(bool isOnline); + public: boost::signal<void (RosterItem*)> onSomethingSelectedChanged; private slots: void handleItemActivated(const QModelIndex&); void handleModelItemExpanded(const QModelIndex&, bool expanded); @@ -51,12 +53,13 @@ class QtTreeWidget : public QTreeView { protected: void dragEnterEvent(QDragEnterEvent* event); void dropEvent(QDropEvent* event); void dragMoveEvent(QDragMoveEvent* event); bool event(QEvent* event); QModelIndexList getSelectedIndexes() const; + bool isOnline() const; private: void drawBranches(QPainter*, const QRect&, const QModelIndex&) const; protected slots: virtual void currentChanged(const QModelIndex& current, const QModelIndex& previous); @@ -68,9 +71,10 @@ class QtTreeWidget : public QTreeView { Roster* roster_; RosterDelegate* delegate_; QtTreeWidgetItem* treeRoot_; SettingsProvider* settings_; bool tooltipShown_; MessageTarget messageTarget_; + bool isOnline_; }; } |