diff options
Diffstat (limited to 'Swift/QtUI/ChatList/QtChatListWindow.cpp')
| -rw-r--r-- | Swift/QtUI/ChatList/QtChatListWindow.cpp | 39 |
1 files changed, 31 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 @@ -70,2 +70,6 @@ void QtChatListWindow::handleSettingChanged(const std::string& setting) { +void QtChatListWindow::handleClearRecentsRequested() { + onClearRecentsRequested(); +} + void QtChatListWindow::setBookmarksEnabled(bool enabled) { @@ -86,5 +90,7 @@ void QtChatListWindow::setupContextMenus() { 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())); - } @@ -144,2 +150,13 @@ 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() { @@ -170,2 +187,3 @@ void QtChatListWindow::contextMenuEvent(QContextMenuEvent* event) { } + ChatListMUCItem* mucItem = dynamic_cast<ChatListMUCItem*>(baseItem); @@ -176,12 +194,17 @@ 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()); } |
Swift