1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

OP-39 Added reboot page to wizard. User needing to reboot should NOT forget it now.

Added code to invoke Vehicle Setup Wizard and Radio Wizard from Welcome page.
This commit is contained in:
Fredrik Arvidsson 2012-09-16 23:03:15 +02:00
parent 098c0d43fd
commit 806097fd56
15 changed files with 281 additions and 9 deletions

View File

@ -29,6 +29,10 @@
#include "configgadgetconfiguration.h" #include "configgadgetconfiguration.h"
#include "configgadgetoptionspage.h" #include "configgadgetoptionspage.h"
#include <coreplugin/iuavgadget.h> #include <coreplugin/iuavgadget.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/icore.h>
#include <coreplugin/modemanager.h>
ConfigGadgetFactory::ConfigGadgetFactory(QObject *parent) : ConfigGadgetFactory::ConfigGadgetFactory(QObject *parent) :
IUAVGadgetFactory(QString("ConfigGadget"), tr("Config Gadget"), parent), IUAVGadgetFactory(QString("ConfigGadget"), tr("Config Gadget"), parent),
@ -43,6 +47,25 @@ ConfigGadgetFactory::~ConfigGadgetFactory()
Core::IUAVGadget* ConfigGadgetFactory::createGadget(QWidget *parent) Core::IUAVGadget* ConfigGadgetFactory::createGadget(QWidget *parent)
{ {
gadgetWidget = new ConfigGadgetWidget(parent); gadgetWidget = new ConfigGadgetWidget(parent);
// Add Menu entry
Core::ActionManager* am = Core::ICore::instance()->actionManager();
Core::ActionContainer* ac = am->actionContainer(Core::Constants::M_TOOLS);
Core::Command* cmd = am->registerAction(new QAction(this),
"ConfigPlugin.ShowInputWizard",
QList<int>() <<
Core::Constants::C_GLOBAL_ID);
cmd->setDefaultKeySequence(QKeySequence("Ctrl+R"));
cmd->action()->setText(tr("Radio Setup Wizard"));
Core::ModeManager::instance()->addAction(cmd, 1);
ac->appendGroup("Wizard");
ac->addAction(cmd, "Wizard");
connect(cmd->action(), SIGNAL(triggered(bool)), this, SLOT(startInputWizard()));
return new ConfigGadget(QString("ConfigGadget"), gadgetWidget, parent); return new ConfigGadget(QString("ConfigGadget"), gadgetWidget, parent);
} }
@ -60,6 +83,7 @@ void ConfigGadgetFactory::startInputWizard()
{ {
if(gadgetWidget) if(gadgetWidget)
{ {
Core::ModeManager::instance()->activateModeByWorkspaceName("Configuration");
gadgetWidget->startInputWizard(); gadgetWidget->startInputWizard();
} }
} }

View File

@ -50,6 +50,8 @@ public:
IUAVGadget *createGadget(QWidget *parent); IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings); IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config); IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
public slots:
void startInputWizard(); void startInputWizard();
private: private:

View File

@ -326,3 +326,13 @@ void ModeManager::setFocusToCurrentMode()
widget->setFocus(); widget->setFocus();
} }
} }
void ModeManager::triggerAction(const QString &actionId)
{
foreach(Command * command, m_actions.keys()){
if(command->action()->objectName() == actionId) {
command->action()->trigger();
break;
}
}
}

View File

@ -82,6 +82,7 @@ public slots:
void activateMode(const QString &id); void activateMode(const QString &id);
void activateModeByWorkspaceName(const QString &id); void activateModeByWorkspaceName(const QString &id);
void setFocusToCurrentMode(); void setFocusToCurrentMode();
void triggerAction(const QString &actionId);
private slots: private slots:
void objectAdded(QObject *obj); void objectAdded(QObject *obj);

View File

@ -51,7 +51,7 @@ void EndPage::openInputWizard()
ConfigGadgetFactory* configGadgetFactory = pm->getObject<ConfigGadgetFactory>(); ConfigGadgetFactory* configGadgetFactory = pm->getObject<ConfigGadgetFactory>();
if(configGadgetFactory) { if(configGadgetFactory) {
Core::ModeManager::instance()->activateModeByWorkspaceName("Configuration"); //Core::ModeManager::instance()->activateModeByWorkspaceName("Configuration");
getWizard()->close(); getWizard()->close();
configGadgetFactory->startInputWizard(); configGadgetFactory->startInputWizard();
} }

View File

