diff options
author | Tobias Markmann <tm@ayena.de> | 2014-10-09 13:20:04 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2014-10-09 13:20:04 (GMT) |
commit | 8921c929a190c3ae4d7a10e5e58c8e720a0121c3 (patch) | |
tree | ee032d7bfccefa62d700e92906c2f87ad97b4932 /Swift/QtUI/Roster/QtRosterWidget.cpp | |
parent | 54351d4b9d8d3580c4f60306c3e1dfcba304777b (diff) | |
download | swift-contrib-8921c929a190c3ae4d7a10e5e58c8e720a0121c3.zip swift-contrib-8921c929a190c3ae4d7a10e5e58c8e720a0121c3.tar.bz2 |
Prevent renaming of 'Contacts' roster group used for groupless contacts.
Test-Information:
Verified by running Swift and checking that you cannot rename 'Contacts' group
anymore. Other groups are still renameable.
Change-Id: I97a79feb92d65d6dcdf914fb47b13ee268d271c3
Diffstat (limited to 'Swift/QtUI/Roster/QtRosterWidget.cpp')
-rw-r--r-- | Swift/QtUI/Roster/QtRosterWidget.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Swift/QtUI/Roster/QtRosterWidget.cpp b/Swift/QtUI/Roster/QtRosterWidget.cpp index fff0ccd..4a3c9f3 100644 --- a/Swift/QtUI/Roster/QtRosterWidget.cpp +++ b/Swift/QtUI/Roster/QtRosterWidget.cpp @@ -1,37 +1,37 @@ /* - * 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. */ #include <Swift/QtUI/Roster/QtRosterWidget.h> #include <QContextMenuEvent> #include <QMenu> #include <QMessageBox> #include <QInputDialog> #include <QFileDialog> #include <QPushButton> #include <Swift/Controllers/UIEvents/RequestContactEditorUIEvent.h> #include <Swift/Controllers/UIEvents/RemoveRosterItemUIEvent.h> #include <Swift/Controllers/UIEvents/RenameGroupUIEvent.h> #include <Swift/Controllers/UIEvents/SendFileUIEvent.h> #include <Swift/Controllers/UIEvents/RequestWhiteboardUIEvent.h> #include <Swift/Controllers/UIEvents/ShowProfileForRosterItemUIEvent.h> #include <Swift/Controllers/UIEvents/RequestChangeBlockStateUIEvent.h> #include <Swift/QtUI/QtContactEditWindow.h> #include <Swift/Controllers/Roster/ContactRosterItem.h> #include <Swift/Controllers/Roster/GroupRosterItem.h> #include <Swift/Controllers/UIEvents/UIEventStream.h> #include <Swift/QtUI/QtSwiftUtil.h> namespace Swift { QtRosterWidget::QtRosterWidget(UIEventStream* eventStream, SettingsProvider* settings, QWidget* parent) : QtTreeWidget(eventStream, settings, MessageDefaultJID, parent) { } QtRosterWidget::~QtRosterWidget() { } @@ -100,51 +100,54 @@ void QtRosterWidget::contextMenuEvent(QContextMenuEvent* event) { eventStream_->send(boost::make_shared<ShowProfileForRosterItemUIEvent>(contact->getJID())); } else if (unblockContact && result == unblockContact) { if (contact->blockState() == ContactRosterItem::IsDomainBlocked) { QMessageBox messageBox(QMessageBox::Question, tr("Swift"), tr("%2 is currently blocked because of a block on all users of the %1 service.\n %2 cannot be unblocked individually; do you want to unblock all %1 users?").arg(P2QSTRING(contact->getJID().getDomain()), P2QSTRING(contact->getJID().toString())), QMessageBox::NoButton, this); QPushButton* unblockDomainButton = messageBox.addButton(tr("Unblock %1 domain").arg(P2QSTRING(contact->getJID().getDomain())), QMessageBox::AcceptRole); messageBox.addButton(QMessageBox::Abort); messageBox.exec(); if (messageBox.clickedButton() == unblockDomainButton) { eventStream_->send(boost::make_shared<RequestChangeBlockStateUIEvent>(RequestChangeBlockStateUIEvent::Unblocked, contact->getJID().getDomain())); } } else { eventStream_->send(boost::make_shared<RequestChangeBlockStateUIEvent>(RequestChangeBlockStateUIEvent::Unblocked, contact->getJID())); } } else if (blockContact && result == blockContact) { eventStream_->send(boost::make_shared<RequestChangeBlockStateUIEvent>(RequestChangeBlockStateUIEvent::Blocked, contact->getJID())); } #ifdef SWIFT_EXPERIMENTAL_FT else if (sendFile && result == sendFile) { QString fileName = QFileDialog::getOpenFileName(this, tr("Send File"), "", tr("All Files (*);;")); if (!fileName.isEmpty()) { eventStream_->send(boost::make_shared<SendFileUIEvent>(contact->getJID(), Q2PSTRING(fileName))); } } #endif #ifdef SWIFT_EXPERIMENTAL_WB else if (startWhiteboardChat && result == startWhiteboardChat) { eventStream_->send(boost::make_shared<RequestWhiteboardUIEvent>(contact->getJID())); } #endif } else if (GroupRosterItem* group = dynamic_cast<GroupRosterItem*>(item)) { QAction* renameGroupAction = contextMenu.addAction(tr("Rename")); + if (P2QSTRING(group->getDisplayName()) == tr("Contacts")) { + renameGroupAction->setEnabled(false); + } QAction* result = contextMenu.exec(event->globalPos()); if (result == renameGroupAction) { renameGroup(group); } } } void QtRosterWidget::renameGroup(GroupRosterItem* group) { bool ok; QString newName = QInputDialog::getText(NULL, tr("Rename group"), tr("Enter a new name for group '%1':").arg(P2QSTRING(group->getDisplayName())), QLineEdit::Normal, P2QSTRING(group->getDisplayName()), &ok); if (ok) { eventStream_->send(boost::make_shared<RenameGroupUIEvent>(group->getDisplayName(), Q2PSTRING(newName))); } } } |