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
a5a2e831
Commit
a5a2e831
authored
Oct 09, 2019
by
DonLakeFlyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parent
0df420e3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
44 deletions
+32
-44
MultiVehicleSelector.qml
src/ui/toolbar/MultiVehicleSelector.qml
+32
-44
No files found.
src/ui/toolbar/MultiVehicleSelector.qml
View file @
a5a2e831
...
...
@@ -18,61 +18,49 @@ import QGroundControl.ScreenTools 1.0
import
QGroundControl
.
Palette
1.0
//-------------------------------------------------------------------------
//-- M
ode Indica
tor
Item
{
//-- M
ultiple Vehicle Selec
tor
QGCComboBox
{
anchors.top
:
parent
.
top
anchors.bottom
:
parent
.
bottom
visible
:
_multiVehicles
width
:
_multiVehicles
?
multiVehicleSelector
.
width
:
0
font.pointSize
:
ScreenTools
.
mediumFontPointSize
currentIndex
:
-
1
sizeToContents
:
true
model
:
_vehicleModel
visible
:
_multipleVehicles
property
bool
_multiVehicles
:
activeVehicle
?
QGroundControl
.
multiVehicleManager
.
vehicles
.
count
>
1
:
false
property
var
_activeVehicle
:
QGroundControl
.
multiVehicleManager
.
activeVehicle
property
bool
_multipleVehicles
:
_activeVehicle
?
QGroundControl
.
multiVehicleManager
.
vehicles
.
count
>
1
:
false
property
var
_vehicleModel
:
[
]
Connections
{
target
:
QGroundControl
.
multiVehicleManager
.
vehicles
onCountChanged
:
multiVehicleSelector
.
updatemultiVehiclesMenu
()
onCountChanged
:
_updateVehicleModel
()
}
QGCLabel
{
id
:
multiVehicleSelector
text
:
"
Vehicle
"
+
(
activeVehicle
?
activeVehicle
.
id
:
"
None
"
)
font.pointSize
:
ScreenTools
.
mediumFontPointSize
color
:
qgcPal
.
buttonText
anchors.verticalCenter
:
parent
.
verticalCenter
QGCMenu
{
id
:
multiVehiclesMenu
}
Component
{
id
:
multiVehicleMenuItemComponent
QGCMenuItem
{
onTriggered
:
QGroundControl
.
multiVehicleManager
.
activeVehicle
=
vehicle
property
int
vehicleId
:
Number
(
text
.
split
(
"
"
)[
1
])
property
var
vehicle
:
QGroundControl
.
multiVehicleManager
.
getVehicleById
(
vehicleId
)
}
}
property
var
multiVehiclesMenuItems
:
[]
function
updatemultiVehiclesMenu
()
{
if
(
_multiVehicles
)
{
// Remove old menu items
for
(
var
i
=
0
;
i
<
multiVehiclesMenuItems
.
length
;
i
++
)
{
multiVehiclesMenu
.
removeItem
(
multiVehiclesMenuItems
[
i
])
}
multiVehiclesMenuItems
.
length
=
0
// Add new items
for
(
i
=
0
;
i
<
QGroundControl
.
multiVehicleManager
.
vehicles
.
count
;
i
++
)
{
var
vehicle
=
QGroundControl
.
multiVehicleManager
.
vehicles
.
get
(
i
)
var
menuItem
=
multiVehicleMenuItemComponent
.
createObject
(
null
,
{
"
text
"
:
"
Vehicle
"
+
vehicle
.
id
})
multiVehiclesMenuItems
.
push
(
menuItem
)
multiVehiclesMenu
.
insertItem
(
i
,
menuItem
)
Component.onCompleted
:
_updateVehicleModel
()
function
_updateVehicleModel
()
{
var
newCurrentIndex
=
-
1
var
newModel
=
[
]
if
(
_multipleVehicles
)
{
for
(
var
i
=
0
;
i
<
QGroundControl
.
multiVehicleManager
.
vehicles
.
count
;
i
++
)
{
var
vehicle
=
QGroundControl
.
multiVehicleManager
.
vehicles
.
get
(
i
)
newModel
.
push
(
qsTr
(
"
Vehicle
"
)
+
"
"
+
vehicle
.
id
)
if
(
vehicle
.
id
===
_activeVehicle
.
id
)
{
newCurrentIndex
=
i
}
}
}
Component.onCompleted
:
{
multiVehicleSelector
.
updatemultiVehiclesMenu
()
}
currentIndex
=
-
1
_vehicleModel
=
newModel
currentIndex
=
newCurrentIndex
}
MouseArea
{
visible
:
_multiVehicles
anchors.fill
:
parent
onClicked
:
multiVehiclesMenu
.
popup
()
onActivated
:
{
var
vehicleId
=
textAt
(
index
).
split
(
"
"
)[
1
]
var
vehicle
=
QGroundControl
.
multiVehicleManager
.
getVehicleById
(
vehicleId
)
QGroundControl
.
multiVehicleManager
.
activeVehicle
=
vehicle
}
}
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