summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Maudsley <richard.maudsley@isode.com>2014-05-06 13:08:57 (GMT)
committerSwift Review <review@swift.im>2014-05-29 16:18:23 (GMT)
commitb70a50f11da1ea57a0e89ff14882eed03944eb2a (patch)
treebbe3d3f28104dcba7d276a7016da283665b8f326 /Swift/QtUI
parentab612d0f18ff545b4ebcb2bf2bb400996e751181 (diff)
downloadswift-contrib-b70a50f11da1ea57a0e89ff14882eed03944eb2a.zip
swift-contrib-b70a50f11da1ea57a0e89ff14882eed03944eb2a.tar.bz2
Right-click MUC in Recents to bookmark.
Change-Id: Idfb5907adf9bf53f0ac1f417dd57d49ecc897bb0
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/ChatList/QtChatListWindow.cpp39
-rw-r--r--Swift/QtUI/ChatList/QtChatListWindow.h3
2 files changed, 34 insertions, 8 deletions
diff --git a/Swift/QtUI/ChatList/QtChatListWindow.cpp b/Swift/QtUI/ChatList/QtChatListWindow.cpp
index 7455fb5..210124b 100644
--- a/Swift/QtUI/ChatList/QtChatListWindow.cpp
+++ b/Swift/QtUI/ChatList/QtChatListWindow.cpp
@@ -69,4 +69,8 @@ void QtChatListWindow::handleSettingChanged(const std::string& setting) {
}
+void QtChatListWindow::handleClearRecentsRequested() {
+ onClearRecentsRequested();
+}
+
void QtChatListWindow::setBookmarksEnabled(bool enabled) {
bookmarksEnabled_ = enabled;
@@ -85,7 +89,9 @@ void QtChatListWindow::setupContextMenus() {
mucMenu_->addAction(tr("Edit Bookmark"), this, SLOT(handleEditBookmark()));
mucMenu_->addAction(tr("Remove Bookmark"), this, SLOT(handleRemoveBookmark()));
+ mucRecentsMenu_ = new QMenu();
+ 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()));
-
}
@@ -143,4 +149,15 @@ void QtChatListWindow::handleRemoveBookmark() {
}
+void QtChatListWindow::handleAddBookmarkFromRecents() {
+ ChatListRecentItem* item = dynamic_cast<ChatListRecentItem*>(contextMenuItem_);
+ if (item) {
+ const ChatListWindow::Chat& chat = item->getChat();
+ MUCBookmark bookmark(chat.jid, chat.jid.toBare().toString());
+ bookmark.setNick(chat.nick);
+ bookmark.setPassword(chat.password);
+ eventStream_->send(boost::shared_ptr<UIEvent>(new AddMUCBookmarkUIEvent(bookmark)));
+ }
+}
+
void QtChatListWindow::handleAddBookmark() {
(new QtAddBookmarkWindow(eventStream_))->show();
@@ -169,4 +186,5 @@ void QtChatListWindow::contextMenuEvent(QContextMenuEvent* event) {
return;
}
+
ChatListMUCItem* mucItem = dynamic_cast<ChatListMUCItem*>(baseItem);
if (mucItem) {
@@ -175,14 +193,19 @@ void QtChatListWindow::contextMenuEvent(QContextMenuEvent* event) {
}
mucMenu_->exec(QCursor::pos());
+ return;
}
- else {
- QMenu menu;
- QAction* clearRecents = menu.addAction(tr("Clear recents"));
- menu.addAction(clearRecents);
- QAction* result = menu.exec(event->globalPos());
- if (result == clearRecents) {
- onClearRecentsRequested();
+
+ ChatListRecentItem* recentItem = dynamic_cast<ChatListRecentItem*>(baseItem);
+ if (recentItem) {
+ const ChatListWindow::Chat& chat = recentItem->getChat();
+ if (chat.isMUC) {
+ mucRecentsMenu_->exec(QCursor::pos());
+ return;
}
}
+
+ QMenu menu;
+ menu.addAction(tr("Clear recents"), this, SLOT(handleClearRecentsRequested()));
+ menu.exec(event->globalPos());
}
diff --git a/Swift/QtUI/ChatList/QtChatListWindow.h b/Swift/QtUI/ChatList/QtChatListWindow.h
index e218266..1cba3a4 100644
--- a/Swift/QtUI/ChatList/QtChatListWindow.h
+++ b/Swift/QtUI/ChatList/QtChatListWindow.h
@@ -37,6 +37,8 @@ namespace Swift {
void handleEditBookmark();
void handleRemoveBookmark();
+ void handleAddBookmarkFromRecents();
void handleClicked(const QModelIndex& index);
void handleSettingChanged(const std::string& setting);
+ void handleClearRecentsRequested();
protected:
@@ -52,4 +54,5 @@ namespace Swift {
QMenu* mucMenu_;
QMenu* emptyMenu_;
+ QMenu* mucRecentsMenu_;
ChatListItem* contextMenuItem_;
SettingsProvider* settings_;