Commit ac698650 authored by Michael Carpenter's avatar Michael Carpenter

Change so MainWindow handles its own deletion, and deletion of other UI...

Change so MainWindow handles its own deletion, and deletion of other UI objects to allow for closing when the MainWindow is closed, regardless of if other windows are open.
parent 5f536d0d
...@@ -203,7 +203,7 @@ QGCCore::QGCCore(int &argc, char* argv[]) : QApplication(argc, argv) ...@@ -203,7 +203,7 @@ QGCCore::QGCCore(int &argc, char* argv[]) : QApplication(argc, argv)
QGCCore::~QGCCore() QGCCore::~QGCCore()
{ {
//mainWindow->storeSettings(); //mainWindow->storeSettings();
mainWindow->close(); //mainWindow->close();
//mainWindow->deleteLater(); //mainWindow->deleteLater();
// Delete singletons // Delete singletons
// First systems // First systems
...@@ -211,7 +211,8 @@ QGCCore::~QGCCore() ...@@ -211,7 +211,8 @@ QGCCore::~QGCCore()
// then links // then links
delete LinkManager::instance(); delete LinkManager::instance();
// Finally the main window // Finally the main window
delete MainWindow::instance(); //delete MainWindow::instance();
//The main window now autodeletes on close.
} }
/** /**
......
...@@ -106,6 +106,7 @@ MainWindow::MainWindow(QWidget *parent): ...@@ -106,6 +106,7 @@ MainWindow::MainWindow(QWidget *parent):
autoReconnect(false), autoReconnect(false),
lowPowerMode(false) lowPowerMode(false)
{ {
this->setAttribute(Qt::WA_DeleteOnClose);
hide(); hide();
dockWidgetTitleBarEnabled = true; dockWidgetTitleBarEnabled = true;
isAdvancedMode = false; isAdvancedMode = false;
...@@ -323,6 +324,16 @@ MainWindow::~MainWindow() ...@@ -323,6 +324,16 @@ MainWindow::~MainWindow()
} }
} }
// Delete all UAS objects // Delete all UAS objects
if (debugConsole)
{
delete debugConsole;
}
for (int i=0;i<commsWidgetList.size();i++)
{
commsWidgetList[i]->deleteLater();
}
} }
void MainWindow::resizeEvent(QResizeEvent * event) void MainWindow::resizeEvent(QResizeEvent * event)
...@@ -523,10 +534,17 @@ void MainWindow::buildCommonWidgets() ...@@ -523,10 +534,17 @@ void MainWindow::buildCommonWidgets()
connect(tempAction,SIGNAL(triggered(bool)),this, SLOT(showTool(bool))); connect(tempAction,SIGNAL(triggered(bool)),this, SLOT(showTool(bool)));
} }
{ {
QAction* tempAction = ui.menuTools->addAction(tr("Communication Console")); if (!debugConsole)
menuToDockNameMap[tempAction] = "COMMUNICATION_DEBUG_CONSOLE_DOCKWIDGET"; {
tempAction->setCheckable(true); debugConsole = new DebugConsole();
connect(tempAction,SIGNAL(triggered(bool)),this, SLOT(showTool(bool))); debugConsole->setWindowTitle("Communications Console");
debugConsole->show();
QAction* tempAction = ui.menuTools->addAction(tr("Communication Console"));
//menuToDockNameMap[tempAction] = "COMMUNICATION_DEBUG_CONSOLE_DOCKWIDGET";
tempAction->setCheckable(true);
connect(tempAction,SIGNAL(triggered(bool)),debugConsole,SLOT(setShown(bool)));
}
} }
createDockWidget(simView,new HSIDisplay(this),tr("Horizontal Situation"),"HORIZONTAL_SITUATION_INDICATOR_DOCKWIDGET",VIEW_SIMULATION,Qt::BottomDockWidgetArea); createDockWidget(simView,new HSIDisplay(this),tr("Horizontal Situation"),"HORIZONTAL_SITUATION_INDICATOR_DOCKWIDGET",VIEW_SIMULATION,Qt::BottomDockWidgetArea);
...@@ -772,7 +790,9 @@ void MainWindow::loadDockWidget(QString name) ...@@ -772,7 +790,9 @@ void MainWindow::loadDockWidget(QString name)
} }
else if (name == "COMMUNICATION_DEBUG_CONSOLE_DOCKWIDGET") else if (name == "COMMUNICATION_DEBUG_CONSOLE_DOCKWIDGET")
{ {
createDockWidget(centerStack->currentWidget(),new DebugConsole(this),tr("Communication Console"),"COMMUNICATION_DEBUG_CONSOLE_DOCKWIDGET",currentView,Qt::BottomDockWidgetArea); //This is now a permanently detached window.
//centralWidgetToDockWidgetsMap[currentView][name] = console;
//createDockWidget(centerStack->currentWidget(),new DebugConsole(this),tr("Communication Console"),"COMMUNICATION_DEBUG_CONSOLE_DOCKWIDGET",currentView,Qt::BottomDockWidgetArea);
} }
else if (name == "HORIZONTAL_SITUATION_INDICATOR_DOCKWIDGET") else if (name == "HORIZONTAL_SITUATION_INDICATOR_DOCKWIDGET")
{ {
...@@ -1614,6 +1634,8 @@ void MainWindow::addLink(LinkInterface *link) ...@@ -1614,6 +1634,8 @@ void MainWindow::addLink(LinkInterface *link)
if (!found) if (!found)
{ // || udp { // || udp
CommConfigurationWindow* commWidget = new CommConfigurationWindow(link, mavlink, this); CommConfigurationWindow* commWidget = new CommConfigurationWindow(link, mavlink, this);
commsWidgetList.append(commWidget);
connect(commWidget,SIGNAL(destroyed(QObject*)),this,SLOT(commsWidgetDestroyed(QObject*)));
QAction* action = commWidget->getAction(); QAction* action = commWidget->getAction();
ui.menuNetwork->addAction(action); ui.menuNetwork->addAction(action);
...@@ -1627,6 +1649,13 @@ void MainWindow::addLink(LinkInterface *link) ...@@ -1627,6 +1649,13 @@ void MainWindow::addLink(LinkInterface *link)
} }
} }
} }
void MainWindow::commsWidgetDestroyed(QObject *obj)
{
if (commsWidgetList.contains(obj))
{
commsWidgetList.removeOne(obj);
}
}
void MainWindow::setActiveUAS(UASInterface* uas) void MainWindow::setActiveUAS(UASInterface* uas)
{ {
......
...@@ -250,6 +250,8 @@ public slots: ...@@ -250,6 +250,8 @@ public slots:
/** @brief Update the window name */ /** @brief Update the window name */
void configureWindowName(); void configureWindowName();
void commsWidgetDestroyed(QObject *obj);
signals: signals:
void initStatusChanged(const QString& message); void initStatusChanged(const QString& message);
#ifdef MOUSE_ENABLED_LINUX #ifdef MOUSE_ENABLED_LINUX
...@@ -397,6 +399,8 @@ protected: ...@@ -397,6 +399,8 @@ protected:
QPointer<QGCToolBar> toolBar; QPointer<QGCToolBar> toolBar;
QPointer<QGCStatusBar> customStatusBar; QPointer<QGCStatusBar> customStatusBar;
QPointer<DebugConsole> debugConsole;
QPointer<QDockWidget> mavlinkInspectorWidget; QPointer<QDockWidget> mavlinkInspectorWidget;
QPointer<MAVLinkDecoder> mavlinkDecoder; QPointer<MAVLinkDecoder> mavlinkDecoder;
QPointer<QDockWidget> mavlinkSenderWidget; QPointer<QDockWidget> mavlinkSenderWidget;
...@@ -441,6 +445,7 @@ protected: ...@@ -441,6 +445,7 @@ protected:
QTimer windowNameUpdateTimer; QTimer windowNameUpdateTimer;
private: private:
QList<QObject*> commsWidgetList;
QMap<QString,QString> customWidgetNameToFilenameMap; QMap<QString,QString> customWidgetNameToFilenameMap;
QMap<QAction*,QString > menuToDockNameMap; QMap<QAction*,QString > menuToDockNameMap;
QMap<QDockWidget*,QWidget*> dockToTitleBarMap; QMap<QDockWidget*,QWidget*> dockToTitleBarMap;
......
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