Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / ground / gcs / src / plugins / setupwizard / setupwizardplugin.cpp
blob48050fa80475eaee2c823ec682bcf9d7ae7cd314
1 /**
2 ******************************************************************************
4 * @file setupwizardplugin.cpp
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
6 * @addtogroup GCSPlugins GCS Plugins
7 * @{
8 * @addtogroup SetupWizardPlugin
9 * @{
10 * @brief A Setup Wizard Plugin
11 *****************************************************************************/
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * for more details.
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include "setupwizardplugin.h"
29 #include <QDebug>
30 #include <QtPlugin>
31 #include <QStringList>
32 #include <configgadgetfactory.h>
33 #include <extensionsystem/pluginmanager.h>
35 #include <coreplugin/coreconstants.h>
36 #include <coreplugin/actionmanager/actionmanager.h>
37 #include <coreplugin/icore.h>
38 #include <QKeySequence>
39 #include <coreplugin/modemanager.h>
40 #include "vehicletemplateexportdialog.h"
42 SetupWizardPlugin::SetupWizardPlugin() : wizardRunning(false)
45 SetupWizardPlugin::~SetupWizardPlugin()
48 bool SetupWizardPlugin::initialize(const QStringList & args, QString *errMsg)
50 Q_UNUSED(args);
51 Q_UNUSED(errMsg);
53 // Add Menu entry
54 Core::ActionManager *am = Core::ICore::instance()->actionManager();
55 Core::ActionContainer *ac = am->actionContainer(Core::Constants::M_TOOLS);
57 Core::Command *cmd = am->registerAction(new QAction(this),
58 "SetupWizardPlugin.ShowSetupWizard",
59 QList<int>() <<
60 Core::Constants::C_GLOBAL_ID);
61 cmd->action()->setText(tr("Vehicle Setup Wizard..."));
62 connect(cmd->action(), SIGNAL(triggered(bool)), this, SLOT(showSetupWizard()));
64 Core::ModeManager::instance()->addAction(cmd, 1);
65 ac->menu()->addSeparator();
66 ac->appendGroup("Wizard");
67 ac->addAction(cmd, "Wizard");
69 cmd = am->registerAction(new QAction(this),
70 "SetupWizardPlugin.ExportJSon",
71 QList<int>() <<
72 Core::Constants::C_GLOBAL_ID);
73 cmd->action()->setText(tr("Export/Import Vehicle Template..."));
74 connect(cmd->action(), SIGNAL(triggered(bool)), this, SLOT(exportSettings()));
76 Core::ModeManager::instance()->addAction(cmd, 1);
77 ac->menu()->addSeparator();
78 ac->appendGroup("Wizard");
79 ac->addAction(cmd, "Wizard");
81 ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
82 ConfigGadgetFactory *configGadgetFactory = pm->getObject<ConfigGadgetFactory>();
83 connect(configGadgetFactory, SIGNAL(onOpenVehicleConfigurationWizard()), this, SLOT(showSetupWizard()));
85 return true;
88 void SetupWizardPlugin::extensionsInitialized()
91 void SetupWizardPlugin::shutdown()
94 void SetupWizardPlugin::showSetupWizard()
96 if (!wizardRunning) {
97 wizardRunning = true;
98 SetupWizard *m_wiz = new SetupWizard();
99 connect(m_wiz, SIGNAL(finished(int)), this, SLOT(wizardTerminated()));
100 m_wiz->setAttribute(Qt::WA_DeleteOnClose, true);
101 m_wiz->setWindowFlags(m_wiz->windowFlags() | Qt::WindowStaysOnTopHint);
102 m_wiz->show();
106 void SetupWizardPlugin::exportSettings()
108 VehicleTemplateExportDialog dialog;
110 dialog.exec();
113 void SetupWizardPlugin::wizardTerminated()
115 wizardRunning = false;
116 disconnect(this, SLOT(wizardTerminated()));