Commit 0d1969c0 authored by pixhawk's avatar pixhawk

Fixed all known issues in application persistence

parent b770e5b7
...@@ -230,6 +230,10 @@ void HUD::hideEvent(QHideEvent* event) ...@@ -230,6 +230,10 @@ void HUD::hideEvent(QHideEvent* event)
void HUD::contextMenuEvent (QContextMenuEvent* event) void HUD::contextMenuEvent (QContextMenuEvent* event)
{ {
QMenu menu(this); QMenu menu(this);
// Update actions
enableHUDAction->setChecked(hudInstrumentsEnabled);
enableVideoAction->setChecked(videoEnabled);
menu.addAction(enableHUDAction); menu.addAction(enableHUDAction);
//menu.addAction(selectHUDColorAction); //menu.addAction(selectHUDColorAction);
menu.addAction(enableVideoAction); menu.addAction(enableVideoAction);
......
...@@ -214,8 +214,8 @@ void MainWindow::setDefaultSettingsForAp() ...@@ -214,8 +214,8 @@ void MainWindow::setDefaultSettingsForAp()
// ENABLE UAS LIST // ENABLE UAS LIST
settings.setValue(buildMenuKey(SUB_SECTION_CHECKED,MainWindow::MENU_UAS_LIST,VIEW_OPERATOR), true); settings.setValue(buildMenuKey(SUB_SECTION_CHECKED,MainWindow::MENU_UAS_LIST,VIEW_OPERATOR), true);
// ENABLE COMMUNICATION CONSOLE // ENABLE HUD TOOL WIDGET
settings.setValue(buildMenuKey(SUB_SECTION_CHECKED,MainWindow::MENU_DEBUG_CONSOLE,VIEW_OPERATOR), true); settings.setValue(buildMenuKey(SUB_SECTION_CHECKED,MainWindow::MENU_HUD,VIEW_OPERATOR), true);
} }
// ENGINEER VIEW DEFAULT // ENGINEER VIEW DEFAULT
...@@ -516,7 +516,7 @@ void MainWindow::buildPxWidgets() ...@@ -516,7 +516,7 @@ void MainWindow::buildPxWidgets()
headUpDockWidget = new QDockWidget(tr("HUD"), this); headUpDockWidget = new QDockWidget(tr("HUD"), this);
headUpDockWidget->setWidget( new HUD(320, 240, this)); headUpDockWidget->setWidget( new HUD(320, 240, this));
headUpDockWidget->setObjectName("HEAD_UP_DISPLAY_DOCK_WIDGET"); headUpDockWidget->setObjectName("HEAD_UP_DISPLAY_DOCK_WIDGET");
addToToolsMenu (headUpDockWidget, tr("Control Indicator"), SLOT(showToolWidget(bool)), MENU_HUD, Qt::LeftDockWidgetArea); addToToolsMenu (headUpDockWidget, tr("Head Up Display"), SLOT(showToolWidget(bool)), MENU_HUD, Qt::RightDockWidgetArea);
} }
if (!video1DockWidget) if (!video1DockWidget)
...@@ -766,7 +766,7 @@ void MainWindow::addToToolsMenu ( QWidget* widget, ...@@ -766,7 +766,7 @@ void MainWindow::addToToolsMenu ( QWidget* widget,
connect(tempAction,SIGNAL(toggled(bool)),this, slotName); connect(tempAction,SIGNAL(toggled(bool)),this, slotName);
connect(qobject_cast <QDockWidget *>(dockWidgets[tool]), connect(qobject_cast <QDockWidget *>(dockWidgets[tool]),
SIGNAL(visibilityChanged(bool)), tempAction, SLOT(setChecked(bool))); SIGNAL(visibilityChanged(bool)), this, SLOT(showToolWidget(bool)));
// connect(qobject_cast <QDockWidget *>(dockWidgets[tool]), // connect(qobject_cast <QDockWidget *>(dockWidgets[tool]),
// SIGNAL(visibilityChanged(bool)), this, SLOT(updateVisibilitySettings(bool))); // SIGNAL(visibilityChanged(bool)), this, SLOT(updateVisibilitySettings(bool)));
...@@ -780,23 +780,60 @@ void MainWindow::showToolWidget(bool visible) ...@@ -780,23 +780,60 @@ void MainWindow::showToolWidget(bool visible)
if (!aboutToCloseFlag && !changingViewsFlag) if (!aboutToCloseFlag && !changingViewsFlag)
{ {
QAction* action = qobject_cast<QAction *>(sender()); QAction* action = qobject_cast<QAction *>(sender());
// Prevent this to fire if undocked
if (action)
{
int tool = action->data().toInt(); int tool = action->data().toInt();
QDockWidget* dockWidget = qobject_cast<QDockWidget *> (dockWidgets[tool]); QDockWidget* dockWidget = qobject_cast<QDockWidget *> (dockWidgets[tool]);
if (action && dockWidget) qDebug() << "DATA:" << tool << "FLOATING" << dockWidget->isFloating() << "checked" << action->isChecked() << "visible" << dockWidget->isVisible() << "action vis:" << action->isVisible();
if (dockWidget && dockWidget->isVisible() != visible)
{ {
if (visible) if (visible)
{ {
qDebug() << "DOCK WIDGET ADDED";
addDockWidget(dockWidgetLocations[tool], dockWidget); addDockWidget(dockWidgetLocations[tool], dockWidget);
dockWidget->show(); dockWidget->show();
} }
else
if (!visible && dockWidget->isVisible())
{ {
qDebug() << "DOCK WIDGET REMOVED";
removeDockWidget(dockWidget); removeDockWidget(dockWidget);
//dockWidget->hide();
}
QHashIterator<int, QWidget*> i(dockWidgets);
while (i.hasNext())
{
i.next();
if ((static_cast <QDockWidget *>(dockWidgets[i.key()])) == dockWidget)
{
QString chKey = buildMenuKey (SUB_SECTION_CHECKED,static_cast<TOOLS_WIDGET_NAMES>(i.key()), currentView);
settings.setValue(chKey,visible);
qDebug() << "showToolWidget(): Set key" << chKey << "to" << visible;
break;
}
} }
}
}
QDockWidget* dockWidget = qobject_cast<QDockWidget*>(QObject::sender());
qDebug() << "Trying to cast dockwidget" << dockWidget << "isvisible" << visible;
if (dockWidget)
{
// Get action
int tool = dockWidgets.key(dockWidget);
qDebug() << "Updating widget setting" << tool << "to" << visible;
QAction* action = toolsMenuActions[tool];
action->blockSignals(true);
action->setChecked(visible);
action->blockSignals(false);
QHashIterator<int, QWidget*> i(dockWidgets); QHashIterator<int, QWidget*> i(dockWidgets);
while (i.hasNext()) while (i.hasNext())
...@@ -1778,19 +1815,20 @@ void MainWindow::presentView() ...@@ -1778,19 +1815,20 @@ void MainWindow::presentView()
this->show(); this->show();
// Restore window state // Restore window state
// if (UASManager::instance()->getUASList().count() > 0) if (UASManager::instance()->getUASList().count() > 0)
// { {
// // Restore the widget positions and size // Restore the mainwindow size
// if (settings.contains(getWindowStateKey()))
// {
// restoreState(settings.value(getWindowStateKey()).toByteArray(), QGC::applicationVersion());
// }
if (settings.contains(getWindowGeometryKey())) if (settings.contains(getWindowGeometryKey()))
{ {
restoreGeometry(settings.value(getWindowGeometryKey()).toByteArray()); restoreGeometry(settings.value(getWindowGeometryKey()).toByteArray());
} }
// }
// Restore the widget positions and size
if (settings.contains(getWindowStateKey()))
{
restoreState(settings.value(getWindowStateKey()).toByteArray(), QGC::applicationVersion());
}
}
} }
void MainWindow::showTheCentralWidget (TOOLS_WIDGET_NAMES centralWidget, VIEW_SECTIONS view) void MainWindow::showTheCentralWidget (TOOLS_WIDGET_NAMES centralWidget, VIEW_SECTIONS view)
......
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