@ -0,0 +1,66 @@
/**
******************************************************************************
*
* @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)
{
ui->setupUi(this);
ui->yellowLabel->setVisible(false);
ui->redLabel->setVisible(true);
}
RebootPage::~RebootPage()
{
disconnect(&m_timer, SIGNAL(timeout()), this, SLOT(toggleLabel()));
m_timer.stop();
delete ui;
}
void RebootPage::initializePage()
{
connect(&m_timer, SIGNAL(timeout()), this, SLOT(toggleLabel()));
m_timer.setInterval(500);
m_timer.setSingleShot(false);
m_timer.start();
}
bool RebootPage::validatePage()
{
return true;
}
void RebootPage::toggleLabel()
{
m_toggl = !m_toggl;
ui->yellowLabel->setVisible(m_toggl);
ui->redLabel->setVisible(!m_toggl);
qDebug() << "Toggle = " << m_toggl;
}

View File

@ -0,0 +1,57 @@
/**
******************************************************************************
*
* @file rebootpage.h
* @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
*/
#ifndef REBOOTPAGE_H
#define REBOOTPAGE_H
#include "abstractwizardpage.h"
namespace Ui {
class RebootPage;
}
class RebootPage : public AbstractWizardPage
{
Q_OBJECT
public:
explicit RebootPage(SetupWizard *wizard, QWidget *parent = 0);
~RebootPage();
void initializePage();
bool validatePage();
private:
Ui::RebootPage *ui;
QTimer m_timer;
bool m_toggl;
private slots:
void toggleLabel();
};
#endif // REBOOTPAGE_H

View File

@ -0,0 +1,91 @@
<?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>
<widget class="QLabel" name="redLabel">
<property name="geometry">
<rect>
<x>50</x>
<y>130</y>
<width>501</width>
<height>41</height>
</rect>
</property>
<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:'MS Shell Dlg 2'; font-size:8pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; 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>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>50</x>
<y>180</y>
<width>501</width>
<height>61</height>
</rect>
</property>
<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:'MS Shell Dlg 2'; font-size:8pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:10pt; color:#000000;&quot;&gt;The configuration created by the wizard contains settings that require a reboot of your controller. Please power cycle the controller before continuing.&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>
<widget class="QLabel" name="yellowLabel">
<property name="geometry">
<rect>
<x>50</x>
<y>130</y>
<width>501</width>
<height>41</height>
</rect>
</property>
<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:'MS Shell Dlg 2'; font-size:8pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; 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>
<zorder>yellowLabel</zorder>
<zorder>redLabel</zorder>
<zorder>label_3</zorder>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -41,6 +41,7 @@
#include "pages/flashpage.h" #include "pages/flashpage.h"
#include "pages/outputcalibrationpage.h" #include "pages/outputcalibrationpage.h"
#include "pages/notyetimplementedpage.h" #include "pages/notyetimplementedpage.h"
#include "pages/rebootpage.h"
#include "extensionsystem/pluginmanager.h" #include "extensionsystem/pluginmanager.h"
#include "vehicleconfigurationhelper.h" #include "vehicleconfigurationhelper.h"
#include "actuatorsettings.h" #include "actuatorsettings.h"
@ -105,6 +106,13 @@ int SetupWizard::nextId() const
case PAGE_SUMMARY: case PAGE_SUMMARY:
return PAGE_LEVELLING; return PAGE_LEVELLING;
case PAGE_FLASH: case PAGE_FLASH:
if(isRestartNeeded()) {
return PAGE_REBOOT;
}
else {
return PAGE_END;
}
case PAGE_REBOOT:
return PAGE_END; return PAGE_END;
case PAGE_NOTYETIMPLEMENTED: case PAGE_NOTYETIMPLEMENTED:
return PAGE_END; return PAGE_END;
@ -251,6 +259,7 @@ void SetupWizard::createPages()
setPage(PAGE_CALIBRATION, new OutputCalibrationPage(this)); setPage(PAGE_CALIBRATION, new OutputCalibrationPage(this));
setPage(PAGE_SUMMARY, new SummaryPage(this)); setPage(PAGE_SUMMARY, new SummaryPage(this));
setPage(PAGE_FLASH, new FlashPage(this)); setPage(PAGE_FLASH, new FlashPage(this));
setPage(PAGE_REBOOT, new RebootPage(this));
setPage(PAGE_NOTYETIMPLEMENTED, new NotYetImplementedPage(this)); setPage(PAGE_NOTYETIMPLEMENTED, new NotYetImplementedPage(this));
setPage(PAGE_END, new EndPage(this)); setPage(PAGE_END, new EndPage(this));

View File

