Remove widgets from the layout as a FormGroup as well

and fix the focus order pointers.

Resolves #257 and potentially more.
This commit is contained in:
Raphael Coeffic
2021-06-19 12:07:55 +02:00
parent 952bc12b04
commit 0d5504686e
3 changed files with 14 additions and 9 deletions
-2
View File
@@ -123,8 +123,6 @@ void loadCustomScreens()
}
auto topbar = viewMain->getTopbar();
// TODO: how to reload this guy?
topbar->load();
viewMain->setCurrentMainView(0);
@@ -43,10 +43,12 @@ class WidgetsContainerImpl: public WidgetsContainer
// remove old one if existing
removeWidget(index);
Widget * widget = nullptr;
Widget* widget = nullptr;
if (factory) {
strncpy(persistentData->zones[index].widgetName, factory->getName(), sizeof(ZonePersistentData::widgetName));
widget = factory->create(this, getZone(index), &persistentData->zones[index].widgetData);
strncpy(persistentData->zones[index].widgetName, factory->getName(),
sizeof(ZonePersistentData::widgetName));
widget = factory->create(this, getZone(index),
&persistentData->zones[index].widgetData);
}
widgets[index] = widget;
@@ -61,12 +63,16 @@ class WidgetsContainerImpl: public WidgetsContainer
if (index >= N)
return;
if (widgets[index])
if (widgets[index]) {
removeField(widgets[index]);
widgets[index]->deleteLater();
}
widgets[index] = nullptr;
memset(persistentData->zones[index].widgetName, 0, sizeof(ZonePersistentData::widgetName));
memset(&persistentData->zones[index].widgetData, 0, sizeof(Widget::PersistentData));
memset(persistentData->zones[index].widgetName, 0,
sizeof(ZonePersistentData::widgetName));
memset(&persistentData->zones[index].widgetData, 0,
sizeof(Widget::PersistentData));
}
Widget * getWidget(unsigned int index) override
@@ -89,6 +95,7 @@ class WidgetsContainerImpl: public WidgetsContainer
// remove old widget
if (widgets[i]) {
removeField(widgets[i]);
widgets[i]->deleteLater();
widgets[i] = nullptr;
}