summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Maudsley <richard.maudsley@isode.com>2014-05-19 11:18:52 (GMT)
committerSwift Review <review@swift.im>2014-07-09 10:19:41 (GMT)
commit05d9e618e4c756e50b633448f0546614a645a13d (patch)
tree5a05e5c2c939c240a58c4aa468af0806a7ed8822 /Swift/QtUI/QtAdHocCommandWithJIDWindow.cpp
parentacac7962ba04c083377f62f4265ecc754176f74e (diff)
downloadswift-05d9e618e4c756e50b633448f0546614a645a13d.zip
swift-05d9e618e4c756e50b633448f0546614a645a13d.tar.bz2
Add dialog to send AdHoc's to target specific JID's. Fix multi-item Form rendering.
Test-Information: Use AdHoc bot that presents a multi-item form and check that it is rendered correctly. Check that entering invalid JID and node parameters in the dialog do not cause malfunction. Check that canceling the JID prompt closes the dialog without sending any server commands. Change-Id: I10e6f4c7eccd1a35c8c885d548994b5f57fdbf66
Diffstat (limited to 'Swift/QtUI/QtAdHocCommandWithJIDWindow.cpp')
-rw-r--r--Swift/QtUI/QtAdHocCommandWithJIDWindow.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/Swift/QtUI/QtAdHocCommandWithJIDWindow.cpp b/Swift/QtUI/QtAdHocCommandWithJIDWindow.cpp
new file mode 100644
index 0000000..7f33f77
--- /dev/null
+++ b/Swift/QtUI/QtAdHocCommandWithJIDWindow.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2010-2014 Kevin Smith
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include <boost/bind.hpp>
+#include <QLabel>
+#include <QPushButton>
+#include <QBoxLayout>
+#include <QDialogButtonBox>
+#include <Swiften/Elements/Command.h>
+#include <Swift/Controllers/UIEvents/UIEventStream.h>
+#include <Swift/Controllers/UIEvents/RequestAdHocWithJIDUIEvent.h>
+#include <Swift/QtUI/QtAdHocCommandWithJIDWindow.h>
+#include <Swift/QtUI/QtFormWidget.h>
+#include <Swift/QtUI/QtSwiftUtil.h>
+
+const int FormLayoutIndex = 1;
+
+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();
+}
+
+}