diff options
Diffstat (limited to 'Swift/QtUI/QtChatWindow.cpp')
-rw-r--r-- | Swift/QtUI/QtChatWindow.cpp | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp index dc89c21..c6519ba 100644 --- a/Swift/QtUI/QtChatWindow.cpp +++ b/Swift/QtUI/QtChatWindow.cpp @@ -726,23 +726,36 @@ void QtChatWindow::setAvailableOccupantActions(const std::vector<OccupantAction> } void QtChatWindow::setSubject(const std::string& subject) { //subject_->setVisible(!subject.empty()); subject_->setText(P2QSTRING(subject)); } void QtChatWindow::handleActionButtonClicked() { QMenu contextMenu; - QAction* changeSubject = contextMenu.addAction(tr("Change subject")); - QAction* configure = contextMenu.addAction(tr("Configure room")); - QAction* affiliations = contextMenu.addAction(tr("Edit affiliations")); - QAction* destroy = contextMenu.addAction(tr("Destroy room")); - QAction* invite = contextMenu.addAction(tr("Invite person to this room")); + QAction* changeSubject = NULL; + QAction* configure = NULL; + QAction* affiliations = NULL; + QAction* destroy = NULL; + QAction* invite = NULL; + + foreach(ChatWindow::RoomAction availableAction, availableRoomActions_) + { + 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; + } + } + QAction* result = contextMenu.exec(QCursor::pos()); if (result == changeSubject) { bool ok; QString subject = QInputDialog::getText(this, tr("Change room subject"), tr("New subject:"), QLineEdit::Normal, subject_->text(), &ok); if (ok) { onChangeSubjectRequest(Q2PSTRING(subject)); } } else if (result == configure) { @@ -779,18 +792,23 @@ void QtChatWindow::handleActionButtonClicked() { void QtChatWindow::handleAffiliationEditorAccepted() { onChangeAffiliationsRequest(affiliationEditor_->getChanges()); } void QtChatWindow::setAffiliations(MUCOccupant::Affiliation affiliation, const std::vector<JID>& jids) { if (!affiliationEditor_) return; affiliationEditor_->setAffiliations(affiliation, jids); } +void QtChatWindow::setAvailableRoomActions(const std::vector<RoomAction> &actions) +{ + availableRoomActions_ = actions; +} + void QtChatWindow::showRoomConfigurationForm(Form::ref form) { if (mucConfigurationWindow_) { delete mucConfigurationWindow_.data(); } mucConfigurationWindow_ = new QtMUCConfigurationWindow(form); mucConfigurationWindow_->onFormComplete.connect(boost::bind(boost::ref(onConfigureRequest), _1)); mucConfigurationWindow_->onFormCancelled.connect(boost::bind(boost::ref(onConfigurationFormCancelled))); } |