30 #include <QMainWindow>
31 #include <QStringList>
35 #include "objectpersistence.h"
37 ConfigPlugin::ConfigPlugin()
42 ConfigPlugin::~ConfigPlugin()
47 bool ConfigPlugin::initialize(
const QStringList &args, QString *errMsg)
62 cmd = am->
registerAction(
new QAction(
this),
"ConfigPlugin.EraseAll",
64 cmd->
action()->setText(tr(
"Erase all settings from board..."));
66 ac->
menu()->addSeparator();
70 connect(cmd->
action(), &QAction::triggered,
this, &ConfigPlugin::eraseAllSettings);
79 cmd->
action()->setEnabled(
false);
97 void ConfigPlugin::extensionsInitialized() {}
99 void ConfigPlugin::shutdown()
107 void ConfigPlugin::onAutopilotConnect()
110 cmd->
action()->setEnabled(
true);
112 auto pm = ExtensionSystem::PluginManager::instance();
115 if (uavoUtilManager->firmwareHashMatchesGcs()) {
118 if (!uavoUtilManager->boardConfigured())
131 void ConfigPlugin::onAutopilotDisconnect()
133 cmd->
action()->setEnabled(
false);
139 void ConfigPlugin::eraseAllSettings()
142 msgBox.setText(tr(
"Are you sure you want to erase all board settings?."));
143 msgBox.setInformativeText(tr(
"All settings stored in your board flash will be deleted."));
144 msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
145 msgBox.setDefaultButton(QMessageBox::Ok);
146 if (msgBox.exec() != QMessageBox::Ok)
149 settingsErased =
false;
153 msgBox.setText(tr(
"Settings will now erase."));
154 msgBox.setInformativeText(tr(
"Press <OK> and then please wait until a completion box appears. "
155 "This can take up to %1 seconds.")
156 .arg(FLASH_ERASE_TIMEOUT_MS / 1000));
157 msgBox.setStandardButtons(QMessageBox::Ok);
160 ObjectPersistence *objper = ObjectPersistence::GetInstance(getObjectManager());
165 ObjectPersistence::DataFields
data = objper->getData();
166 data.Operation = ObjectPersistence::OPERATION_FULLERASE;
170 objper->setData(data);
172 QTimer::singleShot(FLASH_ERASE_TIMEOUT_MS,
this, &ConfigPlugin::eraseFailed);
175 void ConfigPlugin::eraseFailed()
180 ObjectPersistence *objper = ObjectPersistence::GetInstance(getObjectManager());
184 (
void)QMessageBox::critical(
186 tr(
"Error erasing settings"),
187 tr(
"Power-cycle your board after removing all blades. Settings might be inconsistent."),
191 void ConfigPlugin::eraseDone(
UAVObject *obj)
194 QMessageBox msgBox(dynamic_cast<QWidget *>(Core::ICore::instance()->mainWindow()));
195 ObjectPersistence *objper = ObjectPersistence::GetInstance(getObjectManager());
196 ObjectPersistence::DataFields data = objper->
getData();
197 Q_ASSERT(obj->getInstID() == objper->getInstID());
199 if (data.Operation != ObjectPersistence::OPERATION_COMPLETED) {
204 if (data.Operation == ObjectPersistence::OPERATION_COMPLETED) {
205 settingsErased =
true;
206 msgBox.setText(tr(
"Settings are now erased."));
207 msgBox.setInformativeText(tr(
"Please ensure that the status LED is flashing regularly and "
208 "then power-cycle your board."));
210 msgBox.setText(tr(
"Error trying to erase settings."));
211 msgBox.setInformativeText(tr(
212 "Power-cycle your board after removing all blades. Settings might be inconsistent."));
214 msgBox.setStandardButtons(QMessageBox::Ok);
215 msgBox.setDefaultButton(QMessageBox::Ok);
void addObject(QObject *obj)
virtual QAction * action() const =0
virtual Command * registerAction(QAction *action, const QString &id, const QList< int > &context)=0
Makes an action known to the system under the specified string id.
const char *const M_TOOLS
The Calibration class is a UI free algorithm that can be connected to any interfaces. As such it only communicates with the UI via signals and slots, but has no direct handles to any particular controls or widgets.
virtual ActionContainer * actionContainer(const QString &id) const =0
Returns the IActionContainter object that is know to the system under the given string id...
Core plugin system that manages the plugins, their life cycle and their registered objects...
virtual ActionManager * actionManager() const =0
Returns the application's action manager.
void objectUpdated(UAVObject *obj)
Signal sent whenever any field of the object is updated.
virtual QMenu * menu() const =0
static ICore * instance()
virtual void appendGroup(const QString &group)=0
virtual void addAction(Core::Command *action, const QString &group=QString())=0
void removeObject(QObject *obj)
The action manager is responsible for registration of menus and menu items and keyboard shortcuts...
Gui-less support class for calibration.
void addAutoReleasedObject(QObject *obj)