From ecd4309da49ad3186ae829b7c8b50eb78f856249 Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Mon, 31 May 2010 22:13:00 +0100 Subject: Add option to autojoin when joining a room. Resolves: #380 diff --git a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp index a8bf9ee..b1cfd65 100644 --- a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp +++ b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp @@ -10,6 +10,7 @@ #include "Swift/Controllers/UIEvents/UIEventStream.h" #include "Swift/Controllers/UIEvents/JoinMUCUIEvent.h" +#include "Swift/Controllers/UIEvents/AddMUCBookmarkUIEvent.h" #include "Swift/QtUI/MUCSearch/MUCSearchModel.h" #include "Swift/QtUI/MUCSearch/MUCSearchDelegate.h" #include "Swift/QtUI/QtSwiftUtil.h" @@ -79,14 +80,37 @@ void QtMUCSearchWindow::handleJoin() { } boost::optional maybeNick; if (!nickName_->text().isEmpty()) { - maybeNick = Q2PSTRING(nickName_->text()); + lastSetNick_ = Q2PSTRING(nickName_->text()); + maybeNick = lastSetNick_; } - eventStream_->send(boost::shared_ptr(new JoinMUCUIEvent(JID(Q2PSTRING(room_->text())), maybeNick))); + + JID room(Q2PSTRING(room_->text())); + if (joinAutomatically_->isChecked()) { + createAutoJoin(room, maybeNick); + } + eventStream_->send(boost::shared_ptr(new JoinMUCUIEvent(room, maybeNick))); hide(); } +void QtMUCSearchWindow::createAutoJoin(const JID& room, boost::optional passedNick) { + String nick = lastSetNick_; + if (passedNick) { + nick = passedNick.get(); + } + MUCBookmark bookmark(room, room.getNode()); + bookmark.setAutojoin(true); + if (!nick.isEmpty()) { + bookmark.setNick(nick); + } + //if (!password.isEmpty()) { + // bookmark.setPassword(password); + //} + eventStream_->send(boost::shared_ptr(new AddMUCBookmarkUIEvent(bookmark))); +} + void QtMUCSearchWindow::setNick(const String& nick) { nickName_->setText(P2QSTRING(nick)); + lastSetNick_ = nick; } void QtMUCSearchWindow::setMUC(const String& nick) { diff --git a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.h b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.h index 7b556b0..c0a8e72 100644 --- a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.h +++ b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.h @@ -32,8 +32,10 @@ namespace Swift { void handleSelected(const QModelIndex& current); void handleActivated(const QModelIndex& index); private: + void createAutoJoin(const JID& room, boost::optional passedNick); MUCSearchModel* model_; MUCSearchDelegate* delegate_; UIEventStream* eventStream_; + String lastSetNick_; }; } diff --git a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.ui b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.ui index d3d327e..11c4df2 100644 --- a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.ui +++ b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.ui @@ -95,7 +95,7 @@ 280 - 410 + 380 211 18 @@ -131,7 +131,7 @@ 280 - 430 + 400 201 26 @@ -179,6 +179,19 @@ Search + + + + 280 + 440 + 211 + 22 + + + + Join automatically in future + + -- cgit v0.10.2-6-g49f6