1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-30 15:52:12 +01:00

OP-1628 Removed reboot page in wizard and replaced it with reboot dialog. Still some quirks to fix.

This commit is contained in:
m_thread 2015-01-09 00:42:43 +01:00
parent bd5171d442
commit 230d7eaef5
12 changed files with 210 additions and 297 deletions

View File

@ -1,119 +0,0 @@
/**
******************************************************************************
*
* @file rebootpage.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @addtogroup
* @{
* @addtogroup RebootPage
* @{
* @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
*/
#include "rebootpage.h"
#include "ui_rebootpage.h"
RebootPage::RebootPage(SetupWizard *wizard, QWidget *parent) :
AbstractWizardPage(wizard, parent),
ui(new Ui::RebootPage), m_toggl(false), m_isRebooting(false)
{
ui->setupUi(this);
ui->yellowLabel->setVisible(false);
ui->redLabel->setVisible(true);
connect(ui->rebootButton, SIGNAL(clicked()), this, SLOT(reboot()));
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
Q_ASSERT(pm);
m_uploader = pm->getObject<UploaderGadgetFactory>();
Q_ASSERT(m_uploader);
}
RebootPage::~RebootPage()
{
disconnect(&m_timer, SIGNAL(timeout()), this, SLOT(toggleLabel()));
m_timer.stop();
delete ui;
}
void RebootPage::initializePage()
{
ui->messageLabel->setText("");
ui->rebootProgress->setValue(0);
if (!m_timer.isActive()) {
connect(&m_timer, SIGNAL(timeout()), this, SLOT(toggleLabel()));
m_timer.setInterval(500);
m_timer.setSingleShot(false);
m_timer.start();
}
}
bool RebootPage::validatePage()
{
return !m_isRebooting;
}
void RebootPage::toggleLabel()
{
m_toggl = !m_toggl;
ui->yellowLabel->setVisible(m_toggl);
ui->redLabel->setVisible(!m_toggl);
}
void RebootPage::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);
ui->rebootButton->setEnabled(enable);
}
void RebootPage::reboot()
{
enableButtons(false);
ui->rebootProgress->setValue(0);
QApplication::processEvents();
connect(m_uploader, SIGNAL(progressUpdate(uploader::ProgressStep, QVariant)), this, SLOT(progressUpdate(uploader::ProgressStep, QVariant)));
ui->messageLabel->setText(tr("Reboot in progress..."));
m_isRebooting = true;
m_uploader->reboot();
}
void RebootPage::progressUpdate(uploader::ProgressStep progress, QVariant message)
{
Q_UNUSED(message);
if (progress == uploader::SUCCESS || progress == uploader::FAILURE) {
disconnect(m_uploader, SIGNAL(progressUpdate(uploader::ProgressStep, QVariant)), this, SLOT(progressUpdate(uploader::ProgressStep, QVariant)));
if (progress == uploader::FAILURE) {
ui->messageLabel->setText(tr("<font color='red'>Software reboot failed!</font><p> Please perform a manual reboot by power cycling the board. "
"To power cycle the controller remove all batteries and the USB cable for at least 30 seconds. "
"After 30 seconds, plug in the board again and wait for it to connect, this can take a few seconds. Then press Next."));
} else {
ui->messageLabel->setText(tr("<font color='green'>Reboot complete!</font>"));
}
m_isRebooting= false;
enableButtons(true);
} else {
ui->rebootProgress->setValue(ui->rebootProgress->value() + 1);
}
}
bool RebootPage::isComplete() const
{
return !m_isRebooting;
}

View File

