summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/QtAdHocCommandWindow.cpp')
-rw-r--r--Swift/QtUI/QtAdHocCommandWindow.cpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/Swift/QtUI/QtAdHocCommandWindow.cpp b/Swift/QtUI/QtAdHocCommandWindow.cpp
index 5d87031..5f99dba 100644
--- a/Swift/QtUI/QtAdHocCommandWindow.cpp
+++ b/Swift/QtUI/QtAdHocCommandWindow.cpp
@@ -1,40 +1,47 @@
/*
- * Copyright (c) 2010-2012 Kevin Smith
+ * Copyright (c) 2010-2014 Kevin Smith
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
-#include <Swift/QtUI/QtAdHocCommandWindow.h>
-
#include <boost/bind.hpp>
#include <QBoxLayout>
+#include <Swift/QtUI/QtAdHocCommandWindow.h>
#include <Swift/QtUI/QtFormWidget.h>
-#include <Swiften/Elements/Command.h>
#include <Swift/QtUI/QtSwiftUtil.h>
+#include <Swiften/Base/format.h>
+#include <Swiften/Elements/Command.h>
const int FormLayoutIndex = 1;
namespace Swift {
QtAdHocCommandWindow::QtAdHocCommandWindow(boost::shared_ptr<OutgoingAdHocCommandSession> command) : command_(command) {
formWidget_ = NULL;
setAttribute(Qt::WA_DeleteOnClose);
command->onNextStageReceived.connect(boost::bind(&QtAdHocCommandWindow::handleNextStageReceived, this, _1));
command->onError.connect(boost::bind(&QtAdHocCommandWindow::handleError, this, _1));
command->start();
layout_ = new QBoxLayout(QBoxLayout::TopToBottom, this);
layout_->setContentsMargins(0,0,0,0);
layout_->setSpacing(2);
label_ = new QLabel(this);
label_->setTextFormat(Qt::PlainText);
layout_->addWidget(label_);
+
+ errorLabel_ = new QLabel(this);
+ errorLabel_->setText(QString("<b>%1</b>").arg(tr("Unable to complete the command because you have been disconnected")));
+ errorLabel_->setVisible(false);
+ errorLabel_->setFrameStyle(QFrame::Box|QFrame::Sunken);
+ layout_->addWidget(errorLabel_);
+
QWidget* buttonsWidget = new QWidget(this);
layout_->addWidget(buttonsWidget);
QBoxLayout* buttonsLayout = new QBoxLayout(QBoxLayout::LeftToRight, buttonsWidget);
cancelButton_ = new QPushButton(tr("Cancel"), buttonsWidget);
buttonsLayout->addWidget(cancelButton_);
connect(cancelButton_, SIGNAL(clicked()), this, SLOT(handleCancelClicked()));
backButton_ = new QPushButton(tr("Back"), buttonsWidget);
buttonsLayout->addWidget(backButton_);
@@ -42,26 +49,39 @@ QtAdHocCommandWindow::QtAdHocCommandWindow(boost::shared_ptr<OutgoingAdHocComman
nextButton_ = new QPushButton(tr("Next"), buttonsWidget);
buttonsLayout->addWidget(nextButton_);
connect(nextButton_, SIGNAL(clicked()), this, SLOT(handleNextClicked()));
completeButton_ = new QPushButton(tr("Complete"), buttonsWidget);
buttonsLayout->addWidget(completeButton_);
connect(completeButton_, SIGNAL(clicked()), this, SLOT(handleCompleteClicked()));
nextButton_->setEnabled(false);
backButton_->setEnabled(false);
completeButton_->setEnabled(false);
+
actions_[Command::Next] = nextButton_;
actions_[Command::Prev] = backButton_;
actions_[Command::Complete] = completeButton_;
actions_[Command::Cancel] = cancelButton_;
}
QtAdHocCommandWindow::~QtAdHocCommandWindow() {
+}
+
+void QtAdHocCommandWindow::setOnline(bool online) {
+ if (!online) {
+ nextButton_->setEnabled(false);
+ backButton_->setEnabled(false);
+ completeButton_->setEnabled(false);
+ errorLabel_->setVisible(true);
+ }
+}
+void QtAdHocCommandWindow::closeEvent(QCloseEvent*) {
+ onClosing();
}
void QtAdHocCommandWindow::handleCancelClicked() {
command_->cancel();
close();
}
void QtAdHocCommandWindow::handlePrevClicked() {
command_->goBack();