From f5ddc6b637ac69470d39b68ecc2a7c7312a95da7 Mon Sep 17 00:00:00 2001 From: Kevin Smith <git@kismith.co.uk> Date: Sun, 29 Apr 2012 10:16:27 +0100 Subject: Render notes in AdHoc commands. Resolves: #1074 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(); -- cgit v0.10.2-6-g49f6