summaryrefslogtreecommitdiffstats
blob: 5ffc34dd0e67aeb498701c9fe6c82466e6846480 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
 * Copyright (c) 2010 Remko Tronçon
 * Licensed under the GNU General Public License v3.
 * See Documentation/Licenses/GPLv3.txt for more information.
 */

#include "QtJoinMUCWindow.h"
#include "QtSwiftUtil.h"

namespace Swift {

QtJoinMUCWindow::QtJoinMUCWindow() {
	ui.setupUi(this);
#if QT_VERSION >= 0x040700
	ui.room->setPlaceholderText("swift@rooms.swift.im");
#endif
	connect(ui.room, SIGNAL(returnPressed()), this, SLOT(handleJoin()));
	connect(ui.searchButton, SIGNAL(clicked()), this, SLOT(handleSearch()));
	connect(ui.joinButton, SIGNAL(clicked()), this, SLOT(handleJoin()));
}

void QtJoinMUCWindow::handleJoin() {
	if (ui.room->text().isEmpty()) {
		// TODO: Error
		return;
	}
	if (ui.nickName->text().isEmpty()) {
		// TODO: Error
		return;
	}

	lastSetNick = Q2PSTRING(ui.nickName->text());
	JID room(Q2PSTRING(ui.room->text()));
	onJoinMUC(room, lastSetNick, ui.joinAutomatically->isChecked()); 
	hide();
}

void QtJoinMUCWindow::handleSearch() {
	onSearchMUC();
}

void QtJoinMUCWindow::setNick(const std::string& nick) {
	ui.nickName->setText(P2QSTRING(nick));
	lastSetNick = nick;
}

void QtJoinMUCWindow::setMUC(const std::string& nick) {
	ui.room->setText(P2QSTRING(nick));
}

void QtJoinMUCWindow::show() {
	QWidget::show();
	QWidget::activateWindow();
}

}