summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2011-10-10 13:34:07 (GMT)
committerKevin Smith <git@kismith.co.uk>2011-10-10 13:34:07 (GMT)
commit5847ecd71f31f5f9167b80f0a2a4d2a52029758d (patch)
tree738e0b5f5a32f5df8eaa43a3a6cb15d850b6b0bc /Swift
parent150542a5c60fe49f4e164ffdaa51236795426214 (diff)
downloadswift-5847ecd71f31f5f9167b80f0a2a4d2a52029758d.zip
swift-5847ecd71f31f5f9167b80f0a2a4d2a52029758d.tar.bz2
Have the available MUC actions work on initial rightclick.
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/Roster/QtOccupantListWidget.cpp39
1 files changed, 24 insertions, 15 deletions
diff --git a/Swift/QtUI/Roster/QtOccupantListWidget.cpp b/Swift/QtUI/Roster/QtOccupantListWidget.cpp
index 3f66585..d7bb875 100644
--- a/Swift/QtUI/Roster/QtOccupantListWidget.cpp
+++ b/Swift/QtUI/Roster/QtOccupantListWidget.cpp
@@ -36,26 +36,35 @@ void QtOccupantListWidget::contextMenuEvent(QContextMenuEvent* event) {
if (!index.isValid()) {
return;
}
+
RosterItem* item = static_cast<RosterItem*>(index.internalPointer());
ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item);
if (contact) {
+ onSomethingSelectedChanged(contact);
QMenu contextMenu;
- std::map<QAction*, ChatWindow::OccupantAction> actions;
- foreach (ChatWindow::OccupantAction availableAction, availableOccupantActions_) {
- QString text = "Error: missing string";
- switch (availableAction) {
- case ChatWindow::Kick: text = tr("Kick user"); break;
- case ChatWindow::Ban: text = tr("Kick and ban user"); break;
- case ChatWindow::MakeModerator: text = tr("Make moderator"); break;
- case ChatWindow::MakeParticipant: text = tr("Make participant"); break;
- case ChatWindow::MakeVisitor: text = tr("Remove voice"); break;
- }
- QAction* action = contextMenu.addAction(text);
- actions[action] = availableAction;
+ if (availableOccupantActions_.empty()) {
+ QAction* noAction = contextMenu.addAction(tr("No actions for this user"));
+ noAction->setEnabled(false);
+ contextMenu.exec(event->globalPos());
}
- QAction* result = contextMenu.exec(event->globalPos());
- if (result) {
- onOccupantActionSelected(actions[result], contact);
+ else {
+ std::map<QAction*, ChatWindow::OccupantAction> actions;
+ foreach (ChatWindow::OccupantAction availableAction, availableOccupantActions_) {
+ QString text = "Error: missing string";
+ switch (availableAction) {
+ case ChatWindow::Kick: text = tr("Kick user"); break;
+ case ChatWindow::Ban: text = tr("Kick and ban user"); break;
+ case ChatWindow::MakeModerator: text = tr("Make moderator"); break;
+ case ChatWindow::MakeParticipant: text = tr("Make participant"); break;
+ case ChatWindow::MakeVisitor: text = tr("Remove voice"); break;
+ }
+ QAction* action = contextMenu.addAction(text);
+ actions[action] = availableAction;
+ }
+ QAction* result = contextMenu.exec(event->globalPos());
+ if (result) {
+ onOccupantActionSelected(actions[result], contact);
+ }
}
}
}