1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

OP-686 Added code to disable wizard buttons during firmware upgrade procedure. Re-factored some code and fixed some minor bugs.

This commit is contained in:
Fredrik Arvidsson 2012-11-08 19:53:31 +01:00 committed by Oleg Semyonov
parent 8332f32519
commit 08fd9a8153
5 changed files with 54 additions and 9 deletions

26
OPLicenseTemplate.txt Normal file
View File

@ -0,0 +1,26 @@
/**
******************************************************************************
*
* @file %FILENAME%
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @addtogroup [Group]
* @{
* @addtogroup %CLASS%
* @{
* @brief [Brief]
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

View File

@ -8,13 +8,14 @@
AutoUpdatePage::AutoUpdatePage(SetupWizard *wizard, QWidget *parent) :
AbstractWizardPage(wizard, parent),
ui(new Ui::AutoUpdatePage),m_wiz(wizard)
ui(new Ui::AutoUpdatePage)
{
ui->setupUi(this);
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
Q_ASSERT(pm);
UploaderGadgetFactory *uploader = pm->getObject<UploaderGadgetFactory>();
Q_ASSERT(uploader);
connect(ui->startUpdate,SIGNAL(clicked()), this, SLOT(disableButtons()));
connect(ui->startUpdate,SIGNAL(clicked()),uploader,SIGNAL(autoUpdate()));
connect(uploader,SIGNAL(autoUpdateSignal(uploader::AutoUpdateStep,QVariant)),this,SLOT(updateStatus(uploader::AutoUpdateStep,QVariant)));
}
@ -24,18 +25,30 @@ AutoUpdatePage::~AutoUpdatePage()
delete ui;
}
void AutoUpdatePage::enableButtons(bool enable = false)
{
ui->startUpdate->setEnabled(enable);
getWizard()->button(QWizard::NextButton)->setEnabled(enable);
getWizard()->button(QWizard::CancelButton)->setEnabled(enable);
getWizard()->button(QWizard::BackButton)->setEnabled(enable);
getWizard()->button(QWizard::CustomButton1)->setEnabled(enable);
QApplication::processEvents();
}
void AutoUpdatePage::updateStatus(uploader::AutoUpdateStep status, QVariant value)
{
switch(status)
{
case uploader::WAITING_DISCONNECT:
m_wiz->setWindowFlags(m_wiz->windowFlags() & ~Qt::WindowStaysOnTopHint);
getWizard()->setWindowFlags(getWizard()->windowFlags() & ~Qt::WindowStaysOnTopHint);
disableButtons();
ui->statusLabel->setText("Waiting for all OP boards to be disconnected");
break;
case uploader::WAITING_CONNECT:
m_wiz->setWindowFlags(m_wiz->windowFlags() | Qt::WindowStaysOnTopHint);
m_wiz->setWindowIcon(qApp->windowIcon());
m_wiz->show();
getWizard()->setWindowFlags(getWizard()->windowFlags() | Qt::WindowStaysOnTopHint);
getWizard()->setWindowIcon(qApp->windowIcon());
disableButtons();
getWizard()->show();
ui->statusLabel->setText("Please connect the board to the USB port (don't use external supply)");
ui->levellinProgressBar->setValue(value.toInt());
break;
@ -57,12 +70,14 @@ void AutoUpdatePage::updateStatus(uploader::AutoUpdateStep status, QVariant valu
ui->statusLabel->setText("Booting the board");
break;
case uploader::SUCCESS:
enableButtons(true);
ui->statusLabel->setText("Board Updated, please press the 'next' button below");
break;
case uploader::FAILURE:
m_wiz->setWindowFlags(m_wiz->windowFlags() | Qt::WindowStaysOnTopHint);
m_wiz->setWindowIcon(qApp->windowIcon());
m_wiz->show();
getWizard()->setWindowFlags(getWizard()->windowFlags() | Qt::WindowStaysOnTopHint);
getWizard()->setWindowIcon(qApp->windowIcon());
enableButtons(true);
getWizard()->show();
ui->statusLabel->setText("Something went wrong, you will have to manualy upgrade the board using the uploader plugin");
break;
}

View File

@ -49,10 +49,12 @@ public:
private slots:
void updateStatus(uploader::AutoUpdateStep ,QVariant);
void disableButtons(){ enableButtons(false); }
void enableButtons(bool enable);
private:
Ui::AutoUpdatePage *ui;
SetupWizard * m_wiz;
};
#endif // AUTOUPDATEPAGE_H

View File

@ -64,6 +64,7 @@ void LevellingPage::enableButtons(bool enable)
getWizard()->button(QWizard::NextButton)->setEnabled(enable);
getWizard()->button(QWizard::CancelButton)->setEnabled(enable);
getWizard()->button(QWizard::BackButton)->setEnabled(enable);
getWizard()->button(QWizard::CustomButton1)->setEnabled(enable);
QApplication::processEvents();
}

View File

@ -85,6 +85,7 @@ void SavePage::enableButtons(bool enable)
getWizard()->button(QWizard::NextButton)->setEnabled(enable);
getWizard()->button(QWizard::CancelButton)->setEnabled(enable);
getWizard()->button(QWizard::BackButton)->setEnabled(enable);
getWizard()->button(QWizard::CustomButton1)->setEnabled(enable);
QApplication::processEvents();
}