Commit b770e5b7 authored by pixhawk's avatar pixhawk

Working on final main window version

parent 2b1967c0
...@@ -17,14 +17,14 @@ ...@@ -17,14 +17,14 @@
#define WITH_TEXT_TO_SPEECH 1 #define WITH_TEXT_TO_SPEECH 1
#define QGC_APPLICATION_NAME "QGroundControl" #define QGC_APPLICATION_NAME "QGroundControl"
#define QGC_APPLICATION_VERSION "v. 0.8.1 (Alpha)" #define QGC_APPLICATION_VERSION "v. 0.8.3 (Alpha)"
namespace QGC namespace QGC
{ {
const QString APPNAME = "QGROUNDCONTROL"; const QString APPNAME = "QGROUNDCONTROL";
const QString COMPANYNAME = "OPENMAV"; const QString COMPANYNAME = "OPENMAV";
const int APPLICATIONVERSION = 80; // 0.8.0 const int APPLICATIONVERSION = 83; // 0.8.0
} }
#endif // CONFIGURATION_H #endif // CONFIGURATION_H
...@@ -152,7 +152,7 @@ HDDisplay::~HDDisplay() ...@@ -152,7 +152,7 @@ HDDisplay::~HDDisplay()
QSize HDDisplay::sizeHint() const QSize HDDisplay::sizeHint() const
{ {
return QSize(400, 400.0f*(vwidth/vheight)*1.1f); return QSize(400, 400.0f*(vwidth/vheight)*1.2f);
} }
void HDDisplay::enableGLRendering(bool enable) void HDDisplay::enableGLRendering(bool enable)
......
...@@ -64,7 +64,7 @@ MainWindow* MainWindow::instance() ...@@ -64,7 +64,7 @@ MainWindow* MainWindow::instance()
MainWindow::MainWindow(QWidget *parent): MainWindow::MainWindow(QWidget *parent):
QMainWindow(parent), QMainWindow(parent),
toolsMenuActions(), toolsMenuActions(),
currentView(VIEW_ENGINEER), currentView(VIEW_UNCONNECTED),
aboutToCloseFlag(false), aboutToCloseFlag(false),
changingViewsFlag(false) changingViewsFlag(false)
{ {
...@@ -82,47 +82,17 @@ MainWindow::MainWindow(QWidget *parent): ...@@ -82,47 +82,17 @@ MainWindow::MainWindow(QWidget *parent):
} }
else else
{ {
if (settings.value("CURRENT_VIEW", VIEW_PILOT) != VIEW_PILOT) // LOAD THE LAST VIEW
VIEW_SECTIONS currentViewCandidate = (VIEW_SECTIONS) settings.value("CURRENT_VIEW", currentView).toInt();
if (currentViewCandidate != VIEW_ENGINEER &&
currentViewCandidate != VIEW_OPERATOR &&
currentViewCandidate != VIEW_PILOT)
{ {
currentView = (VIEW_SECTIONS) settings.value("CURRENT_VIEW", currentView).toInt(); currentView = currentViewCandidate;
} }
} }
// Check if the settings exist, instantiate defaults if necessary setDefaultSettingsForAp();
// OPERATOR VIEW DEFAULT
QString centralKey = buildMenuKey(SUB_SECTION_CHECKED, CENTRAL_MAP, VIEW_OPERATOR);
if (!settings.contains(centralKey))
{
settings.setValue(centralKey,true);
}
// ENGINEER VIEW DEFAULT
centralKey = buildMenuKey(SUB_SECTION_CHECKED, CENTRAL_LINECHART, VIEW_ENGINEER);
if (!settings.contains(centralKey))
{
settings.setValue(centralKey,true);
}
// MAVLINK VIEW DEFAULT
centralKey = buildMenuKey(SUB_SECTION_CHECKED, CENTRAL_PROTOCOL, VIEW_MAVLINK);
if (!settings.contains(centralKey))
{
settings.setValue(centralKey,true);
}
// PILOT VIEW DEFAULT
centralKey = buildMenuKey(SUB_SECTION_CHECKED, CENTRAL_HUD, VIEW_PILOT);
if (!settings.contains(centralKey))
{
settings.setValue(centralKey,true);
}
QString listKey = buildMenuKey(SUB_SECTION_CHECKED, MENU_UAS_LIST, currentView);
if (!settings.contains(listKey))
{
settings.setValue(listKey, true);
}
settings.sync(); settings.sync();
...@@ -138,6 +108,7 @@ MainWindow::MainWindow(QWidget *parent): ...@@ -138,6 +108,7 @@ MainWindow::MainWindow(QWidget *parent):
perspectives->addAction(ui.actionMavlinkView); perspectives->addAction(ui.actionMavlinkView);
perspectives->addAction(ui.actionPilotsView); perspectives->addAction(ui.actionPilotsView);
perspectives->addAction(ui.actionOperatorsView); perspectives->addAction(ui.actionOperatorsView);
perspectives->addAction(ui.actionUnconnectedView);
perspectives->setExclusive(true); perspectives->setExclusive(true);
// Mark the right one as selected // Mark the right one as selected
...@@ -145,9 +116,13 @@ MainWindow::MainWindow(QWidget *parent): ...@@ -145,9 +116,13 @@ MainWindow::MainWindow(QWidget *parent):
if (currentView == VIEW_MAVLINK) ui.actionMavlinkView->setChecked(true); if (currentView == VIEW_MAVLINK) ui.actionMavlinkView->setChecked(true);
if (currentView == VIEW_PILOT) ui.actionPilotsView->setChecked(true); if (currentView == VIEW_PILOT) ui.actionPilotsView->setChecked(true);
if (currentView == VIEW_OPERATOR) ui.actionOperatorsView->setChecked(true); if (currentView == VIEW_OPERATOR) ui.actionOperatorsView->setChecked(true);
if (currentView == VIEW_UNCONNECTED) ui.actionUnconnectedView->setChecked(true);
// The pilot view is not available on startup // The pilot, engineer and operator view are not available on startup
// since they only make sense with a system connected.
ui.actionPilotsView->setEnabled(false); ui.actionPilotsView->setEnabled(false);
ui.actionOperatorsView->setEnabled(false);
ui.actionEngineersView->setEnabled(false);
buildCommonWidgets(); buildCommonWidgets();
...@@ -217,6 +192,54 @@ MainWindow::~MainWindow() ...@@ -217,6 +192,54 @@ MainWindow::~MainWindow()
} }
/**
* Set default settings for this AP type.
*/
void MainWindow::setDefaultSettingsForAp()
{
// Check if the settings exist, instantiate defaults if necessary
// UNCONNECTED VIEW DEFAULT
QString centralKey = buildMenuKey(SUB_SECTION_CHECKED, CENTRAL_MAP, VIEW_UNCONNECTED);
if (!settings.contains(centralKey))
{
settings.setValue(centralKey,true);
}
// OPERATOR VIEW DEFAULT
centralKey = buildMenuKey(SUB_SECTION_CHECKED, CENTRAL_MAP, VIEW_OPERATOR);
if (!settings.contains(centralKey))
{
settings.setValue(centralKey,true);
// ENABLE UAS LIST
settings.setValue(buildMenuKey(SUB_SECTION_CHECKED,MainWindow::MENU_UAS_LIST,VIEW_OPERATOR), true);
// ENABLE COMMUNICATION CONSOLE
settings.setValue(buildMenuKey(SUB_SECTION_CHECKED,MainWindow::MENU_DEBUG_CONSOLE,VIEW_OPERATOR), true);
}
// ENGINEER VIEW DEFAULT
centralKey = buildMenuKey(SUB_SECTION_CHECKED, CENTRAL_LINECHART, VIEW_ENGINEER);
if (!settings.contains(centralKey))
{
settings.setValue(centralKey,true);
}
// MAVLINK VIEW DEFAULT
centralKey = buildMenuKey(SUB_SECTION_CHECKED, CENTRAL_PROTOCOL, VIEW_MAVLINK);
if (!settings.contains(centralKey))
{
settings.setValue(centralKey,true);
}
// PILOT VIEW DEFAULT
centralKey = buildMenuKey(SUB_SECTION_CHECKED, CENTRAL_HUD, VIEW_PILOT);
if (!settings.contains(centralKey))
{
settings.setValue(centralKey,true);
}
}
void MainWindow::resizeEvent(QResizeEvent * event) void MainWindow::resizeEvent(QResizeEvent * event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
...@@ -289,7 +312,7 @@ void MainWindow::buildCommonWidgets() ...@@ -289,7 +312,7 @@ void MainWindow::buildCommonWidgets()
controlDockWidget = new QDockWidget(tr("Control"), this); controlDockWidget = new QDockWidget(tr("Control"), this);
controlDockWidget->setObjectName("UNMANNED_SYSTEM_CONTROL_DOCKWIDGET"); controlDockWidget->setObjectName("UNMANNED_SYSTEM_CONTROL_DOCKWIDGET");
controlDockWidget->setWidget( new UASControlWidget(this) ); controlDockWidget->setWidget( new UASControlWidget(this) );
addToToolsMenu (controlDockWidget, tr("Control"), SLOT(showToolWidget()), MENU_UAS_CONTROL, Qt::LeftDockWidgetArea); addToToolsMenu (controlDockWidget, tr("Control"), SLOT(showToolWidget(bool)), MENU_UAS_CONTROL, Qt::LeftDockWidgetArea);
} }
if (!listDockWidget) if (!listDockWidget)
...@@ -297,7 +320,7 @@ void MainWindow::buildCommonWidgets() ...@@ -297,7 +320,7 @@ void MainWindow::buildCommonWidgets()
listDockWidget = new QDockWidget(tr("Unmanned Systems"), this); listDockWidget = new QDockWidget(tr("Unmanned Systems"), this);
listDockWidget->setWidget( new UASListWidget(this) ); listDockWidget->setWidget( new UASListWidget(this) );
listDockWidget->setObjectName("UNMANNED_SYSTEMS_LIST_DOCKWIDGET"); listDockWidget->setObjectName("UNMANNED_SYSTEMS_LIST_DOCKWIDGET");
addToToolsMenu (listDockWidget, tr("Unmanned Systems"), SLOT(showToolWidget()), MENU_UAS_LIST, Qt::RightDockWidgetArea); addToToolsMenu (listDockWidget, tr("Unmanned Systems"), SLOT(showToolWidget(bool)), MENU_UAS_LIST, Qt::RightDockWidgetArea);
} }
if (!waypointsDockWidget) if (!waypointsDockWidget)
...@@ -305,7 +328,7 @@ void MainWindow::buildCommonWidgets() ...@@ -305,7 +328,7 @@ void MainWindow::buildCommonWidgets()
waypointsDockWidget = new QDockWidget(tr("Waypoint List"), this); waypointsDockWidget = new QDockWidget(tr("Waypoint List"), this);
waypointsDockWidget->setWidget( new WaypointList(this, NULL) ); waypointsDockWidget->setWidget( new WaypointList(this, NULL) );
waypointsDockWidget->setObjectName("WAYPOINT_LIST_DOCKWIDGET"); waypointsDockWidget->setObjectName("WAYPOINT_LIST_DOCKWIDGET");
addToToolsMenu (waypointsDockWidget, tr("Waypoints List"), SLOT(showToolWidget()), MENU_WAYPOINTS, Qt::BottomDockWidgetArea); addToToolsMenu (waypointsDockWidget, tr("Waypoints List"), SLOT(showToolWidget(bool)), MENU_WAYPOINTS, Qt::BottomDockWidgetArea);
} }
if (!infoDockWidget) if (!infoDockWidget)
...@@ -313,7 +336,7 @@ void MainWindow::buildCommonWidgets() ...@@ -313,7 +336,7 @@ void MainWindow::buildCommonWidgets()
infoDockWidget = new QDockWidget(tr("Status Details"), this); infoDockWidget = new QDockWidget(tr("Status Details"), this);
infoDockWidget->setWidget( new UASInfoWidget(this) ); infoDockWidget->setWidget( new UASInfoWidget(this) );
infoDockWidget->setObjectName("UAS_STATUS_DETAILS_DOCKWIDGET"); infoDockWidget->setObjectName("UAS_STATUS_DETAILS_DOCKWIDGET");
addToToolsMenu (infoDockWidget, tr("Status Details"), SLOT(showToolWidget()), MENU_STATUS, Qt::RightDockWidgetArea); addToToolsMenu (infoDockWidget, tr("Status Details"), SLOT(showToolWidget(bool)), MENU_STATUS, Qt::RightDockWidgetArea);
} }
if (!debugConsoleDockWidget) if (!debugConsoleDockWidget)
...@@ -321,7 +344,7 @@ void MainWindow::buildCommonWidgets() ...@@ -321,7 +344,7 @@ void MainWindow::buildCommonWidgets()
debugConsoleDockWidget = new QDockWidget(tr("Communication Console"), this); debugConsoleDockWidget = new QDockWidget(tr("Communication Console"), this);
debugConsoleDockWidget->setWidget( new DebugConsole(this) ); debugConsoleDockWidget->setWidget( new DebugConsole(this) );
debugConsoleDockWidget->setObjectName("COMMUNICATION_DEBUG_CONSOLE_DOCKWIDGET"); debugConsoleDockWidget->setObjectName("COMMUNICATION_DEBUG_CONSOLE_DOCKWIDGET");
addToToolsMenu (debugConsoleDockWidget, tr("Communication Console"), SLOT(showToolWidget()), MENU_DEBUG_CONSOLE, Qt::BottomDockWidgetArea); addToToolsMenu (debugConsoleDockWidget, tr("Communication Console"), SLOT(showToolWidget(bool)), MENU_DEBUG_CONSOLE, Qt::BottomDockWidgetArea);
} }
if (!logPlayerDockWidget) if (!logPlayerDockWidget)
...@@ -329,7 +352,7 @@ void MainWindow::buildCommonWidgets() ...@@ -329,7 +352,7 @@ void MainWindow::buildCommonWidgets()
logPlayerDockWidget = new QDockWidget(tr("MAVLink Log Player"), this); logPlayerDockWidget = new QDockWidget(tr("MAVLink Log Player"), this);
logPlayerDockWidget->setWidget( new QGCMAVLinkLogPlayer(mavlink, this) ); logPlayerDockWidget->setWidget( new QGCMAVLinkLogPlayer(mavlink, this) );
logPlayerDockWidget->setObjectName("MAVLINK_LOG_PLAYER_DOCKWIDGET"); logPlayerDockWidget->setObjectName("MAVLINK_LOG_PLAYER_DOCKWIDGET");
addToToolsMenu(logPlayerDockWidget, tr("MAVLink Log Replay"), SLOT(showToolWidget()), MENU_MAVLINK_LOG_PLAYER, Qt::RightDockWidgetArea); addToToolsMenu(logPlayerDockWidget, tr("MAVLink Log Replay"), SLOT(showToolWidget(bool)), MENU_MAVLINK_LOG_PLAYER, Qt::RightDockWidgetArea);
} }
// Center widgets // Center widgets
...@@ -350,7 +373,7 @@ void MainWindow::buildCommonWidgets() ...@@ -350,7 +373,7 @@ void MainWindow::buildCommonWidgets()
{ {
slugsHilSimWidget = new QDockWidget(tr("Slugs Hil Sim"), this); slugsHilSimWidget = new QDockWidget(tr("Slugs Hil Sim"), this);
slugsHilSimWidget->setWidget( new SlugsHilSim(this)); slugsHilSimWidget->setWidget( new SlugsHilSim(this));
addToToolsMenu (slugsHilSimWidget, tr("HIL Sim Configuration"), SLOT(showToolWidget()), MENU_SLUGS_HIL, Qt::LeftDockWidgetArea); addToToolsMenu (slugsHilSimWidget, tr("HIL Sim Configuration"), SLOT(showToolWidget(bool)), MENU_SLUGS_HIL, Qt::LeftDockWidgetArea);
} }
//TODO temporaly debug //TODO temporaly debug
...@@ -358,7 +381,7 @@ void MainWindow::buildCommonWidgets() ...@@ -358,7 +381,7 @@ void MainWindow::buildCommonWidgets()
{ {
slugsCamControlWidget = new QDockWidget(tr("Slugs Video Camera Control"), this); slugsCamControlWidget = new QDockWidget(tr("Slugs Video Camera Control"), this);
slugsCamControlWidget->setWidget(new SlugsVideoCamControl(this)); slugsCamControlWidget->setWidget(new SlugsVideoCamControl(this));
addToToolsMenu (slugsCamControlWidget, tr("Camera Control"), SLOT(showToolWidget()), MENU_SLUGS_CAMERA, Qt::BottomDockWidgetArea); addToToolsMenu (slugsCamControlWidget, tr("Camera Control"), SLOT(showToolWidget(bool)), MENU_SLUGS_CAMERA, Qt::BottomDockWidgetArea);
} }
if (!dataplotWidget) if (!dataplotWidget)
{ {
...@@ -437,7 +460,7 @@ void MainWindow::buildPxWidgets() ...@@ -437,7 +460,7 @@ void MainWindow::buildPxWidgets()
detectionDockWidget = new QDockWidget(tr("Object Recognition"), this); detectionDockWidget = new QDockWidget(tr("Object Recognition"), this);
detectionDockWidget->setWidget( new ObjectDetectionView("images/patterns", this) ); detectionDockWidget->setWidget( new ObjectDetectionView("images/patterns", this) );
detectionDockWidget->setObjectName("OBJECT_DETECTION_DOCK_WIDGET"); detectionDockWidget->setObjectName("OBJECT_DETECTION_DOCK_WIDGET");
addToToolsMenu (detectionDockWidget, tr("Object Recognition"), SLOT(showToolWidget()), MENU_DETECTION, Qt::RightDockWidgetArea); addToToolsMenu (detectionDockWidget, tr("Object Recognition"), SLOT(showToolWidget(bool)), MENU_DETECTION, Qt::RightDockWidgetArea);
} }
if (!parametersDockWidget) if (!parametersDockWidget)
...@@ -445,7 +468,7 @@ void MainWindow::buildPxWidgets() ...@@ -445,7 +468,7 @@ void MainWindow::buildPxWidgets()
parametersDockWidget = new QDockWidget(tr("Calibration and Onboard Parameters"), this); parametersDockWidget = new QDockWidget(tr("Calibration and Onboard Parameters"), this);
parametersDockWidget->setWidget( new ParameterInterface(this) ); parametersDockWidget->setWidget( new ParameterInterface(this) );
parametersDockWidget->setObjectName("PARAMETER_INTERFACE_DOCKWIDGET"); parametersDockWidget->setObjectName("PARAMETER_INTERFACE_DOCKWIDGET");
addToToolsMenu (parametersDockWidget, tr("Calibration and Parameters"), SLOT(showToolWidget()), MENU_PARAMETERS, Qt::RightDockWidgetArea); addToToolsMenu (parametersDockWidget, tr("Calibration and Parameters"), SLOT(showToolWidget(bool)), MENU_PARAMETERS, Qt::RightDockWidgetArea);
} }
if (!watchdogControlDockWidget) if (!watchdogControlDockWidget)
...@@ -453,7 +476,7 @@ void MainWindow::buildPxWidgets() ...@@ -453,7 +476,7 @@ void MainWindow::buildPxWidgets()
watchdogControlDockWidget = new QDockWidget(tr("Process Control"), this); watchdogControlDockWidget = new QDockWidget(tr("Process Control"), this);
watchdogControlDockWidget->setWidget( new WatchdogControl(this) ); watchdogControlDockWidget->setWidget( new WatchdogControl(this) );
watchdogControlDockWidget->setObjectName("WATCHDOG_CONTROL_DOCKWIDGET"); watchdogControlDockWidget->setObjectName("WATCHDOG_CONTROL_DOCKWIDGET");
addToToolsMenu (watchdogControlDockWidget, tr("Process Control"), SLOT(showToolWidget()), MENU_WATCHDOG, Qt::BottomDockWidgetArea); addToToolsMenu (watchdogControlDockWidget, tr("Process Control"), SLOT(showToolWidget(bool)), MENU_WATCHDOG, Qt::BottomDockWidgetArea);
} }
if (!hsiDockWidget) if (!hsiDockWidget)
...@@ -461,7 +484,7 @@ void MainWindow::buildPxWidgets() ...@@ -461,7 +484,7 @@ void MainWindow::buildPxWidgets()
hsiDockWidget = new QDockWidget(tr("Horizontal Situation Indicator"), this); hsiDockWidget = new QDockWidget(tr("Horizontal Situation Indicator"), this);
hsiDockWidget->setWidget( new HSIDisplay(this) ); hsiDockWidget->setWidget( new HSIDisplay(this) );
hsiDockWidget->setObjectName("HORIZONTAL_SITUATION_INDICATOR_DOCK_WIDGET"); hsiDockWidget->setObjectName("HORIZONTAL_SITUATION_INDICATOR_DOCK_WIDGET");
addToToolsMenu (hsiDockWidget, tr("HSI"), SLOT(showToolWidget()), MENU_HSI, Qt::BottomDockWidgetArea); addToToolsMenu (hsiDockWidget, tr("HSI"), SLOT(showToolWidget(bool)), MENU_HSI, Qt::BottomDockWidgetArea);
} }
if (!headDown1DockWidget) if (!headDown1DockWidget)
...@@ -469,7 +492,7 @@ void MainWindow::buildPxWidgets() ...@@ -469,7 +492,7 @@ void MainWindow::buildPxWidgets()
headDown1DockWidget = new QDockWidget(tr("Flight Display"), this); headDown1DockWidget = new QDockWidget(tr("Flight Display"), this);
headDown1DockWidget->setWidget( new HDDisplay(acceptList, "Flight Display", this) ); headDown1DockWidget->setWidget( new HDDisplay(acceptList, "Flight Display", this) );
headDown1DockWidget->setObjectName("HEAD_DOWN_DISPLAY_1_DOCK_WIDGET"); headDown1DockWidget->setObjectName("HEAD_DOWN_DISPLAY_1_DOCK_WIDGET");
addToToolsMenu (headDown1DockWidget, tr("Flight Display"), SLOT(showToolWidget()), MENU_HDD_1, Qt::RightDockWidgetArea); addToToolsMenu (headDown1DockWidget, tr("Flight Display"), SLOT(showToolWidget(bool)), MENU_HDD_1, Qt::RightDockWidgetArea);
} }
if (!headDown2DockWidget) if (!headDown2DockWidget)
...@@ -477,7 +500,7 @@ void MainWindow::buildPxWidgets() ...@@ -477,7 +500,7 @@ void MainWindow::buildPxWidgets()
headDown2DockWidget = new QDockWidget(tr("Payload Status"), this); headDown2DockWidget = new QDockWidget(tr("Payload Status"), this);
headDown2DockWidget->setWidget( new HDDisplay(acceptList2, "Payload Status", this) ); headDown2DockWidget->setWidget( new HDDisplay(acceptList2, "Payload Status", this) );
headDown2DockWidget->setObjectName("HEAD_DOWN_DISPLAY_2_DOCK_WIDGET"); headDown2DockWidget->setObjectName("HEAD_DOWN_DISPLAY_2_DOCK_WIDGET");
addToToolsMenu (headDown2DockWidget, tr("Payload Status"), SLOT(showToolWidget()), MENU_HDD_2, Qt::RightDockWidgetArea); addToToolsMenu (headDown2DockWidget, tr("Payload Status"), SLOT(showToolWidget(bool)), MENU_HDD_2, Qt::RightDockWidgetArea);
} }
if (!rcViewDockWidget) if (!rcViewDockWidget)
...@@ -485,7 +508,7 @@ void MainWindow::buildPxWidgets() ...@@ -485,7 +508,7 @@ void MainWindow::buildPxWidgets()
rcViewDockWidget = new QDockWidget(tr("Radio Control"), this); rcViewDockWidget = new QDockWidget(tr("Radio Control"), this);
rcViewDockWidget->setWidget( new QGCRemoteControlView(this) ); rcViewDockWidget->setWidget( new QGCRemoteControlView(this) );
rcViewDockWidget->setObjectName("RADIO_CONTROL_CHANNELS_DOCK_WIDGET"); rcViewDockWidget->setObjectName("RADIO_CONTROL_CHANNELS_DOCK_WIDGET");
addToToolsMenu (rcViewDockWidget, tr("Radio Control"), SLOT(showToolWidget()), MENU_RC_VIEW, Qt::BottomDockWidgetArea); addToToolsMenu (rcViewDockWidget, tr("Radio Control"), SLOT(showToolWidget(bool)), MENU_RC_VIEW, Qt::BottomDockWidgetArea);
} }
if (!headUpDockWidget) if (!headUpDockWidget)
...@@ -493,7 +516,7 @@ void MainWindow::buildPxWidgets() ...@@ -493,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()), MENU_HUD, Qt::LeftDockWidgetArea); addToToolsMenu (headUpDockWidget, tr("Control Indicator"), SLOT(showToolWidget(bool)), MENU_HUD, Qt::LeftDockWidgetArea);
} }
if (!video1DockWidget) if (!video1DockWidget)
...@@ -505,7 +528,7 @@ void MainWindow::buildPxWidgets() ...@@ -505,7 +528,7 @@ void MainWindow::buildPxWidgets()
// FIXME select video stream as well // FIXME select video stream as well
video1DockWidget->setWidget(video1); video1DockWidget->setWidget(video1);
video1DockWidget->setObjectName("VIDEO_STREAM_1_DOCK_WIDGET"); video1DockWidget->setObjectName("VIDEO_STREAM_1_DOCK_WIDGET");
addToToolsMenu (video1DockWidget, tr("Video Stream 1"), SLOT(showToolWidget()), MENU_VIDEO_STREAM_1, Qt::LeftDockWidgetArea); addToToolsMenu (video1DockWidget, tr("Video Stream 1"), SLOT(showToolWidget(bool)), MENU_VIDEO_STREAM_1, Qt::LeftDockWidgetArea);
} }
if (!video2DockWidget) if (!video2DockWidget)
...@@ -517,7 +540,7 @@ void MainWindow::buildPxWidgets() ...@@ -517,7 +540,7 @@ void MainWindow::buildPxWidgets()
// FIXME select video stream as well // FIXME select video stream as well
video2DockWidget->setWidget(video2); video2DockWidget->setWidget(video2);
video2DockWidget->setObjectName("VIDEO_STREAM_2_DOCK_WIDGET"); video2DockWidget->setObjectName("VIDEO_STREAM_2_DOCK_WIDGET");
addToToolsMenu (video2DockWidget, tr("Video Stream 2"), SLOT(showToolWidget()), MENU_VIDEO_STREAM_2, Qt::LeftDockWidgetArea); addToToolsMenu (video2DockWidget, tr("Video Stream 2"), SLOT(showToolWidget(bool)), MENU_VIDEO_STREAM_2, Qt::LeftDockWidgetArea);
} }
// Dialogue widgets // Dialogue widgets
...@@ -538,7 +561,7 @@ void MainWindow::buildSlugsWidgets() ...@@ -538,7 +561,7 @@ void MainWindow::buildSlugsWidgets()
headUpDockWidget = new QDockWidget(tr("Control Indicator"), this); headUpDockWidget = new QDockWidget(tr("Control Indicator"), 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("HUD"), SLOT(showToolWidget()), MENU_HUD, Qt::LeftDockWidgetArea); addToToolsMenu (headUpDockWidget, tr("HUD"), SLOT(showToolWidget(bool)), MENU_HUD, Qt::LeftDockWidgetArea);
} }
if (!rcViewDockWidget) if (!rcViewDockWidget)
...@@ -546,7 +569,7 @@ void MainWindow::buildSlugsWidgets() ...@@ -546,7 +569,7 @@ void MainWindow::buildSlugsWidgets()
rcViewDockWidget = new QDockWidget(tr("Radio Control"), this); rcViewDockWidget = new QDockWidget(tr("Radio Control"), this);
rcViewDockWidget->setWidget( new QGCRemoteControlView(this) ); rcViewDockWidget->setWidget( new QGCRemoteControlView(this) );
rcViewDockWidget->setObjectName("RADIO_CONTROL_CHANNELS_DOCK_WIDGET"); rcViewDockWidget->setObjectName("RADIO_CONTROL_CHANNELS_DOCK_WIDGET");
addToToolsMenu (rcViewDockWidget, tr("Radio Control"), SLOT(showToolWidget()), MENU_RC_VIEW, Qt::BottomDockWidgetArea); addToToolsMenu (rcViewDockWidget, tr("Radio Control"), SLOT(showToolWidget(bool)), MENU_RC_VIEW, Qt::BottomDockWidgetArea);
} }
if (!slugsDataWidget) if (!slugsDataWidget)
...@@ -555,7 +578,7 @@ void MainWindow::buildSlugsWidgets() ...@@ -555,7 +578,7 @@ void MainWindow::buildSlugsWidgets()
slugsDataWidget = new QDockWidget(tr("Slugs Data"), this); slugsDataWidget = new QDockWidget(tr("Slugs Data"), this);
slugsDataWidget->setWidget( new SlugsDataSensorView(this)); slugsDataWidget->setWidget( new SlugsDataSensorView(this));
slugsDataWidget->setObjectName("SLUGS_DATA_DOCK_WIDGET"); slugsDataWidget->setObjectName("SLUGS_DATA_DOCK_WIDGET");
addToToolsMenu (slugsDataWidget, tr("Telemetry Data"), SLOT(showToolWidget()), MENU_SLUGS_DATA, Qt::RightDockWidgetArea); addToToolsMenu (slugsDataWidget, tr("Telemetry Data"), SLOT(showToolWidget(bool)), MENU_SLUGS_DATA, Qt::RightDockWidgetArea);
} }
if (!slugsPIDControlWidget) if (!slugsPIDControlWidget)
...@@ -563,7 +586,7 @@ void MainWindow::buildSlugsWidgets() ...@@ -563,7 +586,7 @@ void MainWindow::buildSlugsWidgets()
slugsPIDControlWidget = new QDockWidget(tr("Slugs PID Control"), this); slugsPIDControlWidget = new QDockWidget(tr("Slugs PID Control"), this);
slugsPIDControlWidget->setWidget(new SlugsPIDControl(this)); slugsPIDControlWidget->setWidget(new SlugsPIDControl(this));
slugsPIDControlWidget->setObjectName("SLUGS_PID_CONTROL_DOCK_WIDGET"); slugsPIDControlWidget->setObjectName("SLUGS_PID_CONTROL_DOCK_WIDGET");
addToToolsMenu (slugsPIDControlWidget, tr("PID Configuration"), SLOT(showToolWidget()), MENU_SLUGS_PID, Qt::LeftDockWidgetArea); addToToolsMenu (slugsPIDControlWidget, tr("PID Configuration"), SLOT(showToolWidget(bool)), MENU_SLUGS_PID, Qt::LeftDockWidgetArea);
} }
if (!slugsHilSimWidget) if (!slugsHilSimWidget)
...@@ -571,7 +594,7 @@ void MainWindow::buildSlugsWidgets() ...@@ -571,7 +594,7 @@ void MainWindow::buildSlugsWidgets()
slugsHilSimWidget = new QDockWidget(tr("Slugs Hil Sim"), this); slugsHilSimWidget = new QDockWidget(tr("Slugs Hil Sim"), this);
slugsHilSimWidget->setWidget( new SlugsHilSim(this)); slugsHilSimWidget->setWidget( new SlugsHilSim(this));
slugsHilSimWidget->setObjectName("SLUGS_HIL_SIM_DOCK_WIDGET"); slugsHilSimWidget->setObjectName("SLUGS_HIL_SIM_DOCK_WIDGET");
addToToolsMenu (slugsHilSimWidget, tr("HIL Sim Configuration"), SLOT(showToolWidget()), MENU_SLUGS_HIL, Qt::LeftDockWidgetArea); addToToolsMenu (slugsHilSimWidget, tr("HIL Sim Configuration"), SLOT(showToolWidget(bool)), MENU_SLUGS_HIL, Qt::LeftDockWidgetArea);
} }
if (!slugsCamControlWidget) if (!slugsCamControlWidget)
...@@ -579,7 +602,7 @@ void MainWindow::buildSlugsWidgets() ...@@ -579,7 +602,7 @@ void MainWindow::buildSlugsWidgets()
slugsCamControlWidget = new QDockWidget(tr("Slugs Video Camera Control"), this); slugsCamControlWidget = new QDockWidget(tr("Slugs Video Camera Control"), this);
slugsCamControlWidget->setWidget(new SlugsVideoCamControl(this)); slugsCamControlWidget->setWidget(new SlugsVideoCamControl(this));
slugsCamControlWidget->setObjectName("SLUGS_CAM_CONTROL_DOCK_WIDGET"); slugsCamControlWidget->setObjectName("SLUGS_CAM_CONTROL_DOCK_WIDGET");
addToToolsMenu (slugsCamControlWidget, tr("Camera Control"), SLOT(showToolWidget()), MENU_SLUGS_CAMERA, Qt::BottomDockWidgetArea); addToToolsMenu (slugsCamControlWidget, tr("Camera Control"), SLOT(showToolWidget(bool)), MENU_SLUGS_CAMERA, Qt::BottomDockWidgetArea);
} }
} }
...@@ -592,15 +615,17 @@ void MainWindow::addToCentralWidgetsMenu ( QWidget* widget, ...@@ -592,15 +615,17 @@ void MainWindow::addToCentralWidgetsMenu ( QWidget* widget,
QAction* tempAction; QAction* tempAction;
// Add the separator that will separate tools from central Widgets // Not needed any more - separate menu now available
if (!toolsMenuActions[CENTRAL_SEPARATOR])
{
tempAction = ui.menuTools->addSeparator();
toolsMenuActions[CENTRAL_SEPARATOR] = tempAction;
tempAction->setData(CENTRAL_SEPARATOR);
}
tempAction = ui.menuTools->addAction(title); // // Add the separator that will separate tools from central Widgets
// if (!toolsMenuActions[CENTRAL_SEPARATOR])
// {
// tempAction = ui.menuTools->addSeparator();
// toolsMenuActions[CENTRAL_SEPARATOR] = tempAction;
// tempAction->setData(CENTRAL_SEPARATOR);
// }
tempAction = ui.menuMain->addAction(title);
tempAction->setCheckable(true); tempAction->setCheckable(true);
tempAction->setData(centralWidget); tempAction->setData(centralWidget);
...@@ -622,13 +647,17 @@ void MainWindow::addToCentralWidgetsMenu ( QWidget* widget, ...@@ -622,13 +647,17 @@ void MainWindow::addToCentralWidgetsMenu ( QWidget* widget,
} }
// connect the action // connect the action
connect(tempAction,SIGNAL(triggered()),this, slotName); connect(tempAction,SIGNAL(triggered(bool)),this, slotName);
} }
void MainWindow::showCentralWidget() void MainWindow::showCentralWidget()
{ {
QAction* senderAction = qobject_cast<QAction *>(sender()); QAction* senderAction = qobject_cast<QAction *>(sender());
// Block sender action while manipulating state
senderAction->blockSignals(true);
int tool = senderAction->data().toInt(); int tool = senderAction->data().toInt();
QString chKey; QString chKey;
...@@ -636,7 +665,6 @@ void MainWindow::showCentralWidget() ...@@ -636,7 +665,6 @@ void MainWindow::showCentralWidget()
if (senderAction && dockWidgets[tool]) if (senderAction && dockWidgets[tool])
{ {
// uncheck all central widget actions // uncheck all central widget actions
QHashIterator<int, QAction*> i(toolsMenuActions); QHashIterator<int, QAction*> i(toolsMenuActions);
while (i.hasNext()) while (i.hasNext())
...@@ -645,7 +673,11 @@ void MainWindow::showCentralWidget() ...@@ -645,7 +673,11 @@ void MainWindow::showCentralWidget()
//qDebug() << "shCW" << i.key() << "read"; //qDebug() << "shCW" << i.key() << "read";
if (i.value() && i.value()->data().toInt() > 255) if (i.value() && i.value()->data().toInt() > 255)
{ {
// Block signals and uncheck action
// firing would be unneccesary
i.value()->blockSignals(true);
i.value()->setChecked(false); i.value()->setChecked(false);
i.value()->blockSignals(false);
// update the settings // update the settings
chKey = buildMenuKey (SUB_SECTION_CHECKED,static_cast<TOOLS_WIDGET_NAMES>(i.value()->data().toInt()), currentView); chKey = buildMenuKey (SUB_SECTION_CHECKED,static_cast<TOOLS_WIDGET_NAMES>(i.value()->data().toInt()), currentView);
...@@ -664,6 +696,9 @@ void MainWindow::showCentralWidget() ...@@ -664,6 +696,9 @@ void MainWindow::showCentralWidget()
chKey = buildMenuKey (SUB_SECTION_CHECKED,static_cast<TOOLS_WIDGET_NAMES>(tool), currentView); chKey = buildMenuKey (SUB_SECTION_CHECKED,static_cast<TOOLS_WIDGET_NAMES>(tool), currentView);
settings.setValue(chKey,true); settings.setValue(chKey,true);
// Unblock sender action
senderAction->blockSignals(false);
presentView(); presentView();
} }
} }
...@@ -723,39 +758,60 @@ void MainWindow::addToToolsMenu ( QWidget* widget, ...@@ -723,39 +758,60 @@ void MainWindow::addToToolsMenu ( QWidget* widget,
} }
else else
{ {
tempAction->setChecked(settings.value(chKey).toBool()); tempAction->setChecked(settings.value(chKey, false).toBool());
widget->setVisible(settings.value(chKey, false).toBool()); widget->setVisible(settings.value(chKey, false).toBool());
} }
// connect the action // connect the action
connect(tempAction,SIGNAL(triggered()),this, slotName); connect(tempAction,SIGNAL(toggled(bool)),this, slotName);
// connect(qobject_cast <QDockWidget *>(dockWidgets[tool]), connect(qobject_cast <QDockWidget *>(dockWidgets[tool]),
// SIGNAL(visibilityChanged(bool)), this, SLOT(updateVisibilitySettings(bool))); SIGNAL(visibilityChanged(bool)), tempAction, SLOT(setChecked(bool)));
// connect(qobject_cast <QDockWidget *>(dockWidgets[tool]),
// SIGNAL(visibilityChanged(bool)), this, SLOT(updateVisibilitySettings(bool)));
connect(qobject_cast <QDockWidget *>(dockWidgets[tool]), connect(qobject_cast <QDockWidget *>(dockWidgets[tool]),
SIGNAL(dockLocationChanged(Qt::DockWidgetArea)), this, SLOT(updateLocationSettings(Qt::DockWidgetArea))); SIGNAL(dockLocationChanged(Qt::DockWidgetArea)), this, SLOT(updateLocationSettings(Qt::DockWidgetArea)));
} }
void MainWindow::showToolWidget() void MainWindow::showToolWidget(bool visible)
{ {
QAction* temp = qobject_cast<QAction *>(sender()); if (!aboutToCloseFlag && !changingViewsFlag)
int tool = temp->data().toInt(); {
QAction* action = qobject_cast<QAction *>(sender());
int tool = action->data().toInt();
QDockWidget* dockWidget = qobject_cast<QDockWidget *> (dockWidgets[tool]);
if (temp && dockWidgets[tool]) if (action && dockWidget)
{ {
if (temp->isChecked()) if (visible)
{ {
addDockWidget(dockWidgetLocations[tool], qobject_cast<QDockWidget *> (dockWidgets[tool])); addDockWidget(dockWidgetLocations[tool], dockWidget);
qobject_cast<QDockWidget *>(dockWidgets[tool])->show(); dockWidget->show();
} }
else
if (!visible && dockWidget->isVisible())
{ {
removeDockWidget(qobject_cast<QDockWidget *>(dockWidgets[tool])); removeDockWidget(dockWidget);
}
} }
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;
}
}
}
}
} }
...@@ -767,6 +823,8 @@ void MainWindow::showTheWidget (TOOLS_WIDGET_NAMES widget, VIEW_SECTIONS view) ...@@ -767,6 +823,8 @@ void MainWindow::showTheWidget (TOOLS_WIDGET_NAMES widget, VIEW_SECTIONS view)
tempVisible = settings.value(buildMenuKey(SUB_SECTION_CHECKED,widget,view), false).toBool(); tempVisible = settings.value(buildMenuKey(SUB_SECTION_CHECKED,widget,view), false).toBool();
qDebug() << "showTheWidget(): Set key" << buildMenuKey(SUB_SECTION_CHECKED,widget,view) << "to" << tempVisible;
if (tempWidget) if (tempWidget)
{ {
toolsMenuActions[widget]->setChecked(tempVisible); toolsMenuActions[widget]->setChecked(tempVisible);
...@@ -785,12 +843,14 @@ void MainWindow::showTheWidget (TOOLS_WIDGET_NAMES widget, VIEW_SECTIONS view) ...@@ -785,12 +843,14 @@ void MainWindow::showTheWidget (TOOLS_WIDGET_NAMES widget, VIEW_SECTIONS view)
// } // }
// } // }
if ((tempWidget != NULL) && tempVisible) if (tempWidget != NULL)
{
if (tempVisible)
{ {
addDockWidget(tempLocation, tempWidget); addDockWidget(tempLocation, tempWidget);
tempWidget->show(); tempWidget->show();
} }
}
} }
QString MainWindow::buildMenuKey(SETTINGS_SECTIONS section, TOOLS_WIDGET_NAMES tool, VIEW_SECTIONS view) QString MainWindow::buildMenuKey(SETTINGS_SECTIONS section, TOOLS_WIDGET_NAMES tool, VIEW_SECTIONS view)
...@@ -802,11 +862,11 @@ QString MainWindow::buildMenuKey(SETTINGS_SECTIONS section, TOOLS_WIDGET_NAMES t ...@@ -802,11 +862,11 @@ QString MainWindow::buildMenuKey(SETTINGS_SECTIONS section, TOOLS_WIDGET_NAMES t
UASManager::instance()->getActiveUAS()->getAutopilotType(): UASManager::instance()->getActiveUAS()->getAutopilotType():
-1; -1;
return (QString::number(apType) + "/" + return (QString::number(apType) + "_" +
QString::number(SECTION_MENU) + "/" + QString::number(SECTION_MENU) + "_" +
QString::number(view) + "/" + QString::number(view) + "_" +
QString::number(tool) + "/" + QString::number(tool) + "_" +
QString::number(section) + "/" ); QString::number(section) + "_" );
} }
void MainWindow::closeEvent(QCloseEvent *event) void MainWindow::closeEvent(QCloseEvent *event)
...@@ -824,6 +884,29 @@ void MainWindow::closeEvent(QCloseEvent *event) ...@@ -824,6 +884,29 @@ void MainWindow::closeEvent(QCloseEvent *event)
QMainWindow::closeEvent(event); QMainWindow::closeEvent(event);
} }
void MainWindow::showDockWidget (bool vis)
{
if (!aboutToCloseFlag && !changingViewsFlag)
{
QDockWidget* temp = qobject_cast<QDockWidget *>(sender());
if (temp)
{
QHashIterator<int, QWidget*> i(dockWidgets);
while (i.hasNext())
{
i.next();
if ((static_cast <QDockWidget *>(dockWidgets[i.key()])) == temp)
{
QString chKey = buildMenuKey (SUB_SECTION_CHECKED,static_cast<TOOLS_WIDGET_NAMES>(i.key()), currentView);
settings.setValue(chKey,vis);
toolsMenuActions[i.key()]->setChecked(vis);
break;
}
}
}
}
}
void MainWindow::updateVisibilitySettings (bool vis) void MainWindow::updateVisibilitySettings (bool vis)
{ {
...@@ -834,9 +917,11 @@ void MainWindow::updateVisibilitySettings (bool vis) ...@@ -834,9 +917,11 @@ void MainWindow::updateVisibilitySettings (bool vis)
if (temp) if (temp)
{ {
QHashIterator<int, QWidget*> i(dockWidgets); QHashIterator<int, QWidget*> i(dockWidgets);
while (i.hasNext()) { while (i.hasNext())
{
i.next(); i.next();
if ((static_cast <QDockWidget *>(dockWidgets[i.key()])) == temp) { if ((static_cast <QDockWidget *>(dockWidgets[i.key()])) == temp)
{
QString chKey = buildMenuKey (SUB_SECTION_CHECKED,static_cast<TOOLS_WIDGET_NAMES>(i.key()), currentView); QString chKey = buildMenuKey (SUB_SECTION_CHECKED,static_cast<TOOLS_WIDGET_NAMES>(i.key()), currentView);
settings.setValue(chKey,vis); settings.setValue(chKey,vis);
toolsMenuActions[i.key()]->setChecked(vis); toolsMenuActions[i.key()]->setChecked(vis);
...@@ -1163,6 +1248,7 @@ void MainWindow::connectCommonActions() ...@@ -1163,6 +1248,7 @@ void MainWindow::connectCommonActions()
connect(ui.actionPilotsView, SIGNAL(triggered()), this, SLOT(loadPilotView())); connect(ui.actionPilotsView, SIGNAL(triggered()), this, SLOT(loadPilotView()));
connect(ui.actionEngineersView, SIGNAL(triggered()), this, SLOT(loadEngineerView())); connect(ui.actionEngineersView, SIGNAL(triggered()), this, SLOT(loadEngineerView()));
connect(ui.actionOperatorsView, SIGNAL(triggered()), this, SLOT(loadOperatorView())); connect(ui.actionOperatorsView, SIGNAL(triggered()), this, SLOT(loadOperatorView()));
connect(ui.actionUnconnectedView, SIGNAL(triggered()), this, SLOT(loadUnconnectedView()));
connect(ui.actionMavlinkView, SIGNAL(triggered()), this, SLOT(loadMAVLinkView())); connect(ui.actionMavlinkView, SIGNAL(triggered()), this, SLOT(loadMAVLinkView()));
connect(ui.actionReloadStyle, SIGNAL(triggered()), this, SLOT(reloadStylesheet())); connect(ui.actionReloadStyle, SIGNAL(triggered()), this, SLOT(reloadStylesheet()));
...@@ -1309,8 +1395,13 @@ void MainWindow::UASCreated(UASInterface* uas) ...@@ -1309,8 +1395,13 @@ void MainWindow::UASCreated(UASInterface* uas)
if (uas != NULL) if (uas != NULL)
{ {
// The pilot view was not available on startup, enable it now // Set default settings
setDefaultSettingsForAp();
// The pilot, operator and engineer views were not available on startup, enable them now
ui.actionPilotsView->setEnabled(true); ui.actionPilotsView->setEnabled(true);
ui.actionOperatorsView->setEnabled(true);
ui.actionEngineersView->setEnabled(true);
QIcon icon; QIcon icon;
// Set matching icon // Set matching icon
...@@ -1404,6 +1495,7 @@ void MainWindow::UASCreated(UASInterface* uas) ...@@ -1404,6 +1495,7 @@ void MainWindow::UASCreated(UASInterface* uas)
// } // }
// } // }
// } // }
} }
break; break;
default: default:
...@@ -1424,8 +1516,6 @@ void MainWindow::UASCreated(UASInterface* uas) ...@@ -1424,8 +1516,6 @@ void MainWindow::UASCreated(UASInterface* uas)
connectPxActions(); connectPxActions();
} }
break; break;
loadOperatorView();
} }
// Change the view only if this is the first UAS // Change the view only if this is the first UAS
...@@ -1439,19 +1529,31 @@ void MainWindow::UASCreated(UASInterface* uas) ...@@ -1439,19 +1529,31 @@ void MainWindow::UASCreated(UASInterface* uas)
// Load last view if setting is present // Load last view if setting is present
if (settings.contains("CURRENT_VIEW_WITH_UAS_CONNECTED")) if (settings.contains("CURRENT_VIEW_WITH_UAS_CONNECTED"))
{ {
clearView();
int view = settings.value("CURRENT_VIEW_WITH_UAS_CONNECTED").toInt(); int view = settings.value("CURRENT_VIEW_WITH_UAS_CONNECTED").toInt();
currentView = (VIEW_SECTIONS) view; switch (view)
presentView();
// Restore the widget positions and size
if (settings.contains(getWindowStateKey()))
{ {
restoreState(settings.value(getWindowStateKey()).toByteArray(), QGC::applicationVersion()); case VIEW_ENGINEER:
loadEngineerView();
break;
case VIEW_MAVLINK:
loadMAVLinkView();
break;
case VIEW_PILOT:
loadPilotView();
break;
case VIEW_UNCONNECTED:
loadUnconnectedView();
break;
case VIEW_OPERATOR:
default:
loadOperatorView();
break;
} }
} }
else else
{ {
loadEngineerView(); loadOperatorView();
} }
} }
...@@ -1469,7 +1571,7 @@ void MainWindow::UASCreated(UASInterface* uas) ...@@ -1469,7 +1571,7 @@ void MainWindow::UASCreated(UASInterface* uas)
void MainWindow::clearView() void MainWindow::clearView()
{ {
// Save current state // Save current state
if (UASManager::instance()->getActiveUAS()) settings.setValue(getWindowStateKey(), saveState(QGC::applicationVersion())); if (UASManager::instance()->getUASList().count() > 0) settings.setValue(getWindowStateKey(), saveState(QGC::applicationVersion()));
settings.setValue(getWindowGeometryKey(), saveGeometry()); settings.setValue(getWindowGeometryKey(), saveGeometry());
QAction* temp; QAction* temp;
...@@ -1482,12 +1584,12 @@ void MainWindow::clearView() ...@@ -1482,12 +1584,12 @@ void MainWindow::clearView()
if (temp) if (temp)
{ {
//qDebug() << "TOOL:" << chKey << "IS:" << temp->isChecked(); qDebug() << "TOOL:" << chKey << "IS:" << temp->isChecked();
settings.setValue(chKey,temp->isChecked()); settings.setValue(chKey,temp->isChecked());
} }
else else
{ {
//qDebug() << "TOOL:" << chKey << "IS DEFAULT AND UNCHECKED"; qDebug() << "TOOL:" << chKey << "IS DEFAULT AND UNCHECKED";
settings.setValue(chKey,false); settings.setValue(chKey,false);
} }
} }
...@@ -1504,11 +1606,8 @@ void MainWindow::clearView() ...@@ -1504,11 +1606,8 @@ void MainWindow::clearView()
if (dockWidget) if (dockWidget)
{ {
// Remove dock widget from main window // Remove dock widget from main window
//this->removeDockWidget(dockWidget); removeDockWidget(dockWidget);
dockWidget->setVisible(false); //dockWidget->setVisible(false);
// Deletion of dockWidget would also delete all child
// widgets of dockWidget
// Is there a way to unset a widget from QDockWidget?
} }
} }
changingViewsFlag = false; changingViewsFlag = false;
...@@ -1519,9 +1618,8 @@ void MainWindow::loadEngineerView() ...@@ -1519,9 +1618,8 @@ void MainWindow::loadEngineerView()
if (currentView != VIEW_ENGINEER) if (currentView != VIEW_ENGINEER)
{ {
clearView(); clearView();
currentView = VIEW_ENGINEER; currentView = VIEW_ENGINEER;
ui.actionEngineersView->setChecked(true);
presentView(); presentView();
} }
} }
...@@ -1531,9 +1629,19 @@ void MainWindow::loadOperatorView() ...@@ -1531,9 +1629,19 @@ void MainWindow::loadOperatorView()
if (currentView != VIEW_OPERATOR) if (currentView != VIEW_OPERATOR)
{ {
clearView(); clearView();
currentView = VIEW_OPERATOR; currentView = VIEW_OPERATOR;
ui.actionOperatorsView->setChecked(true);
presentView();
}
}
void MainWindow::loadUnconnectedView()
{
if (currentView != VIEW_UNCONNECTED)
{
clearView();
currentView = VIEW_UNCONNECTED;
ui.actionUnconnectedView->setChecked(true);
presentView(); presentView();
} }
} }
...@@ -1543,9 +1651,8 @@ void MainWindow::loadPilotView() ...@@ -1543,9 +1651,8 @@ void MainWindow::loadPilotView()
if (currentView != VIEW_PILOT) if (currentView != VIEW_PILOT)
{ {
clearView(); clearView();
currentView = VIEW_PILOT; currentView = VIEW_PILOT;
ui.actionPilotsView->setChecked(true);
presentView(); presentView();
} }
} }
...@@ -1555,9 +1662,8 @@ void MainWindow::loadMAVLinkView() ...@@ -1555,9 +1662,8 @@ void MainWindow::loadMAVLinkView()
if (currentView != VIEW_MAVLINK) if (currentView != VIEW_MAVLINK)
{ {
clearView(); clearView();
currentView = VIEW_MAVLINK; currentView = VIEW_MAVLINK;
ui.actionMavlinkView->setChecked(true);
presentView(); presentView();
} }
} }
...@@ -1589,7 +1695,6 @@ void MainWindow::presentView() ...@@ -1589,7 +1695,6 @@ void MainWindow::presentView()
showTheCentralWidget(CENTRAL_DATA_PLOT, currentView); showTheCentralWidget(CENTRAL_DATA_PLOT, currentView);
// Show docked widgets based on current view and autopilot type // Show docked widgets based on current view and autopilot type
// UAS CONTROL // UAS CONTROL
...@@ -1664,8 +1769,28 @@ void MainWindow::presentView() ...@@ -1664,8 +1769,28 @@ void MainWindow::presentView()
// MAVLINK LOG PLAYER // MAVLINK LOG PLAYER
showTheWidget(MENU_MAVLINK_LOG_PLAYER, currentView); showTheWidget(MENU_MAVLINK_LOG_PLAYER, currentView);
// VIDEO 1
showTheWidget(MENU_VIDEO_STREAM_1, currentView);
// VIDEO 2
showTheWidget(MENU_VIDEO_STREAM_2, currentView);
this->show(); this->show();
// Restore window state
// if (UASManager::instance()->getUASList().count() > 0)
// {
// // Restore the widget positions and size
// if (settings.contains(getWindowStateKey()))
// {
// restoreState(settings.value(getWindowStateKey()).toByteArray(), QGC::applicationVersion());
// }
if (settings.contains(getWindowGeometryKey()))
{
restoreGeometry(settings.value(getWindowGeometryKey()).toByteArray());
}
// }
} }
void MainWindow::showTheCentralWidget (TOOLS_WIDGET_NAMES centralWidget, VIEW_SECTIONS view) void MainWindow::showTheCentralWidget (TOOLS_WIDGET_NAMES centralWidget, VIEW_SECTIONS view)
...@@ -1673,15 +1798,17 @@ void MainWindow::showTheCentralWidget (TOOLS_WIDGET_NAMES centralWidget, VIEW_SE ...@@ -1673,15 +1798,17 @@ void MainWindow::showTheCentralWidget (TOOLS_WIDGET_NAMES centralWidget, VIEW_SE
bool tempVisible; bool tempVisible;
QWidget* tempWidget = dockWidgets[centralWidget]; QWidget* tempWidget = dockWidgets[centralWidget];
tempVisible = settings.value(buildMenuKey (SUB_SECTION_CHECKED,centralWidget,view), false).toBool(); tempVisible = settings.value(buildMenuKey(SUB_SECTION_CHECKED,centralWidget,view), false).toBool();
//qDebug() << buildMenuKey (SUB_SECTION_CHECKED,centralWidget,view) << tempVisible; qDebug() << buildMenuKey (SUB_SECTION_CHECKED,centralWidget,view) << tempVisible;
if (toolsMenuActions[centralWidget]) if (toolsMenuActions[centralWidget])
{ {
qDebug() << "SETTING TO:" << tempVisible;
toolsMenuActions[centralWidget]->setChecked(tempVisible); toolsMenuActions[centralWidget]->setChecked(tempVisible);
} }
if (centerStack && tempWidget && tempVisible) if (centerStack && tempWidget && tempVisible)
{ {
qDebug() << "ACTIVATING MAIN WIDGET";
centerStack->setCurrentWidget(tempWidget); centerStack->setCurrentWidget(tempWidget);
} }
} }
......
...@@ -112,6 +112,8 @@ public slots: ...@@ -112,6 +112,8 @@ public slots:
void stopVideoCapture(); void stopVideoCapture();
void saveScreen(); void saveScreen();
/** @brief Load default view when no MAV is connected */
void loadUnconnectedView();
/** @brief Load view for pilot */ /** @brief Load view for pilot */
void loadPilotView(); void loadPilotView();
/** @brief Load view for engineer */ /** @brief Load view for engineer */
...@@ -166,7 +168,7 @@ public slots: ...@@ -166,7 +168,7 @@ public slots:
* It shows the QDockedWidget based on the action sender * It shows the QDockedWidget based on the action sender
* *
*/ */
void showToolWidget(); void showToolWidget(bool visible);
/** /**
* @brief Shows a Widget from the center stack based on the action sender * @brief Shows a Widget from the center stack based on the action sender
...@@ -177,8 +179,10 @@ public slots: ...@@ -177,8 +179,10 @@ public slots:
*/ */
void showCentralWidget(); void showCentralWidget();
/** @brief Change actively a QDockWidgets visibility by an action */
void showDockWidget(bool vis);
/** @brief Updates a QDockWidget's checked status based on its visibility */ /** @brief Updates a QDockWidget's checked status based on its visibility */
void updateVisibilitySettings (bool vis); void updateVisibilitySettings(bool vis);
/** @brief Updates a QDockWidget's location */ /** @brief Updates a QDockWidget's location */
void updateLocationSettings (Qt::DockWidgetArea location); void updateLocationSettings (Qt::DockWidgetArea location);
...@@ -187,6 +191,9 @@ protected: ...@@ -187,6 +191,9 @@ protected:
MainWindow(QWidget *parent = 0); MainWindow(QWidget *parent = 0);
/** @brief Set default window settings for the current autopilot type */
void setDefaultSettingsForAp();
// These defines are used to save the settings when selecting with // These defines are used to save the settings when selecting with
// which widgets populate the views // which widgets populate the views
// FIXME: DO NOT PUT CUSTOM VALUES IN THIS ENUM since it is iterated over // FIXME: DO NOT PUT CUSTOM VALUES IN THIS ENUM since it is iterated over
...@@ -240,6 +247,7 @@ protected: ...@@ -240,6 +247,7 @@ protected:
VIEW_OPERATOR, VIEW_OPERATOR,
VIEW_PILOT, VIEW_PILOT,
VIEW_MAVLINK, VIEW_MAVLINK,
VIEW_UNCONNECTED, ///< View in unconnected mode, when no UAS is available
} VIEW_SECTIONS; } VIEW_SECTIONS;
......
...@@ -100,7 +100,7 @@ ...@@ -100,7 +100,7 @@
</widget> </widget>
<widget class="QMenu" name="menuTools"> <widget class="QMenu" name="menuTools">
<property name="title"> <property name="title">
<string>Tools</string> <string>Widgets</string>
</property> </property>
<addaction name="actionNewCustomWidget"/> <addaction name="actionNewCustomWidget"/>
</widget> </widget>
...@@ -121,11 +121,18 @@ ...@@ -121,11 +121,18 @@
<addaction name="actionPilotsView"/> <addaction name="actionPilotsView"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionMavlinkView"/> <addaction name="actionMavlinkView"/>
<addaction name="actionUnconnectedView"/>
</widget>
<widget class="QMenu" name="menuMain">
<property name="title">
<string>Main</string>
</property>
</widget> </widget>
<addaction name="menuMGround"/> <addaction name="menuMGround"/>
<addaction name="menuNetwork"/> <addaction name="menuNetwork"/>
<addaction name="menuConnected_Systems"/> <addaction name="menuConnected_Systems"/>
<addaction name="menuUnmanned_System"/> <addaction name="menuUnmanned_System"/>
<addaction name="menuMain"/>
<addaction name="menuTools"/> <addaction name="menuTools"/>
<addaction name="menuPerspectives"/> <addaction name="menuPerspectives"/>
<addaction name="menuHelp"/> <addaction name="menuHelp"/>
...@@ -296,6 +303,9 @@ ...@@ -296,6 +303,9 @@
<property name="text"> <property name="text">
<string>Operator</string> <string>Operator</string>
</property> </property>
<property name="shortcut">
<string>Meta+O</string>
</property>
</action> </action>
<action name="actionEngineersView"> <action name="actionEngineersView">
<property name="checkable"> <property name="checkable">
...@@ -308,6 +318,9 @@ ...@@ -308,6 +318,9 @@
<property name="text"> <property name="text">
<string>Engineer</string> <string>Engineer</string>
</property> </property>
<property name="shortcut">
<string>Meta+E</string>
</property>
</action> </action>
<action name="actionMavlinkView"> <action name="actionMavlinkView">
<property name="checkable"> <property name="checkable">
...@@ -320,6 +333,9 @@ ...@@ -320,6 +333,9 @@
<property name="text"> <property name="text">
<string>Mavlink</string> <string>Mavlink</string>
</property> </property>
<property name="shortcut">
<string>Meta+M</string>
</property>
</action> </action>
<action name="actionReloadStyle"> <action name="actionReloadStyle">
<property name="icon"> <property name="icon">
...@@ -341,6 +357,9 @@ ...@@ -341,6 +357,9 @@
<property name="text"> <property name="text">
<string>Pilot</string> <string>Pilot</string>
</property> </property>
<property name="shortcut">
<string>Meta+P</string>
</property>
</action> </action>
<action name="actionNewCustomWidget"> <action name="actionNewCustomWidget">
<property name="icon"> <property name="icon">
...@@ -379,6 +398,21 @@ ...@@ -379,6 +398,21 @@
<string>QGroundControl global settings</string> <string>QGroundControl global settings</string>
</property> </property>
</action> </action>
<action name="actionUnconnectedView">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../../mavground.qrc">
<normaloff>:/images/devices/network-wireless.svg</normaloff>:/images/devices/network-wireless.svg</iconset>
</property>
<property name="text">
<string>Unconnected</string>
</property>
<property name="shortcut">
<string>Meta+U</string>
</property>
</action>
</widget> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>
<resources> <resources>
......
...@@ -308,7 +308,7 @@ Pixhawk3DWidget::insertWaypoint(void) ...@@ -308,7 +308,7 @@ Pixhawk3DWidget::insertWaypoint(void)
if (wp) if (wp)
{ {
wp->setFrame(frame); wp->setFrame(frame);
uas->getWaypointManager().addWaypoint(wp); uas->getWaypointManager()->addWaypoint(wp);
} }
} }
} }
...@@ -325,7 +325,7 @@ Pixhawk3DWidget::setWaypoint(void) ...@@ -325,7 +325,7 @@ Pixhawk3DWidget::setWaypoint(void)
if (uas) if (uas)
{ {
const QVector<Waypoint *> waypoints = const QVector<Waypoint *> waypoints =
uas->getWaypointManager().getWaypointList(); uas->getWaypointManager()->getWaypointList();
Waypoint* waypoint = waypoints.at(selectedWpIndex); Waypoint* waypoint = waypoints.at(selectedWpIndex);
if (frame == MAV_FRAME_GLOBAL) if (frame == MAV_FRAME_GLOBAL)
...@@ -366,7 +366,7 @@ Pixhawk3DWidget::deleteWaypoint(void) ...@@ -366,7 +366,7 @@ Pixhawk3DWidget::deleteWaypoint(void)
{ {
if (uas) if (uas)
{ {
uas->getWaypointManager().removeWaypoint(selectedWpIndex); uas->getWaypointManager()->removeWaypoint(selectedWpIndex);
} }
} }
...@@ -377,7 +377,7 @@ Pixhawk3DWidget::setWaypointAltitude(void) ...@@ -377,7 +377,7 @@ Pixhawk3DWidget::setWaypointAltitude(void)
{ {
bool ok; bool ok;
const QVector<Waypoint *> waypoints = const QVector<Waypoint *> waypoints =
uas->getWaypointManager().getWaypointList(); uas->getWaypointManager()->getWaypointList();
Waypoint* waypoint = waypoints.at(selectedWpIndex); Waypoint* waypoint = waypoints.at(selectedWpIndex);
double altitude = waypoint->getZ(); double altitude = waypoint->getZ();
...@@ -409,10 +409,10 @@ Pixhawk3DWidget::clearAllWaypoints(void) ...@@ -409,10 +409,10 @@ Pixhawk3DWidget::clearAllWaypoints(void)
if (uas) if (uas)
{ {
const QVector<Waypoint *> waypoints = const QVector<Waypoint *> waypoints =
uas->getWaypointManager().getWaypointList(); uas->getWaypointManager()->getWaypointList();
for (int i = waypoints.size() - 1; i >= 0; --i) for (int i = waypoints.size() - 1; i >= 0; --i)
{ {
uas->getWaypointManager().removeWaypoint(i); uas->getWaypointManager()->removeWaypoint(i);
} }
} }
} }
......
...@@ -78,7 +78,7 @@ WaypointGroupNode::update(MAV_FRAME frame, UASInterface *uas) ...@@ -78,7 +78,7 @@ WaypointGroupNode::update(MAV_FRAME frame, UASInterface *uas)
removeChild(0, getNumChildren()); removeChild(0, getNumChildren());
} }
const QVector<Waypoint *>& list = uas->getWaypointManager().getWaypointList(); const QVector<Waypoint *>& list = uas->getWaypointManager()->getWaypointList();
for (int i = 0; i < list.size(); i++) for (int i = 0; i < list.size(); i++)
{ {
......
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