@ -1,137 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>RebootPage</class>
<widget class="QWizardPage" name="RebootPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>400</height>
</rect>
</property>
<property name="windowTitle">
<string>WizardPage</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="redLabel">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Cantarell'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:18pt; color:#ff0000;&quot;&gt;PLEASE REBOOT YOUR CONTROLLER&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="yellowLabel">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:18pt; color:#ffd500;&quot;&gt;PLEASE REBOOT YOUR CONTROLLER&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="infoLabel">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:10pt; color:#000000;&quot;&gt;The configuration created by the wizard contains settings that require a reboot of your controller. &lt;br /&gt;&lt;br /&gt;Press the button below to reboot board. Wait for the board to connect again and the Next button to be enabled before continuing. After board is connected press Next to continue wizard.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="messageLabel">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="rebootProgress">
<property name="styleSheet">
<string notr="true">QProgressBar {
border: 2px solid grey;
border-radius: 5px;
text-align: center;
}
QProgressBar::chunk {
background-color: #3D6699;
width: 10px;
margin: 0.5px;
}</string>
</property>
<property name="maximum">
<number>6</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="textVisible">
<bool>false</bool>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QPushButton" name="rebootButton">
<property name="text">
<string>Reboot</string>
</property>
</widget>
</item>
</layout>
<zorder>yellowLabel</zorder>
<zorder>redLabel</zorder>
<zorder>infoLabel</zorder>
<zorder>rebootButton</zorder>
<zorder>verticalSpacer</zorder>
<zorder>messageLabel</zorder>
<zorder>rebootProgress</zorder>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -44,7 +44,6 @@
#include "pages/summarypage.h"
#include "pages/savepage.h"
#include "pages/notyetimplementedpage.h"
#include "pages/rebootpage.h"
#include "pages/outputcalibrationpage.h"
#include "pages/revocalibrationpage.h"
#include "pages/airframeinitialtuningpage.h"
@ -141,11 +140,8 @@ int SetupWizard::nextId() const
case PAGE_INPUT:
if (isRestartNeeded()) {
saveHardwareSettings();
return PAGE_REBOOT;
} else {
return PAGE_VEHICLES;
reboot();
}
case PAGE_REBOOT:
return PAGE_VEHICLES;
case PAGE_ESC:
@ -470,7 +466,6 @@ void SetupWizard::createPages()
setPage(PAGE_OUTPUT_CALIBRATION, new OutputCalibrationPage(this));
setPage(PAGE_SUMMARY, new SummaryPage(this));
setPage(PAGE_SAVE, new SavePage(this));
setPage(PAGE_REBOOT, new RebootPage(this));
setPage(PAGE_NOTYETIMPLEMENTED, new NotYetImplementedPage(this));
setPage(PAGE_AIRFRAME_INITIAL_TUNING, new AirframeInitialTuningPage(this));
setPage(PAGE_END, new OPEndPage(this));
@ -500,6 +495,15 @@ void SetupWizard::pageChanged(int currId)
button(QWizard::CancelButton)->setVisible(currId != PAGE_END);
}
void SetupWizard::reboot() const
{
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
Q_ASSERT(pm);
UploaderGadgetFactory *uploader = pm->getObject<UploaderGadgetFactory>();
Q_ASSERT(uploader);
uploader->reboot();
}
bool SetupWizard::saveHardwareSettings() const
{
VehicleConfigurationHelper helper(const_cast<SetupWizard *>(this));

View File

@ -192,6 +192,7 @@ private:
void createPages();
bool saveHardwareSettings() const;
bool canAutoUpdate() const;
void reboot() const;
CONTROLLER_TYPE m_controllerType;
VEHICLE_TYPE m_vehicleType;

View File

@ -31,7 +31,6 @@ HEADERS += setupwizardplugin.h \
connectiondiagram.h \
pages/outputcalibrationpage.h \
outputcalibrationutil.h \
pages/rebootpage.h \
pages/savepage.h \
pages/autoupdatepage.h \
pages/revocalibrationpage.h \
@ -65,7 +64,6 @@ SOURCES += setupwizardplugin.cpp \
connectiondiagram.cpp \
pages/outputcalibrationpage.cpp \
outputcalibrationutil.cpp \
pages/rebootpage.cpp \
pages/savepage.cpp \
pages/autoupdatepage.cpp \
pages/revocalibrationpage.cpp \
@ -92,7 +90,6 @@ FORMS += \
pages/summarypage.ui \
connectiondiagram.ui \
pages/outputcalibrationpage.ui \
pages/rebootpage.ui \
pages/savepage.ui \
pages/autoupdatepage.ui \
pages/revocalibrationpage.ui \

View File

@ -0,0 +1,76 @@
/**
******************************************************************************
*
* @file rebootdialog.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @addtogroup [Group]
* @{
* @addtogroup RebootDialog
* @{
* @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
*/
#include "rebootdialog.h"
#include "ui_rebootdialog.h"
RebootDialog::RebootDialog(UploaderGadgetWidget *uploader, QWidget *parent) :
QDialog(parent),
ui(new Ui::RebootDialog), m_uploader(uploader)
{
ui->setupUi(this);
connect(this, SIGNAL(reboot()), m_uploader, SLOT(systemReboot()));
ui->rebootProgressBar->setVisible(true);
ui->okButton->setVisible(false);
}
RebootDialog::~RebootDialog()
{
delete ui;
}
void RebootDialog::on_okButton_clicked()
{
reject();
}
int RebootDialog::exec()
{
show();
connect(m_uploader, SIGNAL(progressUpdate(uploader::ProgressStep, QVariant)), this, SLOT(progressUpdate(uploader::ProgressStep, QVariant)));
emit reboot();
return result();
}
void RebootDialog::progressUpdate(uploader::ProgressStep progress, QVariant message)
{
Q_UNUSED(message);
if (progress == uploader::SUCCESS || progress == uploader::FAILURE) {
disconnect(m_uploader, SIGNAL(progressUpdate(uploader::ProgressStep, QVariant)), this, SLOT(progressUpdate(uploader::ProgressStep, QVariant)));
if (progress == uploader::FAILURE) {
ui->rebootProgressBar->setVisible(false);
ui->okButton->setVisible(true);
ui->label->setText(tr("<font color='red'>Reboot failed!</font><p> Please perform a manual reboot by power cycling the board.<br>"
"To power cycle the controller remove all batteries and the USB cable for at least 30 seconds.<br>"
"After 30 seconds, plug in the board again and wait for it to connect, this can take a few seconds.<br>"
"Then press Ok."));
QDialog::exec();
} else {
accept();
}
}
}

View File

@ -1,13 +1,13 @@
/**
******************************************************************************
*
* @file rebootpage.h
* @file rebootdialog.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @addtogroup
* @addtogroup [Group]
* @{
* @addtogroup RebootPage
* @addtogroup RebootDialog
* @{
* @brief
* @brief [Brief]
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
@ -25,41 +25,37 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef REBOOTPAGE_H
#define REBOOTPAGE_H
#ifndef REBOOTDIALOG_H
#define REBOOTDIALOG_H
#include "abstractwizardpage.h"
#include <extensionsystem/pluginmanager.h>
#include <extensionsystem/pluginmanager.h>
#include "uploader/uploadergadgetfactory.h"
#include <QDialog>
#include "uploadergadgetwidget.h"
namespace Ui {
class RebootPage;
class RebootDialog;
}
class RebootPage : public AbstractWizardPage {
class RebootDialog : public QDialog
{
Q_OBJECT
public:
explicit RebootPage(SetupWizard *wizard, QWidget *parent = 0);
~RebootPage();
explicit RebootDialog(UploaderGadgetWidget *uploader, QWidget *parent = 0);
~RebootDialog();
void initializePage();
bool validatePage();
bool isComplete() const;
void enableButtons(bool enable);
private:
Ui::RebootPage *ui;
QTimer m_timer;
bool m_toggl;
UploaderGadgetFactory *m_uploader;
bool m_isRebooting;
signals:
void reboot();
private slots:
void toggleLabel();
void reboot();
void on_okButton_clicked();
void progressUpdate(uploader::ProgressStep progress, QVariant message);
private:
Ui::RebootDialog *ui;
UploaderGadgetWidget *m_uploader;
public slots:
int exec();
};
#endif // REBOOTPAGE_H
#endif // REBOOTDIALOG_H

View File

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>RebootDialog</class>
<widget class="QDialog" name="RebootDialog">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>445</width>
<height>180</height>
</rect>
</property>
<property name="windowTitle">
<string>Reboot</string>
</property>
<property name="windowIcon">
<iconset resource="../coreplugin/core.qrc">
<normaloff>:/core/images/flight.png</normaloff>:/core/images/flight.png</iconset>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Please wait. Your controller is rebooting.&lt;br/&gt;This can take up to a minute.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="rebootProgressBar">
<property name="styleSheet">
<string notr="true">QProgressBar {
border: 2px solid grey;
border-radius: 5px;
text-align: center;
}
QProgressBar::chunk {
background-color: #3D6699;
width: 10px;
margin: 0.5px;
}</string>
</property>
<property name="maximum">
<number>0</number>
</property>
<property name="value">
<number>-1</number>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QPushButton" name="okButton">
<property name="text">
<string>Ok</string>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../coreplugin/core.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -30,7 +30,8 @@ HEADERS += uploadergadget.h \
SSP/common.h \
runningdevicewidget.h \
uploader_global.h \
enums.h
enums.h \
rebootdialog.h
SOURCES += uploadergadget.cpp \
uploadergadgetconfiguration.cpp \
@ -44,14 +45,16 @@ SOURCES += uploadergadget.cpp \
SSP/port.cpp \
SSP/qssp.cpp \
SSP/qsspt.cpp \
runningdevicewidget.cpp
runningdevicewidget.cpp \
rebootdialog.cpp
OTHER_FILES += Uploader.pluginspec
FORMS += \
uploader.ui \
devicewidget.ui \
runningdevicewidget.ui
runningdevicewidget.ui \
rebootdialog.ui
RESOURCES += uploader.qrc

View File

@ -45,7 +45,7 @@ Core::IUAVGadget *UploaderGadgetFactory::createGadget(QWidget *parent)
isautocapable = gadgetWidget->autoUpdateCapable();
connect(this, SIGNAL(autoUpdate(bool)), gadgetWidget, SLOT(autoUpdate(bool)));
connect(this, SIGNAL(reboot()), gadgetWidget, SLOT(systemReboot()));
connect(this, SIGNAL(reboot()), gadgetWidget, SLOT(rebootWithDialog()));
connect(gadgetWidget, SIGNAL(progressUpdate(uploader::ProgressStep, QVariant)), this, SIGNAL(progressUpdate(uploader::ProgressStep, QVariant)));
return new UploaderGadget(QString("Uploader"), gadgetWidget, parent);
}

View File

@ -41,6 +41,7 @@
#include <QMessageBox>
#include <QProgressBar>
#include <QDebug>
#include "rebootdialog.h"
#define DFU_DEBUG true
@ -548,6 +549,12 @@ void UploaderGadgetWidget::systemEraseBoot()
}
}
void UploaderGadgetWidget::rebootWithDialog()
{
RebootDialog dialog(this);
dialog.exec();
}
void UploaderGadgetWidget::systemReboot()
{
ResultEventLoop eventLoop;

View File

@ -160,6 +160,7 @@ private slots:
void systemBoot();
void systemSafeBoot();
void systemEraseBoot();
void rebootWithDialog();
void systemReboot();
void commonSystemBoot(bool safeboot = false, bool erase = false);
void systemRescue();