summaryrefslogtreecommitdiffstats
blob: b6f58141c2885b6899a757d7afc0c2e1646bcbfa (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
#include "QtJoinMUCDialog.h"
#include "QtSwiftUtil.h"

namespace Swift {

QtJoinMUCDialog::QtJoinMUCDialog(const QString& nick, const QString& muc, QWidget* parent) : QDialog(parent) {
	setupUi(this);
	errorLabel_->hide();
	setAttribute(Qt::WA_DeleteOnClose, true);
	connect(buttons_, SIGNAL(accepted()), SLOT(accept()));
	connect(buttons_, SIGNAL(rejected()), SLOT(reject()));
}

void QtJoinMUCDialog::accept() {
	if (mucJID_->displayText().isEmpty()) {
		showError("You must specify a room to join.");
		return;
	}
	if (nick_->displayText().isEmpty()) {
		showError("You must specify a nickname to join a room.");
		return;
	}
	errorLabel_->hide();
	emit onJoinCommand(JID(Q2PSTRING(mucJID_->displayText())), nick_->displayText());
	QDialog::accept();
}

void QtJoinMUCDialog::showError(const QString& error) {
	errorLabel_->setText(QString("<font color='red'>%1</font>").arg(error));
	errorLabel_->show();
}
}