Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
e390054d
Commit
e390054d
authored
Feb 17, 2017
by
Gus Grubba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow replacing instrument widget with custom widget
parent
dd4de906
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
92 additions
and
14 deletions
+92
-14
FlightDisplayViewWidgets.qml
src/FlightDisplay/FlightDisplayViewWidgets.qml
+39
-12
QGCOptions.cc
src/api/QGCOptions.cc
+19
-0
QGCOptions.h
src/api/QGCOptions.h
+32
-0
AppSettings.qml
src/ui/AppSettings.qml
+2
-2
No files found.
src/FlightDisplay/FlightDisplayViewWidgets.qml
View file @
e390054d
...
...
@@ -15,12 +15,12 @@ import QtQuick.Dialogs 1.2
import
QtLocation
5.3
import
QtPositioning
5.2
import
QGroundControl
1.0
import
QGroundControl
.
ScreenTools
1.0
import
QGroundControl
.
Controls
1.0
import
QGroundControl
.
Palette
1.0
import
QGroundControl
.
Vehicle
1.0
import
QGroundControl
.
FlightMap
1.0
import
QGroundControl
1.0
import
QGroundControl
.
ScreenTools
1.0
import
QGroundControl
.
Controls
1.0
import
QGroundControl
.
Palette
1.0
import
QGroundControl
.
Vehicle
1.0
import
QGroundControl
.
FlightMap
1.0
Item
{
id
:
_root
...
...
@@ -48,13 +48,29 @@ Item {
}
function
_setInstrumentWidget
()
{
var
useAlternateInstruments
=
QGroundControl
.
virtualTabletJoystick
||
ScreenTools
.
isTinyScreen
if
(
useAlternateInstruments
)
{
instrumentsLoader
.
source
=
"
qrc:/qml/QGCInstrumentWidgetAlternate.qml
"
instrumentsLoader
.
state
=
"
topMode
"
if
(
QGroundControl
.
corePlugin
.
options
.
instrumentWidget
.
source
.
toString
().
length
)
{
instrumentsLoader
.
source
=
QGroundControl
.
corePlugin
.
options
.
instrumentWidget
.
source
switch
(
QGroundControl
.
corePlugin
.
options
.
instrumentWidget
.
widgetPosition
)
{
case
CustomInstrumentWidget.POS_TOP_RIGHT
:
instrumentsLoader
.
state
=
"
topMode
"
break
;
case
CustomInstrumentWidget.POS_BOTTOM_RIGHT
:
instrumentsLoader
.
state
=
"
bottomMode
"
break
;
case
CustomInstrumentWidget.POS_CENTER_RIGHT
:
default
:
instrumentsLoader
.
state
=
"
centerMode
"
break
;
}
}
else
{
instrumentsLoader
.
source
=
"
qrc:/qml/QGCInstrumentWidget.qml
"
instrumentsLoader
.
state
=
"
centerMode
"
var
useAlternateInstruments
=
QGroundControl
.
virtualTabletJoystick
||
ScreenTools
.
isTinyScreen
if
(
useAlternateInstruments
)
{
instrumentsLoader
.
source
=
"
qrc:/qml/QGCInstrumentWidgetAlternate.qml
"
instrumentsLoader
.
state
=
"
topMode
"
}
else
{
instrumentsLoader
.
source
=
"
qrc:/qml/QGCInstrumentWidget.qml
"
instrumentsLoader
.
state
=
"
centerMode
"
}
}
}
...
...
@@ -108,6 +124,7 @@ Item {
AnchorChanges
{
target
:
instrumentsLoader
anchors.verticalCenter
:
undefined
anchors.bottom
:
undefined
anchors.top
:
_root
?
_root
.
top
:
undefined
}
},
...
...
@@ -116,8 +133,18 @@ Item {
AnchorChanges
{
target
:
instrumentsLoader
anchors.top
:
undefined
anchors.bottom
:
undefined
anchors.verticalCenter
:
_root
?
_root
.
verticalCenter
:
undefined
}
},
State
{
name
:
"
bottomMode
"
AnchorChanges
{
target
:
instrumentsLoader
anchors.top
:
undefined
anchors.verticalCenter
:
undefined
anchors.bottom
:
_root
?
_root
.
bottom
:
undefined
}
}
]
}
...
...
src/api/QGCOptions.cc
View file @
e390054d
...
...
@@ -8,6 +8,7 @@
****************************************************************************/
#include "QGCOptions.h"
#include <QtQml>
/// @file
/// @brief Core Plugin Interface for QGroundControl - Application Options
...
...
@@ -15,5 +16,23 @@
QGCOptions
::
QGCOptions
(
QObject
*
parent
)
:
QObject
(
parent
)
,
_defaultInstrumentWidget
(
NULL
)
{
qmlRegisterUncreatableType
<
CustomInstrumentWidget
>
(
"QGroundControl"
,
1
,
0
,
"CustomInstrumentWidget"
,
"Reference only"
);
}
CustomInstrumentWidget
*
QGCOptions
::
instrumentWidget
()
{
if
(
!
_defaultInstrumentWidget
)
{
_defaultInstrumentWidget
=
new
CustomInstrumentWidget
(
this
);
}
return
_defaultInstrumentWidget
;
}
CustomInstrumentWidget
::
CustomInstrumentWidget
(
QObject
*
parent
)
:
QObject
(
parent
)
{
}
src/api/QGCOptions.h
View file @
e390054d
...
...
@@ -11,11 +11,13 @@
#include <QObject>
#include <QString>
#include <QUrl>
/// @file
/// @brief Core Plugin Interface for QGroundControl - Application Options
/// @author Gus Grubba <mavlink@grubba.com>
class
CustomInstrumentWidget
;
class
QGCOptions
:
public
QObject
{
Q_OBJECT
...
...
@@ -32,6 +34,8 @@ public:
Q_PROPERTY
(
double
toolbarHeightMultiplier
READ
toolbarHeightMultiplier
CONSTANT
)
Q_PROPERTY
(
double
defaultFontPointSize
READ
defaultFontPointSize
CONSTANT
)
Q_PROPERTY
(
bool
enablePlanViewSelector
READ
enablePlanViewSelector
CONSTANT
)
Q_PROPERTY
(
CustomInstrumentWidget
*
instrumentWidget
READ
instrumentWidget
CONSTANT
)
//! Should QGC hide its settings menu and colapse it into one single menu (Settings and Vehicle Setup)?
/*!
...
...
@@ -83,4 +87,32 @@ public:
@return True or false
*/
virtual
bool
enablePlanViewSelector
()
{
return
true
;
}
//! Provides an alternate instrument widget for the Fly View
/*!
@return An alternate widget (see QGCInstrumentWidget.qml, the default widget)
*/
virtual
CustomInstrumentWidget
*
instrumentWidget
();
private:
CustomInstrumentWidget
*
_defaultInstrumentWidget
;
};
//-----------------------------------------------------------------------------
class
CustomInstrumentWidget
:
public
QObject
{
Q_OBJECT
public:
//-- Widget Position
enum
Pos
{
POS_TOP_RIGHT
=
0
,
POS_CENTER_RIGHT
=
1
,
POS_BOTTOM_RIGHT
=
2
,
};
Q_ENUMS
(
Pos
)
CustomInstrumentWidget
(
QObject
*
parent
=
NULL
);
Q_PROPERTY
(
QUrl
source
READ
source
CONSTANT
)
Q_PROPERTY
(
Pos
widgetPosition
READ
widgetPosition
NOTIFY
widgetPositionChanged
)
virtual
QUrl
source
()
{
return
QUrl
();
}
virtual
Pos
widgetPosition
()
{
return
POS_CENTER_RIGHT
;
}
signals:
void
widgetPositionChanged
();
};
src/ui/AppSettings.qml
View file @
e390054d
...
...
@@ -35,8 +35,8 @@ Rectangle {
QGCPalette
{
id
:
qgcPal
}
Component.onCompleted
:
{
//-- Default
to General
Settings
__rightPanel
.
source
=
"
GeneralSettings.qml
"
//-- Default Settings
__rightPanel
.
source
=
QGroundControl
.
corePlugin
.
settings
[
QGroundControl
.
corePlugin
.
defaltSettings
].
url
}
QGCFlickable
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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