Commit b37fa76b authored by John Tapsell's avatar John Tapsell

Allow custom widget to be deleted

parent 37d8faf2
......@@ -753,6 +753,7 @@ void MainWindow::addTool(SubMainWindow *parent,VIEW_SECTIONS view,QDockWidget* w
centralWidgetToDockWidgetsMap[view][widget->objectName()]= widget;
connect(tempAction,SIGNAL(triggered(bool)),this, SLOT(showTool(bool)));
connect(widget, SIGNAL(visibilityChanged(bool)), tempAction, SLOT(setChecked(bool)));
connect(widget, SIGNAL(destroyed()), tempAction, SLOT(deleteLater()));
tempAction->setChecked(widget->isVisible());
}
else
......@@ -786,9 +787,20 @@ QDockWidget* MainWindow::createDockWidget(QWidget *parent,QWidget *child,QString
widget->setMinimumWidth(minwidth);
}
addTool(qobject_cast<SubMainWindow*>(parent),view,widget,title,area);
connect(child, SIGNAL(destroyed()), widget, SLOT(deleteLater()));
connect(widget, SIGNAL(destroyed()), this, SLOT(dockWidgetDestroyed()));
return widget;
}
void MainWindow::dockWidgetDestroyed()
{
QDockWidget *dock = dynamic_cast<QDockWidget *>(QObject::sender());
Q_ASSERT(dock);
if(!dock) return;
dockWidgets.removeAll(dock);
}
void MainWindow::loadDockWidget(QString name)
{
if (centralWidgetToDockWidgetsMap[currentView].contains(name))
......@@ -1039,8 +1051,6 @@ void MainWindow::createCustomWidget()
settings.setValue(QString("TOOL_PARENT_") + tool->objectName(),currentView);
settings.endGroup();
//connect(tool, SIGNAL(destroyed()), dock, SLOT(deleteLater()));
//dock->setWidget(tool);
......
......@@ -307,6 +307,10 @@ public slots:
void commsWidgetDestroyed(QObject *obj);
protected slots:
/** @brief Called by a dock widget when it is has been deleted */
void dockWidgetDestroyed();
signals:
void styleChanged(MainWindow::QGC_MAINWINDOW_STYLE newTheme);
void styleChanged();
......
......@@ -668,11 +668,12 @@ void QGCToolWidget::deleteWidget()
// Hide
this->hide();
instances()->remove(getTitle());
/*QSettings settings;
settings.beginGroup(getTitle());
settings.remove("");
QSettings settings;
settings.beginGroup("QGC_MAINWINDOW");
settings.remove(QString("TOOL_PARENT_") + objectName());
settings.endGroup();
storeWidgetsToSettings();*/
storeWidgetsToSettings();
// Delete
......
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