32 #include <QPushButton>
35 #include "ui_upgradeassistant.h"
39 , ui(new Ui::UpgradeAssistant)
56 originalText[
i] =
new QString(stepLabels[
i]->text());
59 connect(ui->buttonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject);
69 ui->lblUpgradeBootloader->setEnabled(upgradingBootloader);
71 ui->lblDownloadSettings->setEnabled(!blankFC);
72 ui->lblTranslateSettings->setEnabled(!blankFC);
73 ui->lblImport->setEnabled(!blankFC);
79 QStringList buttonText)
89 foreach (
const QString &buttLabel, buttonText) {
90 QPushButton *newButt =
new QPushButton(buttLabel);
91 buttons.append(newButt);
92 ui->buttonBox->addButton(newButt, QDialogButtonBox::ActionRole);
94 connect(newButt, &QPushButton::clicked, &loop, [&, i](
bool checked) {
103 connect(
this, &UpgradeAssistantDialog::finished, &loop, &QEventLoop::quit);
105 ui->lblStatus->setText(promptText);
106 ui->lblDetailStatus->setText(detailText);
110 foreach (QPushButton *button, buttons) {
111 ui->buttonBox->removeButton(button);
116 ui->lblStatus->setText(tr(
"Auto-upgrade running..."));
117 ui->lblDetailStatus->setText(
118 tr(
"Please wait while the upgrader performs automated actions on the flight board."));
125 qDebug() << QString(
"UpgradeAssistant: in step %1").arg(step);
134 if (stepLabels[
i]->isEnabled()) {
135 stepLabels[
i]->setText(*originalText[
i] + tr(
" done!"));
137 stepLabels[
i]->setText(*originalText[
i] + tr(
" (skipped)"));
139 }
else if (
i == stepVal) {
141 stepLabels[
i]->setText(QString(
"<b>%1</b>").arg(*originalText[
i]));
144 stepLabels[
i]->setText(*originalText[
i]);
149 ui->buttonBox->setStandardButtons(QDialogButtonBox::Close);
151 ui->lblStatus->setText(tr(
"Auto-upgrade complete!"));
152 ui->lblDetailStatus->setText(
153 tr(
"It may be necessary to reset your flight board (by removing and attaching power "
154 "and USB) to apply settings."));
156 ui->buttonBox->setStandardButtons(QDialogButtonBox::Abort);
158 ui->lblStatus->setText(tr(
"Auto-upgrade running..."));
159 ui->lblDetailStatus->setText(
160 tr(
"Please wait while the upgrader performs automated actions on the flight board."));
void closeEvent(QCloseEvent *event)
int PromptUser(QString promptText, QString detailText, QStringList buttonText)
UpgradeAssistantDialog(QWidget *parent=nullptr)
void setOperatingMode(bool upgradingBootloader, bool blankFC)
void onStepChanged(UpgradeAssistantStep step)
~UpgradeAssistantDialog()