@ -83,7 +83,7 @@ public:
private: private:
enum {PAGE_START, PAGE_CONTROLLER, PAGE_VEHICLES, PAGE_MULTI, PAGE_FIXEDWING, enum {PAGE_START, PAGE_CONTROLLER, PAGE_VEHICLES, PAGE_MULTI, PAGE_FIXEDWING,
PAGE_HELI, PAGE_SURFACE, PAGE_INPUT, PAGE_OUTPUT, PAGE_LEVELLING, PAGE_CALIBRATION, PAGE_HELI, PAGE_SURFACE, PAGE_INPUT, PAGE_OUTPUT, PAGE_LEVELLING, PAGE_CALIBRATION,
PAGE_FLASH, PAGE_SUMMARY, PAGE_NOTYETIMPLEMENTED, PAGE_END}; PAGE_FLASH, PAGE_SUMMARY, PAGE_NOTYETIMPLEMENTED, PAGE_REBOOT, PAGE_END};
void createPages(); void createPages();
CONTROLLER_TYPE m_controllerType; CONTROLLER_TYPE m_controllerType;

View File

@ -30,7 +30,8 @@ HEADERS += setupwizardplugin.h \
vehicleconfigurationhelper.h \ vehicleconfigurationhelper.h \
connectiondiagram.h \ connectiondiagram.h \
pages/outputcalibrationpage.h \ pages/outputcalibrationpage.h \
outputcalibrationutil.h outputcalibrationutil.h \
pages/rebootpage.h
SOURCES += setupwizardplugin.cpp \ SOURCES += setupwizardplugin.cpp \
setupwizard.cpp \ setupwizard.cpp \
@ -54,7 +55,8 @@ SOURCES += setupwizardplugin.cpp \
vehicleconfigurationhelper.cpp \ vehicleconfigurationhelper.cpp \
connectiondiagram.cpp \ connectiondiagram.cpp \
pages/outputcalibrationpage.cpp \ pages/outputcalibrationpage.cpp \
outputcalibrationutil.cpp outputcalibrationutil.cpp \
pages/rebootpage.cpp
OTHER_FILES += SetupWizard.pluginspec OTHER_FILES += SetupWizard.pluginspec
@ -74,7 +76,8 @@ FORMS += \
pages/flashpage.ui \ pages/flashpage.ui \
pages/levellingpage.ui \ pages/levellingpage.ui \
connectiondiagram.ui \ connectiondiagram.ui \
pages/outputcalibrationpage.ui pages/outputcalibrationpage.ui \
pages/rebootpage.ui
RESOURCES += \ RESOURCES += \
wizardResources.qrc wizardResources.qrc

View File

@ -35,6 +35,7 @@
#include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <QKeySequence> #include <QKeySequence>
#include <coreplugin/modemanager.h>
SetupWizardPlugin::SetupWizardPlugin() SetupWizardPlugin::SetupWizardPlugin()
{ {
@ -58,8 +59,10 @@ bool SetupWizardPlugin::initialize(const QStringList& args, QString *errMsg)
"SetupWizardPlugin.ShowSetupWizard", "SetupWizardPlugin.ShowSetupWizard",
QList<int>() << QList<int>() <<
Core::Constants::C_GLOBAL_ID); Core::Constants::C_GLOBAL_ID);
cmd->setDefaultKeySequence(QKeySequence("Ctrl+W")); cmd->setDefaultKeySequence(QKeySequence("Ctrl+V"));
cmd->action()->setText(tr("OpenPilot Setup Wizard")); cmd->action()->setText(tr("Vehicle Setup Wizard"));
Core::ModeManager::instance()->addAction(cmd, 1);
ac->menu()->addSeparator(); ac->menu()->addSeparator();
ac->appendGroup("Wizard"); ac->appendGroup("Wizard");

View File

@ -36,12 +36,12 @@ Rectangle {
WelcomePageButton { WelcomePageButton {
baseIconName: "bttn-vehwizard" baseIconName: "bttn-vehwizard"
onClicked: welcomePlugin.openPage("VehWizard") onClicked: welcomePlugin.triggerAction("SetupWizardPlugin.ShowSetupWizard")
} }
WelcomePageButton { WelcomePageButton {
baseIconName: "bttn-txwizard" baseIconName: "bttn-txwizard"
onClicked: welcomePlugin.openPage("TxWizard") onClicked: welcomePlugin.triggerAction("ConfigPlugin.ShowInputWizard")
} }
} }

View File

@ -127,4 +127,9 @@ void WelcomeMode::openPage(const QString &page)
Core::ModeManager::instance()->activateModeByWorkspaceName(page); Core::ModeManager::instance()->activateModeByWorkspaceName(page);
} }
void WelcomeMode::triggerAction(const QString &actionId)
{
Core::ModeManager::instance()->triggerAction(actionId);
}
} // namespace Welcome } // namespace Welcome

View File

@ -65,6 +65,7 @@ public:
public slots: public slots:
void openUrl(const QString &url); void openUrl(const QString &url);
void openPage(const QString &page); void openPage(const QString &page);
void triggerAction(const QString &actionId);
private: private:
WelcomeModePrivate *m_d; WelcomeModePrivate *m_d;