diff options
author | Tobias Markmann <tm@ayena.de> | 2015-06-03 06:19:49 (GMT) |
---|---|---|
committer | Kevin Smith <kevin.smith@isode.com> | 2015-06-05 19:52:20 (GMT) |
commit | 3741c9ad5c0cc6f92e4ed913d67b3b530882334e (patch) | |
tree | baa449dcf475ceb291444bb80e78196d94ccc1e4 /Swift/QtUI/QtAdHocCommandWindow.cpp | |
parent | dba9757d5805ab308b56c9e623a076426b2dd4c2 (diff) | |
download | swift-3741c9ad5c0cc6f92e4ed913d67b3b530882334e.zip swift-3741c9ad5c0cc6f92e4ed913d67b3b530882334e.tar.bz2 |
UI improvements to the ad-hoc command window
Use QDialogButtonBox instead of custom button layout code. This way
the button are correctly layouted depending on platform guidelines.
Show a 'Ok' button if no other button is shown which closes the window.
Test-Information:
Tested on OS X 10.9.5 with Qt 5.4.2.
Change-Id: I37581982766d013f4d3d636880fd5ada59ee0c40
Diffstat (limited to 'Swift/QtUI/QtAdHocCommandWindow.cpp')
-rw-r--r-- | Swift/QtUI/QtAdHocCommandWindow.cpp | 45 |
1 files changed, 28 insertions, 17 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 { |