summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/QtAdHocCommandWindow.cpp45
-rw-r--r--Swift/QtUI/QtAdHocCommandWindow.h15
2 files changed, 39 insertions, 21 deletions
diff --git a/Swift/QtUI/QtAdHocCommandWindow.cpp b/Swift/QtUI/QtAdHocCommandWindow.cpp
index a6bce65..ef397f4 100644
--- a/Swift/QtUI/QtAdHocCommandWindow.cpp
+++ b/Swift/QtUI/QtAdHocCommandWindow.cpp
@@ -1,17 +1,21 @@
/*
- * Copyright (c) 2010-2014 Isode Limited.
+ * Copyright (c) 2010-2015 Isode Limited.
* All rights reserved.
* See the COPYING file 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 <Swift/QtUI/QtSwiftUtil.h>
+
#include <Swiften/Base/format.h>
#include <Swiften/Elements/Command.h>
+#include <Swift/QtUI/QtFormWidget.h>
+#include <Swift/QtUI/QtSwiftUtil.h>
+
const int FormLayoutIndex = 1;
namespace Swift {
@@ -36,22 +40,25 @@ QtAdHocCommandWindow::QtAdHocCommandWindow(boost::shared_ptr<OutgoingAdHocComman
errorLabel_->setFrameStyle(QFrame::Box|QFrame::Sunken);
layout_->addWidget(errorLabel_);
- QWidget* buttonsWidget = new QWidget(this);
- layout_->addWidget(buttonsWidget);
+ dialogButtons_ = new QDialogButtonBox(this);
+ layout_->addWidget(dialogButtons_);
- QBoxLayout* buttonsLayout = new QBoxLayout(QBoxLayout::LeftToRight, buttonsWidget);
- cancelButton_ = new QPushButton(tr("Cancel"), buttonsWidget);
- buttonsLayout->addWidget(cancelButton_);
+ dialogButtons_->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
+ okButton_ = dialogButtons_->button(QDialogButtonBox::Ok);
+ connect(okButton_, SIGNAL(clicked()), this, SLOT(close()));
+ cancelButton_ = dialogButtons_->button(QDialogButtonBox::Cancel);
connect(cancelButton_, SIGNAL(clicked()), this, SLOT(handleCancelClicked()));
- backButton_ = new QPushButton(tr("Back"), buttonsWidget);
- buttonsLayout->addWidget(backButton_);
- connect(backButton_, SIGNAL(clicked()), this, SLOT(handlePrevClicked()));
- 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_);
+ // Buttons appear next to the Ok button, right of Cancel with YesRole
+ completeButton_ = dialogButtons_->addButton(tr("Complete"), QDialogButtonBox::YesRole);
connect(completeButton_, SIGNAL(clicked()), this, SLOT(handleCompleteClicked()));
+ nextButton_ = dialogButtons_->addButton(tr("Next"), QDialogButtonBox::YesRole);
+ connect(nextButton_, SIGNAL(clicked()), this, SLOT(handleNextClicked()));
+ backButton_ = dialogButtons_->addButton(tr("Back"), QDialogButtonBox::YesRole);
+ connect(backButton_, SIGNAL(clicked()), this, SLOT(handlePrevClicked()));
+
+ okButton_->setEnabled(false);
+ okButton_->hide();
+
nextButton_->setEnabled(false);
backButton_->setEnabled(false);
completeButton_->setEnabled(false);
@@ -143,9 +150,13 @@ void QtAdHocCommandWindow::setNoForm(bool andHide) {
typedef std::pair<Command::Action, QPushButton*> ActionButton;
void QtAdHocCommandWindow::setAvailableActions(Command::ref /*commandResult*/) {
+ okButton_->show();
+ okButton_->setEnabled(true);
foreach (ActionButton pair, actions_) {
OutgoingAdHocCommandSession::ActionState state = command_->getActionState(pair.first);
if (state & OutgoingAdHocCommandSession::Present) {
+ okButton_->hide();
+ okButton_->setEnabled(false);
pair.second->show();
}
else {
diff --git a/Swift/QtUI/QtAdHocCommandWindow.h b/Swift/QtUI/QtAdHocCommandWindow.h
index 231a51c..c8d493c 100644
--- a/Swift/QtUI/QtAdHocCommandWindow.h
+++ b/Swift/QtUI/QtAdHocCommandWindow.h
@@ -1,18 +1,20 @@
/*
- * Copyright (c) 2010-2012 Isode Limited.
+ * Copyright (c) 2010-2015 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
-#include <QWidget>
-#include <QPushButton>
+#include <QDialogButtonBox>
#include <QLabel>
+#include <QPushButton>
+#include <QWidget>
-#include <Swift/Controllers/UIInterfaces/AdHocCommandWindow.h>
#include <Swiften/AdHoc/OutgoingAdHocCommandSession.h>
+#include <Swift/Controllers/UIInterfaces/AdHocCommandWindow.h>
+
class QBoxLayout;
namespace Swift {
@@ -23,6 +25,7 @@ namespace Swift {
QtAdHocCommandWindow(boost::shared_ptr<OutgoingAdHocCommandSession> command);
virtual ~QtAdHocCommandWindow();
virtual void setOnline(bool online);
+
private:
void closeEvent(QCloseEvent* event);
void handleNextStageReceived(Command::ref command);
@@ -30,11 +33,13 @@ namespace Swift {
void setForm(Form::ref);
void setNoForm(bool andHide);
void setAvailableActions(Command::ref commandResult);
+
private slots:
void handleCancelClicked();
void handlePrevClicked();
void handleNextClicked();
void handleCompleteClicked();
+
private:
boost::shared_ptr<OutgoingAdHocCommandSession> command_;
QtFormWidget* formWidget_;
@@ -45,7 +50,9 @@ namespace Swift {
QPushButton* nextButton_;
QPushButton* completeButton_;
QPushButton* cancelButton_;
+ QPushButton* okButton_;
std::map<Command::Action, QPushButton*> actions_;
+ QDialogButtonBox* dialogButtons_;
QBoxLayout* layout_;
};
}