summaryrefslogtreecommitdiffstats
blob: ac2a60313d3d3ca34c2cd68cfab5eff49f72602f (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
57
58
59
60
61
62
63
64
/*
 * Copyright (c) 2010-2015 Isode Limited.
 * All rights reserved.
 * See the COPYING file for more information.
 */

#include <Swift/QtUI/QtAdHocCommandWithJIDWindow.h>

#include <boost/bind.hpp>

#include <QBoxLayout>
#include <QDialogButtonBox>
#include <QLabel>
#include <QPushButton>

#include <Swiften/Elements/Command.h>

#include <Swift/Controllers/UIEvents/RequestAdHocWithJIDUIEvent.h>
#include <Swift/Controllers/UIEvents/UIEventStream.h>

#include <Swift/QtUI/QtFormWidget.h>
#include <Swift/QtUI/QtSwiftUtil.h>

namespace Swift {
QtAdHocCommandWithJIDWindow::QtAdHocCommandWithJIDWindow(UIEventStream* uiEventStream) : uiEventStream_(uiEventStream) {
	QVBoxLayout* hlayout = new QVBoxLayout(this);

	QLabel* jidLabel = new QLabel("JID:", this);
	hlayout->addWidget(jidLabel);
	jid_ = new QLineEdit(this);
	hlayout->addWidget(jid_);

	QLabel* commandLabel = new QLabel("Command:", this);
	hlayout->addWidget(commandLabel);
	node_ = new QLineEdit(this);
	hlayout->addWidget(node_);

	QDialogButtonBox* buttonBox = new QDialogButtonBox(this);
	QPushButton* rejectButton = buttonBox->addButton("Cancel", QDialogButtonBox::RejectRole);
	connect(rejectButton, SIGNAL(clicked()), this, SLOT(handleRejectClick()));
	QPushButton* acceptButton = buttonBox->addButton("Complete", QDialogButtonBox::AcceptRole);
	connect(acceptButton, SIGNAL(clicked()), this, SLOT(handleAcceptClick()));
	hlayout->addWidget(buttonBox);

	setLayout(hlayout);
	show();
}

QtAdHocCommandWithJIDWindow::~QtAdHocCommandWithJIDWindow() {
}

void QtAdHocCommandWithJIDWindow::handleAcceptClick() {
	const JID jid = JID(Q2PSTRING(jid_->text()));
	const std::string node = Q2PSTRING(node_->text());
	boost::shared_ptr<UIEvent> event(new RequestAdHocWithJIDUIEvent(jid, node));
	uiEventStream_->send(event);
	accept();
}

void QtAdHocCommandWithJIDWindow::handleRejectClick() {
	reject();
}

}