Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
c4a59ff7
Commit
c4a59ff7
authored
Oct 14, 2015
by
Don Gagne
Browse files
Merge pull request #1981 from DonLakeFlyer/FloatingWidgets
Dock Widgets only support floating
parents
3643a5e7
28fc38f6
Changes
35
Hide whitespace changes
Inline
Side-by-side
QGCApplication.pro
View file @
c4a59ff7
...
...
@@ -230,6 +230,7 @@ HEADERS += \
src
/
QGCApplication
.
h
\
src
/
QGCComboBox
.
h
\
src
/
QGCConfig
.
h
\
src
/
QGCDockWidget
.
h
\
src
/
QGCFileDialog
.
h
\
src
/
QGCGeo
.
h
\
src
/
QGCLoggingCategory
.
h
\
...
...
@@ -289,7 +290,6 @@ HEADERS += \
src
/
comm
/
QGCHilLink
.
h
\
src
/
comm
/
QGCJSBSimLink
.
h
\
src
/
comm
/
QGCXPlaneLink
.
h
\
src
/
QGCDockWidget
.
h
\
src
/
ui
/
CameraView
.
h
\
src
/
ui
/
HILDockWidget
.
h
\
src
/
ui
/
MultiVehicleDockWidget
.
h
\
...
...
@@ -340,6 +340,7 @@ SOURCES += \
src
/
QGC
.
cc
\
src
/
QGCApplication
.
cc
\
src
/
QGCComboBox
.
cc
\
src
/
QGCDockWidget
.
cc
\
src
/
QGCFileDialog
.
cc
\
src
/
QGCLoggingCategory
.
cc
\
src
/
QGCPalette
.
cc
\
...
...
@@ -393,7 +394,6 @@ SOURCES += \
src
/
comm
/
QGCFlightGearLink
.
cc
\
src
/
comm
/
QGCJSBSimLink
.
cc
\
src
/
comm
/
QGCXPlaneLink
.
cc
\
src
/
QGCDockWidget
.
cc
\
src
/
ui
/
CameraView
.
cc
\
src
/
ui
/
HILDockWidget
.
cc
\
src
/
ui
/
MultiVehicleDockWidget
.
cc
\
...
...
src/FlightDisplay/FlightDisplayView.cc
View file @
c4a59ff7
...
...
@@ -35,7 +35,7 @@ This file is part of the QGROUNDCONTROL project
const
char
*
kMainFlightDisplayViewGroup
=
"FlightDisplayView"
;
FlightDisplayView
::
FlightDisplayView
(
QWidget
*
parent
)
:
QGCQmlWidgetHolder
(
parent
)
:
QGCQmlWidgetHolder
(
QString
(),
NULL
,
parent
)
{
setSizePolicy
(
QSizePolicy
::
MinimumExpanding
,
QSizePolicy
::
MinimumExpanding
);
setObjectName
(
"FlightDisplayView"
);
...
...
src/FlightDisplay/FlightDisplayWidget.cc
View file @
c4a59ff7
...
...
@@ -34,8 +34,8 @@ This file is part of the QGROUNDCONTROL project
const
char
*
kMainFlightDisplayWidgetGroup
=
"FlightDisplayWidget"
;
FlightDisplayWidget
::
FlightDisplayWidget
(
QWidget
*
parent
)
:
QGCQmlWidgetHolder
(
parent
)
FlightDisplayWidget
::
FlightDisplayWidget
(
const
QString
&
title
,
QAction
*
action
,
QWidget
*
parent
)
:
QGCQmlWidgetHolder
(
title
,
action
,
parent
)
{
setSizePolicy
(
QSizePolicy
::
MinimumExpanding
,
QSizePolicy
::
MinimumExpanding
);
setObjectName
(
"FlightDisplayWidget"
);
...
...
@@ -86,6 +86,8 @@ FlightDisplayWidget::FlightDisplayWidget(QWidget *parent)
setSource
(
QUrl
::
fromUserInput
(
"qrc:/qml/FlightDisplayWidget.qml"
));
setVisible
(
true
);
loadSettings
();
}
FlightDisplayWidget
::~
FlightDisplayWidget
()
...
...
src/FlightDisplay/FlightDisplayWidget.h
View file @
c4a59ff7
...
...
@@ -30,7 +30,7 @@ class FlightDisplayWidget : public QGCQmlWidgetHolder
{
Q_OBJECT
public:
FlightDisplayWidget
(
QWidget
*
parent
=
NULL
);
FlightDisplayWidget
(
const
QString
&
title
,
QAction
*
action
,
QWidget
*
parent
=
NULL
);
~
FlightDisplayWidget
();
/// @brief Invokes the Flight Display Options menu
...
...
src/MissionEditor/MissionEditor.cc
View file @
c4a59ff7
...
...
@@ -35,7 +35,7 @@ This file is part of the QGROUNDCONTROL project
const
char
*
MissionEditor
::
_settingsGroup
=
"MissionEditor"
;
MissionEditor
::
MissionEditor
(
QWidget
*
parent
)
:
QGCQmlWidgetHolder
(
parent
)
:
QGCQmlWidgetHolder
(
QString
(),
NULL
,
parent
)
,
_missionItems
(
NULL
)
,
_canEdit
(
true
)
{
...
...
src/QGCDockWidget.cc
View file @
c4a59ff7
...
...
@@ -24,24 +24,51 @@
#include
"QGCDockWidget.h"
#include
<QCloseEvent>
#include
<QSettings>
QGCDockWidget
::
QGCDockWidget
(
const
QString
&
title
,
QAction
*
action
,
QWidget
*
parent
,
Qt
::
WindowFlags
flags
)
:
QDockWidget
(
title
,
parent
,
flags
),
_action
(
action
)
const
char
*
QGCDockWidget
::
_settingsGroup
=
"DockWidgets"
;
QGCDockWidget
::
QGCDockWidget
(
const
QString
&
title
,
QAction
*
action
,
QWidget
*
parent
)
:
QWidget
(
parent
)
,
_title
(
title
)
,
_action
(
action
)
{
QDockWidget
::
DockWidgetFeatures
features
=
QDockWidget
::
DockWidgetMovable
;
if
(
action
)
{
features
|=
QDockWidget
::
DockWidgetClosable
;
}
setFeatures
(
features
);
if
(
action
)
{
setWindowTitle
(
title
);
setWindowFlags
(
Qt
::
Tool
);
loadSettings
();
}
}
// Instead of destroying the widget just hide it
void
QGCDockWidget
::
closeEvent
(
QCloseEvent
*
event
)
{
Q_ASSERT
(
_action
);
event
->
ignore
();
_action
->
trigger
();
if
(
_action
)
{
saveSettings
();
event
->
ignore
();
_action
->
trigger
();
}
}
void
QGCDockWidget
::
loadSettings
(
void
)
{
if
(
_action
)
{
QSettings
settings
;
settings
.
beginGroup
(
_settingsGroup
);
if
(
settings
.
contains
(
_title
))
{
restoreGeometry
(
settings
.
value
(
_title
).
toByteArray
());
}
}
}
void
QGCDockWidget
::
saveSettings
(
void
)
{
if
(
_action
)
{
QSettings
settings
;
settings
.
beginGroup
(
_settingsGroup
);
settings
.
setValue
(
_title
,
saveGeometry
());
}
}
src/QGCDockWidget.h
View file @
c4a59ff7
...
...
@@ -27,21 +27,22 @@
#include
<QDockWidget>
#include
<QAction>
/// @file
/// @brief Subclass of QDockWidget so we can intercept the closeEvent.
///
/// @author Don Gagne <don@thegagnes.com>
class
QGCDockWidget
:
public
QDockWidget
{
class
QGCDockWidget
:
public
QWidget
{
Q_OBJECT
public:
QGCDockWidget
(
const
QString
&
title
,
QAction
*
action
,
QWidget
*
parent
=
0
,
Qt
::
WindowFlags
flags
=
0
);
/// Pass in title = QString() and action = NULL when just using as a regular widget
QGCDockWidget
(
const
QString
&
title
,
QAction
*
action
,
QWidget
*
parent
=
0
);
void
loadSettings
(
void
);
void
saveSettings
(
void
);
void
closeEvent
(
QCloseEvent
*
event
);
private:
QAction
*
_action
;
protected:
QString
_title
;
QAction
*
_action
;
static
const
char
*
_settingsGroup
;
};
...
...
src/QGCQmlWidgetHolder.cpp
View file @
c4a59ff7
...
...
@@ -26,10 +26,14 @@
#include
"QGCQmlWidgetHolder.h"
QGCQmlWidgetHolder
::
QGCQmlWidgetHolder
(
QWidget
*
parent
)
:
QWidget
(
parent
)
QGCQmlWidgetHolder
::
QGCQmlWidgetHolder
(
const
QString
&
title
,
QAction
*
action
,
QWidget
*
parent
)
:
Q
GCDock
Widget
(
title
,
action
,
parent
)
{
_ui
.
setupUi
(
this
);
if
(
action
)
{
setWindowTitle
(
title
);
}
setResizeMode
(
QQuickWidget
::
SizeRootObjectToView
);
}
...
...
src/QGCQmlWidgetHolder.h
View file @
c4a59ff7
...
...
@@ -27,10 +27,10 @@
/// @file
/// @author Don Gagne <don@thegagnes.com>
#include
<QWidget>
#include
"QGCDockWidget.h"
#include
"AutoPilotPlugin.h"
#include
"ui_QGCQmlWidgetHolder.h"
#include
"AutoPilotPlugin.h"
namespace
Ui
{
class
QGCQmlWidgetHolder
;
...
...
@@ -38,12 +38,16 @@ class QGCQmlWidgetHolder;
/// This is used to create widgets which are implemented in QML.
class
QGCQmlWidgetHolder
:
public
QWidget
class
QGCQmlWidgetHolder
:
public
Q
GCDock
Widget
{
Q_OBJECT
public:
explicit
QGCQmlWidgetHolder
(
QWidget
*
parent
=
0
);
// This has a title and action since the base class is QGCDockWidget. In order to use this
// control as a normal QWidget, not a doc widget just pass in:
// title = QString()
// action = NULL
explicit
QGCQmlWidgetHolder
(
const
QString
&
title
,
QAction
*
action
,
QWidget
*
parent
=
0
);
~
QGCQmlWidgetHolder
();
/// Sets the UAS into the widget which in turn will load facts into the context
...
...
src/QmlControls/QmlTestWidget.cc
View file @
c4a59ff7
...
...
@@ -27,6 +27,7 @@
#include
"QmlTestWidget.h"
QmlTestWidget
::
QmlTestWidget
(
void
)
:
QGCQmlWidgetHolder
(
QString
(),
NULL
,
NULL
)
{
setAttribute
(
Qt
::
WA_DeleteOnClose
);
resize
(
900
,
500
);
...
...
src/QmlControls/ScreenToolsController.cc
View file @
c4a59ff7
...
...
@@ -55,7 +55,7 @@ void ScreenToolsController::_updateCanvas()
double
ScreenToolsController
::
getQmlDefaultFontPixelSize
(
void
)
{
if
(
_qmlDefaultFontPixelSize
==
-
1
)
{
QGCQmlWidgetHolder
qmlWidgetHolder
;
QGCQmlWidgetHolder
qmlWidgetHolder
(
QString
(),
NULL
)
;
qmlWidgetHolder
.
setSource
(
QUrl
::
fromUserInput
(
"qrc:/qml/ScreenToolsFontQuery.qml"
));
}
...
...
src/VehicleSetup/SetupView.cc
View file @
c4a59ff7
...
...
@@ -41,7 +41,7 @@
#include
<QDebug>
SetupView
::
SetupView
(
QWidget
*
parent
)
:
QGCQmlWidgetHolder
(
parent
)
QGCQmlWidgetHolder
(
QString
(),
NULL
,
parent
)
{
setSource
(
QUrl
::
fromUserInput
(
"qrc:/qml/SetupView.qml"
));
}
...
...
src/ViewWidgets/CustomCommandWidget.cc
View file @
c4a59ff7
...
...
@@ -23,8 +23,12 @@ This file is part of the QGROUNDCONTROL project
#include
"CustomCommandWidget.h"
CustomCommandWidget
::
CustomCommandWidget
(
QWidget
*
parent
)
:
QGCQmlWidgetHolder
(
parent
)
CustomCommandWidget
::
CustomCommandWidget
(
const
QString
&
title
,
QAction
*
action
,
QWidget
*
parent
)
:
QGCQmlWidgetHolder
(
title
,
action
,
parent
)
{
Q_UNUSED
(
title
);
Q_UNUSED
(
action
);
setSource
(
QUrl
::
fromUserInput
(
"qrc:/qml/CustomCommandWidget.qml"
));
loadSettings
();
}
src/ViewWidgets/CustomCommandWidget.h
View file @
c4a59ff7
...
...
@@ -34,7 +34,7 @@ class CustomCommandWidget : public QGCQmlWidgetHolder
Q_OBJECT
public:
CustomCommandWidget
(
QWidget
*
parent
=
0
);
CustomCommandWidget
(
const
QString
&
title
,
QAction
*
action
,
QWidget
*
parent
=
0
);
};
#endif
src/qgcunittest/PX4RCCalibrationTest.cc
View file @
c4a59ff7
...
...
@@ -164,7 +164,7 @@ void RadioConfigTest::init(void)
Q_ASSERT
(
_autopilot
);
// This will instatiate the widget with an active uas with ready parameters
_calWidget
=
new
QGCQmlWidgetHolder
();
_calWidget
=
new
QGCQmlWidgetHolder
(
QString
(),
NULL
);
_calWidget
->
resize
(
600
,
600
);
Q_CHECK_PTR
(
_calWidget
);
_calWidget
->
setAutoPilot
(
_autopilot
);
...
...
src/ui/HILDockWidget.cc
View file @
c4a59ff7
...
...
@@ -24,10 +24,12 @@
#include
"HILDockWidget.h"
#include
"QGCHilConfiguration.h"
HILDockWidget
::
HILDockWidget
(
QWidget
*
parent
)
:
MultiVehicleDockWidget
(
parent
)
HILDockWidget
::
HILDockWidget
(
const
QString
&
title
,
QAction
*
action
,
QWidget
*
parent
)
:
MultiVehicleDockWidget
(
title
,
action
,
parent
)
{
init
();
loadSettings
();
}
HILDockWidget
::~
HILDockWidget
()
...
...
src/ui/HILDockWidget.h
View file @
c4a59ff7
...
...
@@ -31,7 +31,7 @@ class HILDockWidget : public MultiVehicleDockWidget
Q_OBJECT
public:
explicit
HILDockWidget
(
QWidget
*
parent
=
0
);
explicit
HILDockWidget
(
const
QString
&
title
,
QAction
*
action
,
QWidget
*
parent
=
0
);
~
HILDockWidget
();
protected:
...
...
src/ui/MainWindow.cc
View file @
c4a59ff7
...
...
@@ -88,14 +88,15 @@ This file is part of the QGROUNDCONTROL project
const
char
*
MAIN_SETTINGS_GROUP
=
"QGC_MAINWINDOW"
;
#ifndef __mobile__
const
char
*
MainWindow
::
_mavlinkDockWidgetName
=
"MAVLINK_INSPECTOR_DOCKWIDGET"
;
const
char
*
MainWindow
::
_customCommandWidgetName
=
"CUSTOM_COMMAND_DOCKWIDGET"
;
const
char
*
MainWindow
::
_filesDockWidgetName
=
"FILE_VIEW_DOCKWIDGET"
;
const
char
*
MainWindow
::
_uasStatusDetailsDockWidgetName
=
"UAS_STATUS_DETAILS_DOCKWIDGET"
;
const
char
*
MainWindow
::
_mapViewDockWidgetName
=
"MAP_VIEW_DOCKWIDGET"
;
const
char
*
MainWindow
::
_pfdDockWidgetName
=
"PRIMARY_FLIGHT_DISPLAY_DOCKWIDGET"
;
const
char
*
MainWindow
::
_uasInfoViewDockWidgetName
=
"UAS_INFO_INFOVIEW_DOCKWIDGET"
;
const
char
*
MainWindow
::
_hilDockWidgetName
=
"HIL_DOCKWIDGET"
;
const
char
*
MainWindow
::
_mavlinkDockWidgetName
=
"MAVLink Inspector"
;
const
char
*
MainWindow
::
_customCommandWidgetName
=
"Custom Command"
;
const
char
*
MainWindow
::
_filesDockWidgetName
=
"Onboard Files"
;
const
char
*
MainWindow
::
_uasStatusDetailsDockWidgetName
=
"Status Details"
;
const
char
*
MainWindow
::
_pfdDockWidgetName
=
"Primary Flight Display"
;
const
char
*
MainWindow
::
_uasInfoViewDockWidgetName
=
"Info View"
;
const
char
*
MainWindow
::
_hilDockWidgetName
=
"HIL Config"
;
const
char
*
MainWindow
::
_visibleWidgetsKey
=
"VisibleWidgets"
;
#endif
static
MainWindow
*
_instance
=
NULL
;
///< @brief MainWindow singleton
...
...
@@ -313,6 +314,10 @@ MainWindow::MainWindow(QSplashScreen* splashScreen)
qd
.
close
();
#endif
}
#ifndef __mobile__
_loadVisibleWidgetsSettings
();
#endif
}
MainWindow
::~
MainWindow
()
...
...
@@ -341,34 +346,6 @@ QString MainWindow::_getWindowGeometryKey()
}
#ifndef __mobile__
void
MainWindow
::
_createDockWidget
(
const
QString
&
title
,
const
QString
&
name
,
Qt
::
DockWidgetArea
area
,
QWidget
*
innerWidget
)
{
Q_ASSERT
(
!
_mapName2DockWidget
.
contains
(
name
));
// Add to menu
QAction
*
action
=
new
QAction
(
title
,
NULL
);
action
->
setCheckable
(
true
);
action
->
setData
(
name
);
connect
(
action
,
&
QAction
::
triggered
,
this
,
&
MainWindow
::
_showDockWidgetAction
);
_ui
.
menuWidgets
->
addAction
(
action
);
// Create widget
QGCDockWidget
*
dockWidget
=
new
QGCDockWidget
(
title
,
action
,
this
);
Q_CHECK_PTR
(
dockWidget
);
dockWidget
->
setObjectName
(
name
);
dockWidget
->
setVisible
(
false
);
if
(
innerWidget
)
{
// Put inner widget inside QDockWidget
innerWidget
->
setParent
(
dockWidget
);
dockWidget
->
setWidget
(
innerWidget
);
innerWidget
->
setVisible
(
true
);
}
_mapName2DockWidget
[
name
]
=
dockWidget
;
_mapDockWidget2Action
[
dockWidget
]
=
action
;
addDockWidget
(
area
,
dockWidget
);
}
void
MainWindow
::
_buildCommonWidgets
(
void
)
{
// Add generic MAVLink decoder
...
...
@@ -382,99 +359,80 @@ void MainWindow::_buildCommonWidgets(void)
logPlayer
=
new
QGCMAVLinkLogPlayer
(
statusBar
());
statusBar
()
->
addPermanentWidget
(
logPlayer
);
// In order for Qt to save and restore state of widgets all widgets must be created ahead of time. We only create the QDockWidget
// holders. We do not create the actual inner widget until it is needed. This saves memory and cpu from running widgets that are
// never shown.
struct
DockWidgetInfo
{
const
char
*
name
;
const
char
*
title
;
Qt
::
DockWidgetArea
area
;
};
static
const
struct
DockWidgetInfo
rgDockWidgetInfo
[]
=
{
{
_mavlinkDockWidgetName
,
"MAVLink Inspector"
,
Qt
::
RightDockWidgetArea
},
{
_customCommandWidgetName
,
"Custom Command"
,
Qt
::
RightDockWidgetArea
},
{
_filesDockWidgetName
,
"Onboard Files"
,
Qt
::
RightDockWidgetArea
},
{
_uasStatusDetailsDockWidgetName
,
"Status Details"
,
Qt
::
RightDockWidgetArea
},
{
_mapViewDockWidgetName
,
"Map view"
,
Qt
::
RightDockWidgetArea
},
{
_pfdDockWidgetName
,
"Primary Flight Display"
,
Qt
::
RightDockWidgetArea
},
{
_uasInfoViewDockWidgetName
,
"Info View"
,
Qt
::
LeftDockWidgetArea
},
{
_hilDockWidgetName
,
"HIL Config"
,
Qt
::
LeftDockWidgetArea
},
static
const
char
*
rgDockWidgetNames
[]
=
{
_mavlinkDockWidgetName
,
_customCommandWidgetName
,
_filesDockWidgetName
,
_uasStatusDetailsDockWidgetName
,
_pfdDockWidgetName
,
_uasInfoViewDockWidgetName
,
_hilDockWidgetName
,
};
static
const
size_t
cDockWidget
Info
=
sizeof
(
rgDockWidget
Info
)
/
sizeof
(
rgDockWidget
Info
[
0
]);
static
const
size_t
cDockWidget
Names
=
sizeof
(
rgDockWidget
Names
)
/
sizeof
(
rgDockWidget
Names
[
0
]);
for
(
size_t
i
=
0
;
i
<
cDockWidgetInfo
;
i
++
)
{
const
struct
DockWidgetInfo
*
pDockInfo
=
&
rgDockWidgetInfo
[
i
];
_createDockWidget
(
pDockInfo
->
title
,
pDockInfo
->
name
,
pDockInfo
->
area
,
NULL
/* no inner widget yet */
);
for
(
size_t
i
=
0
;
i
<
cDockWidgetNames
;
i
++
)
{
const
char
*
pDockWidgetName
=
rgDockWidgetNames
[
i
];
// Add to menu
QAction
*
action
=
new
QAction
(
pDockWidgetName
,
NULL
);
action
->
setCheckable
(
true
);
action
->
setData
(
pDockWidgetName
);
connect
(
action
,
&
QAction
::
triggered
,
this
,
&
MainWindow
::
_showDockWidgetAction
);
_ui
.
menuWidgets
->
addAction
(
action
);
_mapName2Action
[
pDockWidgetName
]
=
action
;
}
}
/// Shows or hides the specified dock widget, creating if necessary
void
MainWindow
::
_showDockWidget
(
const
QString
&
name
,
bool
show
)
{
if
(
!
_mapName2DockWidget
.
contains
(
name
))
{
// Don't show any sort of warning here. Dock Widgets which have been remove could still be in settings.
// Which would cause us to end up here.
return
;
}
// Create the inner widget if we need to
if
(
!
_mapName2DockWidget
[
name
]
->
widget
(
))
{
if
(
!
_mapName2DockWidget
.
contains
(
name
))
{
_createInnerDockWidget
(
name
);
}
Q_ASSERT
(
_mapName2DockWidget
.
contains
(
name
));
QDockWidget
*
dockWidget
=
_mapName2DockWidget
[
name
];
Q
GC
DockWidget
*
dockWidget
=
_mapName2DockWidget
[
name
];
Q_ASSERT
(
dockWidget
);
dockWidget
->
setVisible
(
show
);
Q_ASSERT
(
_map
DockWidget
2Action
.
contains
(
dockWidget
));
_map
DockWidget2Action
[
dockWidget
]
->
setChecked
(
show
);
Q_ASSERT
(
_map
Name
2Action
.
contains
(
name
));
_map
Name2Action
[
name
]
->
setChecked
(
show
);
}
/// Creates the specified inner dock widget and adds to the QDockWidget
void
MainWindow
::
_createInnerDockWidget
(
const
QString
&
widgetName
)
{
Q_ASSERT
(
_mapName2DockWidget
.
contains
(
widgetName
));
// QDockWidget should already exist
Q_ASSERT
(
!
_mapName2DockWidget
[
widgetName
]
->
widget
());
// Inner widget should not
QWidget
*
widget
=
NULL
;
QGCDockWidget
*
widget
=
NULL
;
if
(
widgetName
==
_mavlinkDockWidgetName
)
{
widget
=
new
QGCMAVLinkInspector
(
MAVLinkProtocol
::
instance
(),
this
);
widget
=
new
QGCMAVLinkInspector
(
widgetName
,
_mapName2Action
[
widgetName
],
MAVLinkProtocol
::
instance
(),
this
);
}
else
if
(
widgetName
==
_customCommandWidgetName
)
{
widget
=
new
CustomCommandWidget
(
this
);
widget
=
new
CustomCommandWidget
(
widgetName
,
_mapName2Action
[
widgetName
],
this
);
}
else
if
(
widgetName
==
_filesDockWidgetName
)
{
widget
=
new
QGCUASFileViewMulti
(
this
);
widget
=
new
QGCUASFileViewMulti
(
widgetName
,
_mapName2Action
[
widgetName
],
this
);
}
else
if
(
widgetName
==
_uasStatusDetailsDockWidgetName
)
{
widget
=
new
UASInfoWidget
(
this
);
widget
=
new
UASInfoWidget
(
widgetName
,
_mapName2Action
[
widgetName
],
this
);
}
else
if
(
widgetName
==
_pfdDockWidgetName
)
{
widget
=
new
FlightDisplayWidget
(
this
);
#ifndef __mobile__
widget
=
new
FlightDisplayWidget
(
widgetName
,
_mapName2Action
[
widgetName
],
this
);
}
else
if
(
widgetName
==
_hilDockWidgetName
)
{
widget
=
new
HILDockWidget
(
this
);
#endif
widget
=
new
HILDockWidget
(
widgetName
,
_mapName2Action
[
widgetName
],
this
);
}
else
if
(
widgetName
==
_uasInfoViewDockWidgetName
)
{
QGCTabbedInfoView
*
pInfoView
=
new
QGCTabbedInfoView
(
this
);
QGCTabbedInfoView
*
pInfoView
=
new
QGCTabbedInfoView
(
widgetName
,
_mapName2Action
[
widgetName
],
this
);
pInfoView
->
addSource
(
mavlinkDecoder
);
widget
=
pInfoView
;
}
else
{
qWarning
()
<<
"Attempt to create unknown Inner Dock Widget"
<<
widgetName
;
}
if
(
widget
)
{
QDockWidget
*
dockWidget
=
_mapName2DockWidget
[
widgetName
];
Q_CHECK_PTR
(
dockWidget
);
widget
->
setParent
(
dockWidget
);
dockWidget
->
setWidget
(
widget
);
}
_mapName2DockWidget
[
widgetName
]
=
widget
;
}
void
MainWindow
::
_hideAllDockWidgets
(
void
)
{
foreach
(
QDockWidget
*
dockWidget
,
_mapName2DockWidget
)
{
foreach
(
Q
GC
DockWidget
*
dockWidget
,
_mapName2DockWidget
)
{
dockWidget
->
setVisible
(
false
);
}
}
...
...
@@ -483,7 +441,7 @@ void MainWindow::_showDockWidgetAction(bool show)
{
QAction
*
action
=
dynamic_cast
<
QAction
*>
(
QObject
::
sender
());
Q_ASSERT
(
action
);
_showDockWidget
(
action
->
data
().
toString
(),
show
);
_showDockWidget
(
action
->
text
(),
show
);
}
#endif
...
...
@@ -592,6 +550,10 @@ void MainWindow::storeSettings()
// Save the last current view in any case
settings
.
setValue
(
"CURRENT_VIEW"
,
_currentView
);
settings
.
setValue
(
_getWindowStateKey
(),
saveState
());
#ifndef __mobile__
_storeVisibleWidgetsSettings
();
#endif
}
void
MainWindow
::
configureWindowName
()
...
...
@@ -751,20 +713,11 @@ void MainWindow::_vehicleAdded(Vehicle* vehicle)
void
MainWindow
::
_storeCurrentViewState
(
void
)
{
#ifndef __mobile__
// Save list of visible widgets
bool
firstWidget
=
true
;
QString
widgetNames
=
""
;
foreach
(
QDockWidget
*
dockWidget
,
_mapName2DockWidget
)
{
if
(
dockWidget
->
isVisible
())
{
if
(
!
firstWidget
)
{
widgetNames
+=
","
;
}
widgetNames
+=
dockWidget
->
objectName
();
firstWidget
=
false
;
}
foreach
(
QGCDockWidget
*
dockWidget
,
_mapName2DockWidget
)
{
dockWidget
->
saveSettings
();
}
settings
.
setValue
(
_getWindowStateKey
()
+
"WIDGETS"
,
widgetNames
);
#endif
settings
.
setValue
(
_getWindowStateKey
(),
saveState
());
settings
.
setValue
(
_getWindowGeometryKey
(),
saveGeometry
());
}
...
...
@@ -773,7 +726,6 @@ void MainWindow::_storeCurrentViewState(void)
void
MainWindow
::
_loadCurrentViewState
(
void
)
{
QWidget
*
centerView
=
NULL
;
QString
defaultWidgets
;
switch
(
_currentView
)
{
case
VIEW_SETUP
:
...
...
@@ -784,13 +736,11 @@ void MainWindow::_loadCurrentViewState(void)
case
VIEW_ANALYZE
:
_buildAnalyzeView
();
centerView
=
_analyzeView
;
defaultWidgets
=
"PARAMETER_INTERFACE_DOCKWIDGET,FILE_VIEW_DOCKWIDGET"
;
break
;
case
VIEW_FLIGHT
:
_buildFlightView
();
centerView
=
_flightView
;
defaultWidgets
=
"COMMUNICATION_CONSOLE_DOCKWIDGET,UAS_INFO_INFOVIEW_DOCKWIDGET"
;
break
;
case
VIEW_MISSIONEDITOR
:
...
...
@@ -820,22 +770,6 @@ void MainWindow::_loadCurrentViewState(void)
_centralLayout
->
setContentsMargins
(
0
,
0
,
0
,
0
);
_currentViewWidget
->
setVisible
(
true
);
#ifndef __mobile__
// Hide all widgets from previous view
_hideAllDockWidgets
();
// Restore the widgets for the new view
QString
widgetNames
=
settings
.
value
(
_getWindowStateKey
()
+
"WIDGETS"
,
defaultWidgets
).
toString
();
qDebug
()
<<
widgetNames
;
if
(
!
widgetNames
.
isEmpty
())
{
QStringList
split
=
widgetNames
.
split
(
","
);
foreach
(
QString
widgetName
,
split
)
{
Q_ASSERT
(
!
widgetName
.
isEmpty
());
_showDockWidget
(
widgetName
,
true
);
}
}
#endif
if
(
settings
.
contains
(
_getWindowStateKey
()))
{
restoreState
(
settings
.
value
(
_getWindowStateKey
()).
toByteArray
());
}
...
...
@@ -949,3 +883,42 @@ void MainWindow::_showQmlTestWidget(void)
new
QmlTestWidget
();
}
#endif
#ifndef __mobile__
void
MainWindow
::
_loadVisibleWidgetsSettings
(
void
)
{
QSettings
settings
;
QString
widgets
=
settings
.
value
(
_visibleWidgetsKey
).
toString
();
if
(
!
widgets
.
isEmpty
())
{
QStringList
nameList
=
widgets
.
split
(
","
);
foreach
(
QString
name
,
nameList
)
{
_showDockWidget
(
name
,
true
);
}
}
}
void
MainWindow
::
_storeVisibleWidgetsSettings
(
void
)
{
QString
widgetNames
;
bool
firstWidget
=
true
;
foreach
(
QString
name
,
_mapName2DockWidget
.
keys
())
{
if
(
_mapName2DockWidget
[
name
]
->
isVisible
())
{
if
(
!
firstWidget
)
{
widgetNames
+=
","
;
}
else
{
firstWidget
=
false
;
}
widgetNames
+=
name
;
}
}
QSettings
settings
;
settings
.
setValue
(
_visibleWidgetsKey
,
widgetNames
);
}
#endif
src/ui/MainWindow.h
View file @
c4a59ff7
...
...
@@ -35,24 +35,26 @@ This file is part of the QGROUNDCONTROL project
#include
<QStatusBar>
#include
<QStackedWidget>
#include
<QSettings>
#include
<
ql
ist
.h
>
#include
<
QL
ist>
#include
"ui_MainWindow.h"
#include
"LinkManager.h"
#include
"LinkInterface.h"
#include
"UASInterface.h"
#include
"CameraView.h"
#if (defined QGC_MOUSE_ENABLED_WIN) | (defined QGC_MOUSE_ENABLED_LINUX)
#include
"Mouse6dofInput.h"
#endif // QGC_MOUSE_ENABLED_WIN
#include
"MainToolBar.h"
#include
"LogCompressor.h"
#include
"FlightDisplayView.h"
#include
"QGCMAVLinkInspector.h"
#include
"QGCMAVLinkLogPlayer.h"
#include
"MAVLinkDecoder.h"
#include
"Vehicle.h"
#include
"QGCDockWidget.h"
#if (defined QGC_MOUSE_ENABLED_WIN) | (defined QGC_MOUSE_ENABLED_LINUX)
#include
"Mouse6dofInput.h"
#endif // QGC_MOUSE_ENABLED_WIN
class
QGCFirmwareUpdate
;
class
QSplashScreen
;
...
...
@@ -270,13 +272,12 @@ private:
static
const
char
*
_customCommandWidgetName
;
static
const
char
*
_filesDockWidgetName
;
static
const
char
*
_uasStatusDetailsDockWidgetName
;
static
const
char
*
_mapViewDockWidgetName
;
static
const
char
*
_pfdDockWidgetName
;
static
const
char
*
_uasInfoViewDockWidgetName
;
static
const
char
*
_hilDockWidgetName
;
QMap
<
QString
,
QDockWidget
*>
_mapName2DockWidget
;
QMap
<
Q
DockWidget
*
,
QAction
*>
_map
DockWidget
2Action
;
QMap
<
QString
,
Q
GC
DockWidget
*>
_mapName2DockWidget
;
QMap
<
Q
String
,
QAction
*>
_map
Name
2Action
;
#endif
void
_buildPlanView
(
void
);
...
...
@@ -290,11 +291,14 @@ private:
void
_loadCurrentViewState
(
void
);
#ifndef __mobile__
void
_createDockWidget
(
const
QString
&
title
,
const
QString
&
name
,
Qt
::
DockWidgetArea
area
,
QWidget
*
innerWidget
);
void
_createInnerDockWidget
(
const
QString
&
widgetName
);
void
_buildCommonWidgets
(
void
);
void
_hideAllDockWidgets
(
void
);
void
_showDockWidget
(
const
QString
&
name
,
bool
show
);
void
_loadVisibleWidgetsSettings
(
void
);
void
_storeVisibleWidgetsSettings
(
void
);
static
const
char
*
_visibleWidgetsKey
;
#endif
bool
_autoReconnect
;
...
...
src/ui/MultiVehicleDockWidget.cc
View file @
c4a59ff7
...
...
@@ -25,12 +25,14 @@
#include
"ui_MultiVehicleDockWidget.h"
#include
"MultiVehicleManager.h"
MultiVehicleDockWidget
::
MultiVehicleDockWidget
(
QWidget
*
parent
)
:
QWidget
(
parent
)
MultiVehicleDockWidget
::
MultiVehicleDockWidget
(
const
QString
&
title
,
QAction
*
action
,
QWidget
*
parent
)
:
Q
GCDock
Widget
(
title
,
action
,
parent
)
,
_ui
(
new
Ui
::
MultiVehicleDockWidget
)
{
_ui
->
setupUi
(
this
);
setWindowTitle
(
title
);
connect
(
MultiVehicleManager
::
instance
(),
&
MultiVehicleManager
::
activeVehicleChanged
,
this
,
&
MultiVehicleDockWidget
::
_activeVehicleChanged
);
connect
(
MultiVehicleManager
::
instance
(),
&
MultiVehicleManager
::
vehicleAdded
,
this
,
&
MultiVehicleDockWidget
::
_vehicleAdded
);
connect
(
MultiVehicleManager
::
instance
(),
&
MultiVehicleManager
::
vehicleRemoved
,
this
,
&
MultiVehicleDockWidget
::
_vehicleRemoved
);
...
...
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment