summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-05-31 21:13:00 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-06-04 19:34:04 (GMT)
commitecd4309da49ad3186ae829b7c8b50eb78f856249 (patch)
tree35ef94e86b6e631a92d38652bc6b4f1ec618035e /Swift
parentfee6af7cc3a8a64fb5d3dbf5e2aaf73a6052ccf1 (diff)
downloadswift-ecd4309da49ad3186ae829b7c8b50eb78f856249.zip
swift-ecd4309da49ad3186ae829b7c8b50eb78f856249.tar.bz2
Add option to autojoin when joining a room.
Resolves: #380
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp28
-rw-r--r--Swift/QtUI/MUCSearch/QtMUCSearchWindow.h2
-rw-r--r--Swift/QtUI/MUCSearch/QtMUCSearchWindow.ui17
3 files changed, 43 insertions, 4 deletions
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<String> maybeNick;
if (!nickName_->text().isEmpty()) {
- maybeNick = Q2PSTRING(nickName_->text());
+ lastSetNick_ = Q2PSTRING(nickName_->text());
+ maybeNick = lastSetNick_;
}
- eventStream_->send(boost::shared_ptr<UIEvent>(new JoinMUCUIEvent(JID(Q2PSTRING(room_->text())), maybeNick)));
+
+ JID room(Q2PSTRING(room_->text()));
+ if (joinAutomatically_->isChecked()) {
+ createAutoJoin(room, maybeNick);
+ }
+ eventStream_->send(boost::shared_ptr<UIEvent>(new JoinMUCUIEvent(room, maybeNick)));
hide();
}
+void QtMUCSearchWindow::createAutoJoin(const JID& room, boost::optional<String> 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<UIEvent>(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<String> 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 @@
<property name="geometry">
<rect>
<x>280</x>
- <y>410</y>
+ <y>380</y>
<width>211</width>
<height>18</height>
</rect>
@@ -131,7 +131,7 @@
<property name="geometry">
<rect>
<x>280</x>
- <y>430</y>
+ <y>400</y>
<width>201</width>
<height>26</height>
</rect>
@@ -179,6 +179,19 @@
<string>Search</string>
</property>
</widget>
+ <widget class="QCheckBox" name="joinAutomatically_">
+ <property name="geometry">
+ <rect>
+ <x>280</x>
+ <y>440</y>
+ <width>211</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Join automatically in future</string>
+ </property>
+ </widget>
</widget>
<resources/>
<connections/>