diff options
author | Kevin Smith <git@kismith.co.uk> | 2012-04-29 09:16:27 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2012-04-29 09:17:50 (GMT) |
commit | f5ddc6b637ac69470d39b68ecc2a7c7312a95da7 (patch) | |
tree | b11dcd6de97663624724f4003abe07d3b8b6e07c /Swift/QtUI | |
parent | 3b129ea8f24bb87c946e3879f74a8437be27376c (diff) | |
download | swift-contrib-f5ddc6b637ac69470d39b68ecc2a7c7312a95da7.zip swift-contrib-f5ddc6b637ac69470d39b68ecc2a7c7312a95da7.tar.bz2 |
Render notes in AdHoc commands.
Resolves: #1074
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/QtAdHocCommandWindow.cpp | 28 | ||||
-rw-r--r-- | Swift/QtUI/QtAdHocCommandWindow.h | 2 |
2 files changed, 16 insertions, 14 deletions
diff --git a/Swift/QtUI/QtAdHocCommandWindow.cpp b/Swift/QtUI/QtAdHocCommandWindow.cpp index b0281d9..5d87031 100644 --- a/Swift/QtUI/QtAdHocCommandWindow.cpp +++ b/Swift/QtUI/QtAdHocCommandWindow.cpp @@ -10,6 +10,7 @@ #include <QBoxLayout> #include <Swift/QtUI/QtFormWidget.h> #include <Swiften/Elements/Command.h> +#include <Swift/QtUI/QtSwiftUtil.h> const int FormLayoutIndex = 1; @@ -75,24 +76,24 @@ void QtAdHocCommandWindow::handleCompleteClicked() { } void QtAdHocCommandWindow::handleNextStageReceived(Command::ref command) { - if (command->getForm()) { - setForm(command->getForm()); - } else { - setNoForm(); - } QString notes; foreach (Command::Note note, command->getNotes()) { if (!notes.isEmpty()) { notes += "\n"; - QString qNote(note.note.c_str()); - switch (note.type) { - case Command::Note::Error: notes += tr("Error: %1").arg(qNote); break; - case Command::Note::Warn: notes += tr("Warning: %1").arg(qNote); break; - case Command::Note::Info: notes += qNote; break; - } + } + QString qNote(P2QSTRING(note.note)); + switch (note.type) { + case Command::Note::Error: notes += tr("Error: %1").arg(qNote); break; + case Command::Note::Warn: notes += tr("Warning: %1").arg(qNote); break; + case Command::Note::Info: notes += qNote; break; } } label_->setText(notes); + if (command->getForm()) { + setForm(command->getForm()); + } else { + setNoForm(notes.isEmpty()); + } setAvailableActions(command); } @@ -111,11 +112,12 @@ void QtAdHocCommandWindow::setForm(Form::ref form) { show(); } -void QtAdHocCommandWindow::setNoForm() { +void QtAdHocCommandWindow::setNoForm(bool andHide) { form_.reset(); delete formWidget_; formWidget_ = NULL; - hide(); + resize(minimumSize()); + setVisible(!andHide); } typedef std::pair<Command::Action, QPushButton*> ActionButton; diff --git a/Swift/QtUI/QtAdHocCommandWindow.h b/Swift/QtUI/QtAdHocCommandWindow.h index 42e3b1c..d42a77d 100644 --- a/Swift/QtUI/QtAdHocCommandWindow.h +++ b/Swift/QtUI/QtAdHocCommandWindow.h @@ -26,7 +26,7 @@ namespace Swift { void handleNextStageReceived(Command::ref command); void handleError(ErrorPayload::ref error); void setForm(Form::ref); - void setNoForm(); + void setNoForm(bool andHide); void setAvailableActions(Command::ref commandResult); private slots: void handleCancelClicked(); |