Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qgroundcontrol
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Valentin Platzgummer
qgroundcontrol
Commits
e5eba4a9
Commit
e5eba4a9
authored
5 years ago
by
Gus Grubba
Browse files
Options
Downloads
Patches
Plain Diff
Use a custom selector for flight modes
parent
7cfba12a
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
custom-example/res/MainToolbar/CustomModeIndicator.qml
+48
-34
48 additions, 34 deletions
custom-example/res/MainToolbar/CustomModeIndicator.qml
with
48 additions
and
34 deletions
custom-example/res/MainToolbar/CustomModeIndicator.qml
+
48
−
34
View file @
e5eba4a9
...
...
@@ -9,8 +9,11 @@
* @author Gus Grubba <gus@auterion.com>
*/
import
QtQuick
2.11
import
QtQuick
.
Controls
1.4
import
QtQuick
.
Controls
2.4
import
QtQuick
.
Layouts
1.11
import
QtQuick
.
Dialogs
1.3
import
QGroundControl
1.0
import
QGroundControl
.
Controls
1.0
...
...
@@ -25,10 +28,6 @@ Item {
anchors.bottom
:
parent
.
bottom
width
:
selectorRow
.
width
property
var
_flightModes
:
activeVehicle
?
activeVehicle
.
flightModes
:
[
]
on_FlightModesChanged
:
flightModeSelector
.
updateFlightModesMenu
()
Row
{
id
:
selectorRow
spacing
:
ScreenTools
.
defaultFontPixelWidth
...
...
@@ -39,32 +38,6 @@ Item {
color
:
qgcPal
.
text
font.pointSize
:
ScreenTools
.
defaultFontPointSize
anchors.verticalCenter
:
parent
.
verticalCenter
Menu
{
id
:
flightModesMenu
}
Component
{
id
:
flightModeMenuItemComponent
MenuItem
{
onTriggered
:
activeVehicle
.
flightMode
=
text
}
}
property
var
flightModesMenuItems
:
[]
function
updateFlightModesMenu
()
{
if
(
activeVehicle
&&
activeVehicle
.
flightModeSetAvailable
)
{
// Remove old menu items
var
i
=
0
for
(
i
=
0
;
i
<
flightModesMenuItems
.
length
;
i
++
)
{
flightModesMenu
.
removeItem
(
flightModesMenuItems
[
i
])
}
flightModesMenuItems
.
length
=
0
// Add new items
for
(
i
=
0
;
i
<
_flightModes
.
length
;
i
++
)
{
var
menuItem
=
flightModeMenuItemComponent
.
createObject
(
null
,
{
"
text
"
:
_flightModes
[
i
]
})
flightModesMenuItems
.
push
(
menuItem
)
flightModesMenu
.
insertItem
(
i
,
menuItem
)
}
}
}
}
QGCColoredImage
{
anchors.verticalCenter
:
parent
.
verticalCenter
...
...
@@ -76,10 +49,51 @@ Item {
color
:
qgcPal
.
text
}
}
Component.onCompleted
:
flightModeSelector
.
updateFlightModesMenu
()
MouseArea
{
visible
:
activeVehicle
&&
activeVehicle
.
flightModeSetAvailable
anchors.fill
:
parent
onClicked
:
flightModesMenu
.
popup
()
onClicked
:
flightModesMenu
.
open
()
}
//-------------------------------------------------------------------------
//-- Flight Modes
Popup
{
id
:
flightModesMenu
width
:
Math
.
min
(
mainWindow
.
width
*
0.666
,
ScreenTools
.
defaultFontPixelWidth
*
40
)
height
:
mainWindow
.
height
*
0.5
modal
:
true
focus
:
true
parent
:
Overlay
.
overlay
x
:
Math
.
round
((
mainWindow
.
width
-
width
)
*
0.5
)
y
:
Math
.
round
((
mainWindow
.
height
-
height
)
*
0.5
)
closePolicy
:
Popup
.
CloseOnEscape
|
Popup
.
CloseOnPressOutside
property
int
selectedIndex
:
0
background
:
Rectangle
{
anchors.fill
:
parent
color
:
qgcPal
.
globalTheme
===
QGCPalette
.
Light
?
Qt
.
rgba
(
1
,
1
,
1
,
0.95
)
:
Qt
.
rgba
(
0
,
0
,
0
,
0.75
)
border.color
:
qgcPal
.
text
radius
:
ScreenTools
.
defaultFontPixelWidth
}
Column
{
id
:
comboListCol
spacing
:
ScreenTools
.
defaultFontPixelHeight
anchors.centerIn
:
parent
QGCLabel
{
text
:
qsTr
(
"
Flight Modes
"
)
anchors.horizontalCenter
:
parent
.
horizontalCenter
}
Repeater
{
model
:
activeVehicle
?
activeVehicle
.
flightModes
:
[
]
QGCButton
{
text
:
modelData
width
:
ScreenTools
.
defaultFontPixelWidth
*
30
height
:
ScreenTools
.
defaultFontPixelHeight
*
2
anchors.horizontalCenter
:
parent
.
horizontalCenter
onClicked
:
{
activeVehicle
.
flightMode
=
modelData
flightModesMenu
.
close
()
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment