Commit e10ca000 authored by lm's avatar lm

Re-enabled custom widget loading

parent 6bbd1bb1
...@@ -1766,10 +1766,13 @@ void UAS::setSystemType(int systemType) ...@@ -1766,10 +1766,13 @@ void UAS::setSystemType(int systemType)
void UAS::setUASName(const QString& name) void UAS::setUASName(const QString& name)
{ {
this->name = name; if (name != "")
writeSettings(); {
emit nameChanged(name); this->name = name;
emit systemSpecsChanged(uasId); writeSettings();
emit nameChanged(name);
emit systemSpecsChanged(uasId);
}
} }
void UAS::executeCommand(MAV_CMD command) void UAS::executeCommand(MAV_CMD command)
......
...@@ -146,6 +146,8 @@ MainWindow::MainWindow(QWidget *parent): ...@@ -146,6 +146,8 @@ MainWindow::MainWindow(QWidget *parent):
// Create actions // Create actions
connectCommonActions(); connectCommonActions();
buildCustomWidget();
// Restore the window setup // Restore the window setup
...@@ -268,40 +270,36 @@ QString MainWindow::getWindowGeometryKey() ...@@ -268,40 +270,36 @@ QString MainWindow::getWindowGeometryKey()
void MainWindow::buildCustomWidget() void MainWindow::buildCustomWidget()
{ {
// Show custom widgets only if UAS is connected // Create custom widgets
if (UASManager::instance()->getActiveUAS() != NULL) QList<QGCToolWidget*> widgets = QGCToolWidget::createWidgetsFromSettings(this);
{
// Create custom widgets
QList<QGCToolWidget*> widgets = QGCToolWidget::createWidgetsFromSettings(this);
if (widgets.size() > 0) if (widgets.size() > 0)
{ {
ui.menuTools->addSeparator(); ui.menuTools->addSeparator();
} }
for(int i = 0; i < widgets.size(); ++i) for(int i = 0; i < widgets.size(); ++i)
{
// Check if this widget already has a parent, do not create it in this case
QGCToolWidget* tool = widgets.at(i);
QDockWidget* dock = dynamic_cast<QDockWidget*>(tool->parentWidget());
if (!dock)
{ {
// Check if this widget already has a parent, do not create it in this case QDockWidget* dock = new QDockWidget(tool->windowTitle(), this);
QGCToolWidget* tool = widgets.at(i); dock->setObjectName(tool->objectName()+"_DOCK");
QDockWidget* dock = dynamic_cast<QDockWidget*>(tool->parentWidget()); dock->setWidget(tool);
if (!dock) connect(tool, SIGNAL(destroyed()), dock, SLOT(deleteLater()));
{ QAction* showAction = new QAction(widgets.at(i)->windowTitle(), this);
QDockWidget* dock = new QDockWidget(tool->windowTitle(), this); showAction->setCheckable(true);
dock->setObjectName(tool->objectName()+"_DOCK"); connect(showAction, SIGNAL(triggered(bool)), dock, SLOT(setVisible(bool)));
dock->setWidget(tool); connect(dock, SIGNAL(visibilityChanged(bool)), showAction, SLOT(setChecked(bool)));
connect(tool, SIGNAL(destroyed()), dock, SLOT(deleteLater())); widgets.at(i)->setMainMenuAction(showAction);
QAction* showAction = new QAction(widgets.at(i)->windowTitle(), this); ui.menuTools->addAction(showAction);
showAction->setCheckable(true);
connect(showAction, SIGNAL(triggered(bool)), dock, SLOT(setVisible(bool))); // Load dock widget location (default is bottom)
connect(dock, SIGNAL(visibilityChanged(bool)), showAction, SLOT(setChecked(bool))); Qt::DockWidgetArea location = static_cast <Qt::DockWidgetArea>(tool->getDockWidgetArea(currentView));
widgets.at(i)->setMainMenuAction(showAction);
ui.menuTools->addAction(showAction); addDockWidget(location, dock);
// Load dock widget location (default is bottom)
Qt::DockWidgetArea location = static_cast <Qt::DockWidgetArea>(tool->getDockWidgetArea(currentView));
addDockWidget(location, dock);
}
} }
} }
} }
...@@ -1251,11 +1249,11 @@ void MainWindow::UASCreated(UASInterface* uas) ...@@ -1251,11 +1249,11 @@ void MainWindow::UASCreated(UASInterface* uas)
if (!ui.menuConnected_Systems->isEnabled()) ui.menuConnected_Systems->setEnabled(true); if (!ui.menuConnected_Systems->isEnabled()) ui.menuConnected_Systems->setEnabled(true);
// Restore the mainwindow size // // Restore the mainwindow size
if (settings.contains(getWindowGeometryKey())) // if (settings.contains(getWindowGeometryKey()))
{ // {
restoreGeometry(settings.value(getWindowGeometryKey()).toByteArray()); // restoreGeometry(settings.value(getWindowGeometryKey()).toByteArray());
} // }
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment