From 86f210e7f49a75a76af20efcf8d85a196cabacde Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Fri, 3 Aug 2012 18:31:47 +0200 Subject: [PATCH] OP-39 Added code to jump from the SetupWizard directly to the InputWizard in the ConfigurationPlugin to complete the vehicle setup and realize the 1-2-Fly idea. Re-factored some code in the ConfigurationPlugin. Fixed a bug in the Levelling page when performing levelling multiple times. --- .../src/libs/utils/mytabbedstackwidget.h | 1 + .../src/plugins/config/configgadgetfactory.cpp | 11 ++++++++--- .../src/plugins/config/configgadgetfactory.h | 9 ++++++++- .../src/plugins/config/configgadgetwidget.cpp | 8 ++++++++ .../src/plugins/config/configgadgetwidget.h | 1 + .../src/plugins/config/configinputwidget.cpp | 1 + .../src/plugins/config/configinputwidget.h | 6 +++--- .../src/plugins/config/configplugin.cpp | 2 +- .../src/plugins/setupwizard/pages/endpage.cpp | 18 +++++++++++++++++- .../src/plugins/setupwizard/pages/endpage.h | 3 +++ .../setupwizard/pages/levellingpage.cpp | 18 ++++++++++-------- .../plugins/setupwizard/pages/levellingpage.h | 2 +- .../src/plugins/setupwizard/setupwizard.cpp | 2 +- .../src/plugins/setupwizard/setupwizard.pro | 3 ++- 14 files changed, 65 insertions(+), 20 deletions(-) diff --git a/ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.h b/ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.h index f32524ce5..5faad8222 100644 --- a/ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.h +++ b/ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.h @@ -52,6 +52,7 @@ public: void insertCornerWidget(int index, QWidget *widget); int cornerWidgetCount() { return m_cornerWidgetCount; } QWidget * currentWidget(){return m_stackWidget->currentWidget();} + QWidget * getWidget(int index) {return m_stackWidget->widget(index);} signals: void currentAboutToShow(int index,bool * proceed); diff --git a/ground/openpilotgcs/src/plugins/config/configgadgetfactory.cpp b/ground/openpilotgcs/src/plugins/config/configgadgetfactory.cpp index 37447b01a..b468adf02 100644 --- a/ground/openpilotgcs/src/plugins/config/configgadgetfactory.cpp +++ b/ground/openpilotgcs/src/plugins/config/configgadgetfactory.cpp @@ -25,14 +25,14 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "configgadgetfactory.h" -#include "configgadgetwidget.h" #include "configgadget.h" #include "configgadgetconfiguration.h" #include "configgadgetoptionspage.h" #include ConfigGadgetFactory::ConfigGadgetFactory(QObject *parent) : - IUAVGadgetFactory(QString("ConfigGadget"), tr("Config Gadget"), parent) + IUAVGadgetFactory(QString("ConfigGadget"), tr("Config Gadget"), parent), + gadgetWidget(0) { } @@ -42,7 +42,7 @@ ConfigGadgetFactory::~ConfigGadgetFactory() Core::IUAVGadget* ConfigGadgetFactory::createGadget(QWidget *parent) { - ConfigGadgetWidget* gadgetWidget = new ConfigGadgetWidget(parent); + gadgetWidget = new ConfigGadgetWidget(parent); return new ConfigGadget(QString("ConfigGadget"), gadgetWidget, parent); } @@ -55,3 +55,8 @@ IOptionsPage *ConfigGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *co { return new ConfigGadgetOptionsPage(qobject_cast(config)); } + +void ConfigGadgetFactory::startInputWizard() +{ + gadgetWidget->startInputWizard(); +} diff --git a/ground/openpilotgcs/src/plugins/config/configgadgetfactory.h b/ground/openpilotgcs/src/plugins/config/configgadgetfactory.h index 8d371e746..77963a842 100644 --- a/ground/openpilotgcs/src/plugins/config/configgadgetfactory.h +++ b/ground/openpilotgcs/src/plugins/config/configgadgetfactory.h @@ -28,6 +28,9 @@ #define CONFIGGADGETFACTORY_H #include +#include "configgadgetwidget.h" +#include "config_global.h" + namespace Core { class IUAVGadget; @@ -36,7 +39,7 @@ class IUAVGadgetFactory; using namespace Core; -class ConfigGadgetFactory: public Core::IUAVGadgetFactory +class CONFIG_EXPORT ConfigGadgetFactory: public Core::IUAVGadgetFactory { Q_OBJECT public: @@ -47,6 +50,10 @@ public: IUAVGadget *createGadget(QWidget *parent); IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings); IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config); + void startInputWizard(); + +private: + ConfigGadgetWidget* gadgetWidget; }; #endif // CONFIGGADGETFACTORY_H diff --git a/ground/openpilotgcs/src/plugins/config/configgadgetwidget.cpp b/ground/openpilotgcs/src/plugins/config/configgadgetwidget.cpp index c12dbaee8..df49eb5db 100644 --- a/ground/openpilotgcs/src/plugins/config/configgadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configgadgetwidget.cpp @@ -127,6 +127,14 @@ ConfigGadgetWidget::~ConfigGadgetWidget() // TODO: properly delete all the tabs in ftw before exiting } +void ConfigGadgetWidget::startInputWizard() +{ + ftw->setCurrentIndex(ConfigGadgetWidget::input); + ConfigInputWidget* inputWidget = dynamic_cast(ftw->getWidget(ConfigGadgetWidget::input)); + Q_ASSERT(inputWidget); + inputWidget->startInputWizard(); +} + void ConfigGadgetWidget::resizeEvent(QResizeEvent *event) { diff --git a/ground/openpilotgcs/src/plugins/config/configgadgetwidget.h b/ground/openpilotgcs/src/plugins/config/configgadgetwidget.h index 5e9dc6e67..0b2331329 100644 --- a/ground/openpilotgcs/src/plugins/config/configgadgetwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configgadgetwidget.h @@ -51,6 +51,7 @@ public: ConfigGadgetWidget(QWidget *parent = 0); ~ConfigGadgetWidget(); enum widgetTabs {hardware=0, aircraft, input, output, sensors, stabilization, camerastabilization, txpid, pipxtreme}; + void startInputWizard(); public slots: void onAutopilotConnect(); diff --git a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp index 7952b3d70..27d830b01 100644 --- a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp @@ -280,6 +280,7 @@ void ConfigInputWidget::openHelp() QDesktopServices::openUrl( QUrl("http://wiki.openpilot.org/display/Doc/Input+Configuration", QUrl::StrictMode) ); } + void ConfigInputWidget::goToWizard() { QMessageBox msgBox; diff --git a/ground/openpilotgcs/src/plugins/config/configinputwidget.h b/ground/openpilotgcs/src/plugins/config/configinputwidget.h index 418fbdfee..25f029e63 100644 --- a/ground/openpilotgcs/src/plugins/config/configinputwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configinputwidget.h @@ -57,7 +57,7 @@ public: enum txMovements{moveLeftVerticalStick,moveRightVerticalStick,moveLeftHorizontalStick,moveRightHorizontalStick,moveAccess0,moveAccess1,moveAccess2,moveFlightMode,centerAll,moveAll,nothing}; enum txMovementType{vertical,horizontal,jump,mix}; enum txType {acro, heli}; -public slots: + void startInputWizard() { goToWizard(); } private: bool growing; @@ -133,6 +133,7 @@ private: void wizardSetUpStep(enum wizardSteps); void wizardTearDownStep(enum wizardSteps); + private slots: void wzNext(); void wzBack(); @@ -150,11 +151,10 @@ private slots: void invertControls(); void simpleCalibration(bool state); void updateCalibration(); + protected: void resizeEvent(QResizeEvent *event); virtual void enableControls(bool enable); - - }; #endif diff --git a/ground/openpilotgcs/src/plugins/config/configplugin.cpp b/ground/openpilotgcs/src/plugins/config/configplugin.cpp index 30418094c..fd3a30544 100644 --- a/ground/openpilotgcs/src/plugins/config/configplugin.cpp +++ b/ground/openpilotgcs/src/plugins/config/configplugin.cpp @@ -99,7 +99,7 @@ void ConfigPlugin::extensionsInitialized() void ConfigPlugin::shutdown() { - // Do nothing + // Do nothing } /** diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.cpp index dda55196e..2df3f9e79 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.cpp @@ -26,16 +26,32 @@ */ #include "endpage.h" #include "ui_endpage.h" +#include +#include +#include EndPage::EndPage(SetupWizard *wizard, QWidget *parent) : AbstractWizardPage(wizard, parent), ui(new Ui::EndPage) { - setFinalPage(true); ui->setupUi(this); + setFinalPage(true); + connect(ui->inputWizardButton, SIGNAL(clicked()), this, SLOT(openInputWizard())); } EndPage::~EndPage() { delete ui; } + +void EndPage::openInputWizard() +{ + Core::ModeManager::instance()->activateModeByWorkspaceName("Configuration"); + + getWizard()->close(); + + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + ConfigGadgetFactory* configGadgetFactory = pm->getObject(); + Q_ASSERT(configGadgetFactory); + configGadgetFactory->startInputWizard(); +} diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.h b/ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.h index afbeb6177..dfbad7942 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.h +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.h @@ -42,6 +42,9 @@ public: explicit EndPage(SetupWizard *wizard, QWidget *parent = 0); ~EndPage(); +private slots: + void openInputWizard(); + private: Ui::EndPage *ui; }; diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/levellingpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/levellingpage.cpp index 8128a3717..cabde07b7 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/levellingpage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/levellingpage.cpp @@ -51,16 +51,18 @@ bool LevellingPage::validatePage() return true; } -bool LevellingPage::isComplete() +bool LevellingPage::isComplete() const { - return getWizard()->isLevellingPerformed(); + return const_cast(this)->getWizard()->isLevellingPerformed() && + ui->levelButton->isEnabled(); } void LevellingPage::performLevelling() { if(!getWizard()->getConnectionManager()->isConnected()) { QMessageBox msgBox; - msgBox.setText(tr("An OpenPilot controller must be connected to your computer to perform bias calculations.\nPlease connect your OpenPilot controller to continue.")); + msgBox.setText(tr("An OpenPilot controller must be connected to your computer to perform bias " + "calculations.\nPlease connect your OpenPilot controller to continue.")); msgBox.setStandardButtons(QMessageBox::Ok); msgBox.setDefaultButton(QMessageBox::Ok); msgBox.exec(); @@ -69,14 +71,14 @@ void LevellingPage::performLevelling() if(!m_levellingUtil) { - ui->levelButton->setEnabled(false); - // Measure every 100ms * 100times = 10s m_levellingUtil = new LevellingUtil(BIAS_CYCLES, BIAS_PERIOD); - connect(m_levellingUtil, SIGNAL(progress(long,long)), this, SLOT(levellingProgress(long,long))); - connect(m_levellingUtil, SIGNAL(done(accelGyroBias)), this, SLOT(levellingDone(accelGyroBias))); - connect(m_levellingUtil, SIGNAL(timeout(QString)), this, SLOT(levellingTimeout(QString))); } + connect(m_levellingUtil, SIGNAL(progress(long,long)), this, SLOT(levellingProgress(long,long))); + connect(m_levellingUtil, SIGNAL(done(accelGyroBias)), this, SLOT(levellingDone(accelGyroBias))); + connect(m_levellingUtil, SIGNAL(timeout(QString)), this, SLOT(levellingTimeout(QString))); + ui->levelButton->setEnabled(false); + emit completeChanged(); m_levellingUtil->start(); } diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/levellingpage.h b/ground/openpilotgcs/src/plugins/setupwizard/pages/levellingpage.h index 870ae5e6f..b5f555ecc 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/levellingpage.h +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/levellingpage.h @@ -43,7 +43,7 @@ public: explicit LevellingPage(SetupWizard *wizard, QWidget *parent = 0); ~LevellingPage(); bool validatePage(); - bool isComplete(); + bool isComplete() const; private slots: void performLevelling(); diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp index 2b32d7a31..f68c942ef 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp @@ -172,7 +172,7 @@ QString SetupWizard::getSummaryText() summary.append('\n'); summary.append(tr("ESC type: ")); - switch (getInputType()) + switch (getESCType()) { case ESC_DEFAULT: summary.append(tr("Default ESC (50 Hz)")); diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro index ff858f29d..d3a6dc0da 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro @@ -6,7 +6,8 @@ QT += svg include(../../openpilotgcsplugin.pri) include(../../plugins/coreplugin/coreplugin.pri) include(../../plugins/uavobjectutil/uavobjectutil.pri) - +include(../../plugins/config/config.pri) + HEADERS += setupwizardplugin.h \ setupwizard.h \ pages/startpage.h \