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
c7262637
Commit
c7262637
authored
Apr 11, 2020
by
DoinLakeFlyer
Browse files
New value editing dialogs
parent
5ad2b7f8
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/FactSystem/FactGroup.cc
View file @
c7262637
...
...
@@ -53,8 +53,6 @@ void FactGroup::_setupTimer()
Fact
*
FactGroup
::
getFact
(
const
QString
&
name
)
{
Fact
*
fact
=
nullptr
;
if
(
name
.
contains
(
"."
))
{
QStringList
parts
=
name
.
split
(
"."
);
if
(
parts
.
count
()
!=
2
)
{
...
...
@@ -71,11 +69,14 @@ Fact* FactGroup::getFact(const QString& name)
return
factGroup
->
getFact
(
parts
[
1
]);
}
if
(
_nameToFactMap
.
contains
(
name
))
{
fact
=
_nameToFactMap
[
name
];
Fact
*
fact
=
nullptr
;
QString
camelCaseName
=
_camelCase
(
name
);
if
(
_nameToFactMap
.
contains
(
camelCaseName
))
{
fact
=
_nameToFactMap
[
camelCaseName
];
QQmlEngine
::
setObjectOwnership
(
fact
,
QQmlEngine
::
CppOwnership
);
}
else
{
qWarning
()
<<
"Unknown Fact"
<<
n
ame
;
qWarning
()
<<
"Unknown Fact"
<<
camelCaseN
ame
;
}
return
fact
;
...
...
@@ -83,13 +84,14 @@ Fact* FactGroup::getFact(const QString& name)
FactGroup
*
FactGroup
::
getFactGroup
(
const
QString
&
name
)
{
FactGroup
*
factGroup
=
nullptr
;
FactGroup
*
factGroup
=
nullptr
;
QString
camelCaseName
=
_camelCase
(
name
);
if
(
_nameToFactGroupMap
.
contains
(
n
ame
))
{
factGroup
=
_nameToFactGroupMap
[
n
ame
];
if
(
_nameToFactGroupMap
.
contains
(
camelCaseN
ame
))
{
factGroup
=
_nameToFactGroupMap
[
camelCaseN
ame
];
QQmlEngine
::
setObjectOwnership
(
factGroup
,
QQmlEngine
::
CppOwnership
);
}
else
{
qWarning
()
<<
"Unknown FactGroup"
<<
n
ame
;
qWarning
()
<<
"Unknown FactGroup"
<<
camelCaseN
ame
;
}
return
factGroup
;
...
...
@@ -142,3 +144,9 @@ void FactGroup::setLiveUpdates(bool liveUpdates)
fact
->
setSendValueChangedSignals
(
liveUpdates
);
}
}
QString
FactGroup
::
_camelCase
(
const
QString
&
text
)
{
return
text
[
0
].
toLower
()
+
text
.
right
(
text
.
length
()
-
1
);
}
src/FactSystem/FactGroup.h
View file @
c7262637
...
...
@@ -44,25 +44,26 @@ public:
QStringList
factNames
(
void
)
const
{
return
_factNames
;
}
QStringList
factGroupNames
(
void
)
const
{
return
_nameToFactGroupMap
.
keys
();
}
protected:
void
_addFact
(
Fact
*
fact
,
const
QString
&
name
);
void
_addFactGroup
(
FactGroup
*
factGroup
,
const
QString
&
name
);
void
_loadFromJsonArray
(
const
QJsonArray
jsonArray
);
int
_updateRateMSecs
;
///< Update rate for Fact::valueChanged signals, 0: immediate update
protected
slots
:
virtual
void
_updateAllValues
(
void
);
private:
void
_setupTimer
();
QTimer
_updateTimer
;
protected:
void
_addFact
(
Fact
*
fact
,
const
QString
&
name
);
void
_addFactGroup
(
FactGroup
*
factGroup
,
const
QString
&
name
);
void
_loadFromJsonArray
(
const
QJsonArray
jsonArray
);
int
_updateRateMSecs
;
///< Update rate for Fact::valueChanged signals, 0: immediate update
QMap
<
QString
,
Fact
*>
_nameToFactMap
;
QMap
<
QString
,
FactGroup
*>
_nameToFactGroupMap
;
QMap
<
QString
,
FactMetaData
*>
_nameToFactMetaDataMap
;
QStringList
_factNames
;
private:
void
_setupTimer
(
void
);
QString
_camelCase
(
const
QString
&
text
);
QTimer
_updateTimer
;
};
#endif
src/FlightMap/Widgets/ValuePageWidget.qml
View file @
c7262637
...
...
@@ -34,8 +34,7 @@ Column {
property
real
_margins
:
ScreenTools
.
defaultFontPixelWidth
/
2
property
int
_colMax
:
4
property
bool
_settingsUnlocked
:
false
property
var
_valuePickerInstrumentValue
:
null
property
int
_valuePickerRowIndex
:
0
property
var
_valueDialogInstrumentValue
:
null
property
var
_rgFontSizes
:
[
ScreenTools
.
defaultFontPointSize
,
ScreenTools
.
smallFontPointSize
,
ScreenTools
.
mediumFontPointSize
,
ScreenTools
.
largeFontPointSize
]
property
var
_rgFontSizeRatios
:
[
1
,
ScreenTools
.
smallFontPointRatio
,
ScreenTools
.
mediumFontPointRatio
,
ScreenTools
.
largeFontPointRatio
]
property
real
_doubleDescent
:
ScreenTools
.
defaultFontDescent
*
2
...
...
@@ -48,6 +47,7 @@ Column {
property
real
_columnButtonsTotalHeight
:
(
_columnButtonHeight
*
2
)
+
_columnButtonSpacing
QGCPalette
{
id
:
qgcPal
;
colorGroupEnabled
:
true
}
QGCPalette
{
id
:
qgcPalDisabled
;
colorGroupEnabled
:
false
}
ValuesWidgetController
{
id
:
controller
}
...
...
@@ -79,9 +79,8 @@ Column {
property
int
rowIndex
onClicked
:
{
_valuePickerInstrumentValue
=
instrumentValue
_valuePickerRowIndex
=
rowIndex
mainWindow
.
showComponentDialog
(
valuePickerDialog
,
qsTr
(
"
Select Value
"
),
mainWindow
.
showDialogDefaultWidth
,
StandardButton
.
Ok
)
_valueDialogInstrumentValue
=
instrumentValue
mainWindow
.
showPopupDialog
(
valueDialog
,
qsTr
(
"
Value Display
"
),
StandardButton
.
Close
)
}
}
}
...
...
@@ -142,7 +141,7 @@ Column {
label
.
x
=
label
.
y
=
0
}
else
{
// label above value
if
(
label
)
{
if
(
object
.
label
)
{
label
.
x
=
(
width
-
label
.
width
)
/
2
label
.
y
=
0
value
.
y
=
label
.
height
+
smallSpacing
...
...
@@ -272,242 +271,166 @@ Column {
}
Component
{
id
:
valuePickerDialog
QGCViewDialog
{
function
accept
()
{
if
(
factRadioGroup
.
checkedButton
)
{
_valuePickerInstrumentValue
.
setFact
(
factRadioGroup
.
checkedButton
.
radioFactGroupName
,
factRadioGroup
.
checkedButton
.
radioFact
.
name
,
labelTextField
.
text
,
fontSizeCombo
.
currentIndex
)
}
else
{
_valuePickerInstrumentValue
.
clearFact
()
}
hideDialog
()
}
Connections
{
target
:
factRadioGroup
onCheckedButtonChanged
:
labelTextField
.
text
=
factRadioGroup
.
checkedButton
.
radioFact
.
shortDescription
}
ButtonGroup
{
id
:
fontRadioGroup
}
QGCFlickable
{
anchors.fill
:
parent
contentHeight
:
column
.
height
flickableDirection
:
Flickable
.
VerticalFlick
clip
:
true
ColumnLayout
{
id
:
column
anchors.left
:
parent
.
left
anchors.right
:
parent
.
right
spacing
:
_margins
QGCButton
{
Layout.fillWidth
:
true
text
:
qsTr
(
"
Blank Entry
"
)
onClicked
:
{
_valuePickerInstrumentValue
.
clearFact
();
hideDialog
()
}
}
RowLayout
{
Layout.fillWidth
:
true
spacing
:
ScreenTools
.
defaultFontPixelWidth
QGCLabel
{
text
:
qsTr
(
"
Label
"
)
}
QGCTextField
{
id
:
labelTextField
Layout.fillWidth
:
true
text
:
_valuePickerInstrumentValue
.
label
id
:
valueDialog
QGCPopupDialog
{
GridLayout
{
rowSpacing
:
_margins
columnSpacing
:
_margins
columns
:
3
QGCCheckBox
{
id
:
valueCheckBox
text
:
qsTr
(
"
Value
"
)
checked
:
_valueDialogInstrumentValue
.
fact
onClicked
:
{
if
(
checked
)
{
_valueDialogInstrumentValue
.
setFact
(
_valueDialogInstrumentValue
.
factGroupNames
[
0
],
_valueDialogInstrumentValue
.
factValueNames
[
0
])
}
else
{
_valueDialogInstrumentValue
.
clearFact
()
}
}
}
RowLayout
{
spacing
:
ScreenTools
.
defaultFontPixelWidth
QGCLabel
{
text
:
qsTr
(
"
Font Size
"
)
}
QGCComboBox
{
id
:
fontSizeCombo
model
:
_valuePickerInstrumentValue
.
fontSizeNames
currentIndex
:
_valuePickerInstrumentValue
.
fontSize
sizeToContents
:
true
onActivated
:
_valuePickerInstrumentValue
.
fontSize
=
index
}
QGCCheckBox
{
text
:
qsTr
(
"
Show Units
"
)
checked
:
_valuePickerInstrumentValue
.
showUnits
onClicked
:
_valuePickerInstrumentValue
.
showUnits
=
checked
}
}
RowLayout
{
spacing
:
ScreenTools
.
defaultFontPixelWidth
QGCLabel
{
text
:
qsTr
(
"
Icon
"
)
}
Rectangle
{
height
:
iconPositionCombo
.
height
width
:
noIconLabel
.
width
+
ScreenTools
.
defaultFontPixelWidth
*
2
color
:
qgcPal
.
window
border.color
:
qgcPal
.
text
visible
:
!
_valuePickerInstrumentValue
.
icon
QGCLabel
{
id
:
noIconLabel
anchors.centerIn
:
parent
text
:
qsTr
(
"
No Icon
"
)
}
}
QGCColoredImage
{
height
:
iconPositionCombo
.
height
width
:
height
source
:
_valuePickerInstrumentValue
.
icon
?
"
/InstrumentValueIcons/
"
+
_valuePickerInstrumentValue
.
icon
:
""
sourceSize.height
:
height
fillMode
:
Image
.
PreserveAspectFit
mipmap
:
true
smooth
:
true
color
:
qgcPal
.
text
visible
:
_valuePickerInstrumentValue
.
icon
}
QGCComboBox
{
id
:
iconPositionCombo
model
:
_valuePickerInstrumentValue
.
iconPositionNames
currentIndex
:
_valuePickerInstrumentValue
.
iconPosition
sizeToContents
:
true
onActivated
:
_valuePickerInstrumentValue
.
iconPosition
=
index
}
QGCComboBox
{
model
:
_valueDialogInstrumentValue
.
factGroupNames
sizeToContents
:
true
enabled
:
valueCheckBox
.
enabled
onModelChanged
:
currentIndex
=
find
(
_valueDialogInstrumentValue
.
factGroupName
)
Component.onCompleted
:
currentIndex
=
find
(
_valueDialogInstrumentValue
.
factGroupName
)
onActivated
:
{
_valueDialogInstrumentValue
.
setFact
(
currentText
,
""
)
_valueDialogInstrumentValue
.
icon
=
""
_valueDialogInstrumentValue
.
label
=
_valueDialogInstrumentValue
.
fact
.
shortDescription
}
}
SectionHeader
{
id
:
iconListHeader
Layout.fillWidth
:
true
text
:
qsTr
(
"
Icons
"
)
checked
:
false
QGCComboBox
{
model
:
_valueDialogInstrumentValue
.
factValueNames
sizeToContents
:
true
enabled
:
valueCheckBox
.
enabled
onModelChanged
:
currentIndex
=
_valueDialogInstrumentValue
.
fact
?
find
(
_valueDialogInstrumentValue
.
factName
)
:
-
1
Component.onCompleted
:
currentIndex
=
_valueDialogInstrumentValue
.
fact
?
find
(
_valueDialogInstrumentValue
.
factName
)
:
-
1
onActivated
:
{
_valueDialogInstrumentValue
.
setFact
(
_valueDialogInstrumentValue
.
factGroupName
,
currentText
)
_valueDialogInstrumentValue
.
icon
=
""
_valueDialogInstrumentValue
.
label
=
_valueDialogInstrumentValue
.
fact
.
shortDescription
}
}
Item
{
width
:
1
;
height
:
1
}
Loader
{
Layout.fillWidth
:
true
sourceComponent
:
iconListHeader
.
checked
?
iconList
:
undefined
visible
:
iconListHeader
.
checked
QGCRadioButton
{
id
:
iconCheckBox
text
:
qsTr
(
"
Icon
"
)
Component.onCompleted
:
checked
=
_valueDialogInstrumentValue
.
icon
!=
""
onClicked
:
{
_valueDialogInstrumentValue
.
label
=
""
_valueDialogInstrumentValue
.
icon
=
_valueDialogInstrumentValue
.
iconNames
[
0
]
mainWindow
.
showPopupDialog
(
iconDialog
,
qsTr
(
"
Select Icon
"
),
StandardButton
.
Close
)
}
}
Loader
{
Layout.fillWidth
:
true
sourceComponent
:
factGroupList
property
var
factGroup
:
_activeVehicle
property
string
factGroupName
:
"
Vehicle
"
QGCColoredImage
{
Layout.alignment
:
Qt
.
AlignHCenter
height
:
iconPositionCombo
.
height
width
:
height
source
:
"
/InstrumentValueIcons/
"
+
(
_valueDialogInstrumentValue
.
icon
?
_valueDialogInstrumentValue
.
icon
:
_valueDialogInstrumentValue
.
iconNames
[
0
])
sourceSize.height
:
height
fillMode
:
Image
.
PreserveAspectFit
mipmap
:
true
smooth
:
true
color
:
enabled
?
qgcPal
.
text
:
qgcPalDisabled
.
text
enabled
:
iconCheckBox
.
checked
MouseArea
{
anchors.fill
:
parent
onClicked
:
mainWindow
.
showPopupDialog
(
iconDialog
,
qsTr
(
"
Select Icon
"
),
StandardButton
.
Close
)
}
}
Repeater
{
model
:
_activeVehicle
.
factGroupNames
Loader
{
Layout.fillWidth
:
true
sourceComponent
:
factGroupList
QGCComboBox
{
id
:
iconPositionCombo
model
:
_valueDialogInstrumentValue
.
iconPositionNames
currentIndex
:
_valueDialogInstrumentValue
.
iconPosition
sizeToContents
:
true
onActivated
:
_valueDialogInstrumentValue
.
iconPosition
=
index
enabled
:
iconCheckBox
.
checked
}
property
var
factGroup
:
_activeVehicle
.
getFactGroup
(
modelData
)
property
string
factGroupName
:
modelData
}
QGCRadioButton
{
id
:
labelCheckBox
text
:
qsTr
(
"
Label
"
)
Component.onCompleted
:
checked
=
_valueDialogInstrumentValue
.
label
!=
""
onClicked
:
{
_valueDialogInstrumentValue
.
icon
=
""
_valueDialogInstrumentValue
.
label
=
_valueDialogInstrumentValue
.
fact
?
_valueDialogInstrumentValue
.
fact
.
shortDescription
:
qsTr
(
"
Label
"
)
}
}
}
}
}
Component
{
id
:
iconList
Flow
{
Rectangle
{
height
:
ScreenTools
.
minTouchPixels
width
:
noIconLabel
.
width
+
ScreenTools
.
defaultFontPixelWidth
*
2
color
:
isNoIcon
?
qgcPal
.
text
:
qgcPal
.
window
border.color
:
isNoIcon
?
qgcPal
.
window
:
qgcPal
.
text
property
bool
isNoIcon
:
_valuePickerInstrumentValue
.
icon
===
""
QGCLabel
{
id
:
noIconLabel
anchors.centerIn
:
parent
color
:
parent
.
isNoIcon
?
qgcPal
.
window
:
qgcPal
.
text
text
:
qsTr
(
"
No Icon
"
)
QGCTextField
{
id
:
labelTextField
Layout.fillWidth
:
true
Layout.columnSpan
:
2
text
:
_valueDialogInstrumentValue
.
label
enabled
:
labelCheckBox
.
checked
}
MouseArea
{
anchors.fill
:
parent
onClicked
:
_valuePickerInstrumentValue
.
icon
=
""
QGCLabel
{
text
:
qsTr
(
"
Size
"
)
}
QGCComboBox
{
id
:
fontSizeCombo
Layout.columnSpan
:
2
model
:
_valueDialogInstrumentValue
.
fontSizeNames
currentIndex
:
_valueDialogInstrumentValue
.
fontSize
sizeToContents
:
true
onActivated
:
_valueDialogInstrumentValue
.
fontSize
=
index
}
}
Repeater
{
model
:
_valuePickerInstrumentValue
.
iconNames
Rectangle
{
height
:
ScreenTools
.
minTouchPixels
width
:
height
color
:
currentSelection
?
qgcPal
.
text
:
qgcPal
.
window
property
bool
currentSelection
:
_valuePickerInstrumentValue
.
icon
==
modelData
QGCColoredImage
{
anchors.centerIn
:
parent
height
:
parent
.
height
*
0.75
width
:
height
source
:
"
/InstrumentValueIcons/
"
+
modelData
sourceSize.height
:
height
fillMode
:
Image
.
PreserveAspectFit
mipmap
:
true
smooth
:
true
color
:
currentSelection
?
qgcPal
.
window
:
qgcPal
.
text
MouseArea
{
anchors.fill
:
parent
onClicked
:
_valuePickerInstrumentValue
.
icon
=
modelData
}
}
QGCCheckBox
{
Layout.columnSpan
:
3
text
:
qsTr
(
"
Show Units
"
)
checked
:
_valueDialogInstrumentValue
.
showUnits
onClicked
:
_valueDialogInstrumentValue
.
showUnits
=
checked
}
}
}
}
Component
{
id
:
factGroupList
// You must push in the following properties from the Loader
// property var factGroup
// property string factGroupName
Column
{
SectionHeader
{
id
:
header
anchors.left
:
parent
.
left
anchors.right
:
parent
.
right
text
:
factGroupName
.
charAt
(
0
).
toUpperCase
()
+
factGroupName
.
slice
(
1
)
checked
:
false
}
id
:
iconDialog
Column
{
visible
:
header
.
checked
QGCPopupDialog
{
GridLayout
{
columns
:
10
columnSpacing
:
0
rowSpacing
:
0
Repeater
{
model
:
factGroup
?
factGroup
.
fact
Names
:
0
model
:
_valueDialogInstrumentValue
.
icon
Names
QGCRadioButton
{
text
:
radioFact
.
shortDescription
ButtonGroup.group
:
factRadioGroup
c
hecked
:
radioFactGroupName
==
_valuePickerInstrumentValue
.
factGroupName
&&
radioFact
==
_valuePickerInstrumentValue
.
fact
Rectangle
{
height
:
ScreenTools
.
minTouchPixels
width
:
height
c
olor
:
currentSelection
?
qgcPal
.
text
:
qgcPal
.
window
property
string
radioFactGroupName
:
factGroupName
property
var
radioFact
:
factGroup
.
getFact
(
modelData
)
property
bool
currentSelection
:
_valueDialogInstrumentValue
.
icon
==
modelData
Component.onCompleted
:
{
if
(
checked
)
{
header
.
checked
=
true
QGCColoredImage
{
anchors.centerIn
:
parent
height
:
parent
.
height
*
0.75
width
:
height
source
:
"
/InstrumentValueIcons/
"
+
modelData
sourceSize.height
:
height
fillMode
:
Image
.
PreserveAspectFit
mipmap
:
true
smooth
:
true
color
:
currentSelection
?
qgcPal
.
window
:
qgcPal
.
text
MouseArea
{
anchors.fill
:
parent
onClicked
:
{
_valueDialogInstrumentValue
.
icon
=
modelData
hideDialog
()
}
}
}
}
...
...
src/FlightMap/Widgets/ValuesWidgetController.cc
View file @
c7262637
...
...
@@ -29,6 +29,7 @@ const char* InstrumentValue::_fontSizeKey = "fontSize";
const
char
*
InstrumentValue
::
_showUnitsKey
=
"showUnits"
;
const
char
*
InstrumentValue
::
_iconKey
=
"icon"
;
const
char
*
InstrumentValue
::
_iconPositionKey
=
"iconPosition"
;
const
char
*
InstrumentValue
::
_vehicleFactGroupName
=
"Vehicle"
;
QStringList
InstrumentValue
::
_iconNames
;
...
...
@@ -234,28 +235,32 @@ void ValuesWidgetController::_loadSettings(void)
QStringList
largeValues
=
settings
.
value
(
_deprecatedLargeValuesKey
).
toStringList
();
QStringList
smallValues
=
settings
.
value
(
_deprecatedSmallValuesKey
).
toStringList
();
QStringList
altitudeProperties
=
{
"
a
ltitudeRelative"
,
"
a
ltitudeAMSL"
};
QStringList
altitudeProperties
=
{
"
A
ltitudeRelative"
,
"
A
ltitudeAMSL"
};
int
rowIndex
=
-
1
;
int
valueCount
=
0
;
QmlObjectListModel
*
rowModel
=
nullptr
;
for
(
const
QString
&
largeValue
:
largeValues
)
{
QStringList
parts
=
largeValue
.
split
(
"."
);
QStringList
parts
=
largeValue
.
split
(
"."
);
QString
factGroupName
=
_pascalCase
(
parts
[
0
]);
QString
factName
=
_pascalCase
(
parts
[
1
]);
rowModel
=
appendRow
(
false
/* addBlankColumn */
);
rowIndex
++
;
InstrumentValue
*
colValue
=
appendColumn
(
rowIndex
);
colValue
->
setFact
(
parts
[
0
],
parts
[
1
],
QString
()
);
colValue
->
setFact
(
factGroupName
,
factName
);
colValue
->
setLabel
(
colValue
->
fact
()
->
shortDescription
());
colValue
->
setShowUnits
(
true
);
colValue
->
setFontSize
(
altitudeProperties
.
contains
(
parts
[
1
]
)
?
InstrumentValue
::
LargeFontSize
:
InstrumentValue
::
DefaultFontSize
);
colValue
->
setFontSize
(
altitudeProperties
.
contains
(
factName
)
?
InstrumentValue
::
LargeFontSize
:
InstrumentValue
::
DefaultFontSize
);
}
valueCount
=
0
;
rowModel
=
nullptr
;
for
(
const
QString
&
smallValue
:
smallValues
)
{
QStringList
parts
=
smallValue
.
split
(
"."
);
QStringList
parts
=
smallValue
.
split
(
"."
);
QString
factGroupName
=
_pascalCase
(
parts
[
0
]);
QString
factName
=
_pascalCase
(
parts
[
1
]);
if
(
!
(
valueCount
++
&
1
))
{
rowModel
=
appendRow
(
false
/* addBlankColumn */
);
...
...
@@ -263,7 +268,7 @@ void ValuesWidgetController::_loadSettings(void)
}
InstrumentValue
*
colValue
=
appendColumn
(
rowIndex
);
colValue
->
setFact
(
parts
[
0
],
parts
[
1
],
QString
()
);
colValue
->
setFact
(
factGroupName
,
factName
);
colValue
->
setLabel
(
colValue
->
fact
()
->
shortDescription
());
colValue
->
setShowUnits
(
true
);
colValue
->
setFontSize
(
InstrumentValue
::
SmallFontSize
);
...
...
@@ -332,6 +337,11 @@ void ValuesWidgetController::setValuesModelParentController(ValuesWidgetControll
}
}
QString
ValuesWidgetController
::
_pascalCase
(
const
QString
&
text
)
{
return
text
[
0
].
toUpper
()
+
text
.
right
(
text
.
length
()
-
1
);
}
InstrumentValue
::
InstrumentValue
(
Vehicle
*
activeVehicle
,
FontSize
fontSize
,
QmlObjectListModel
*
rowModel
)
:
QObject
(
rowModel
)
,
_activeVehicle
(
activeVehicle
)
...
...
@@ -342,17 +352,27 @@ InstrumentValue::InstrumentValue(Vehicle* activeVehicle, FontSize fontSize, QmlO
QDir
iconDir
(
":/InstrumentValueIcons/"
);
_iconNames
=
iconDir
.
entryList
();
}
activeVehicleChanged
(
_activeVehicle
);
}
void
InstrumentValue
::
activeVehicleChanged
(
Vehicle
*
activeVehicle
)
{
_activeVehicle
=
activeVehicle
;
_factGroupNames
.
clear
();
_factGroupNames
=
_activeVehicle
->
factGroupNames
();
for
(
QString
&
name
:
_factGroupNames
)
{
name
[
0
]
=
name
[
0
].
toUpper
();
}
_factGroupNames
.
prepend
(
_vehicleFactGroupName
);
emit
factGroupNamesChanged
(
_factGroupNames
);
if
(
_fact
)
{
_fact
=
nullptr
;
FactGroup
*
factGroup
=
nullptr
;
if
(
_factGroupName
==
QStringLiteral
(
"Vehicle"
)
)
{
if
(
_factGroupName
==
_vehicleFactGroupName
)
{
factGroup
=
_activeVehicle
;
}
else
{
factGroup
=
_activeVehicle
->
getFactGroup
(
_factGroupName
);
...
...
@@ -365,37 +385,47 @@ void InstrumentValue::activeVehicleChanged(Vehicle* activeVehicle)
}
}
void
InstrumentValue
::
setFact
(
QString
factGroupName
,
QString
factName
,
QString
label
)
void
InstrumentValue
::
setFact
(
const
QString
&
factGroupName
,
const
QString
&
factName
)
{
if
(
_fact
)
{
_fact
=
nullptr
;
}
FactGroup
*
factGroup
=
nullptr
;
if
(
factGroupName
==
QStringLiteral
(
"Vehicle"
)
)
{
if
(
factGroupName
==
_vehicleFactGroupName
)
{
factGroup
=
_activeVehicle
;
}
else
{
factGroup
=
_activeVehicle
->
getFactGroup
(
factGroupName
);
}
_factValueNames
.
clear
();
_factValueNames
=
factGroup
->
factNames
();
for
(
QString
&
name
:
_factValueNames
)
{
name
[
0
]
=
name
[
0
].
toUpper
();
}
QString
nonEmptyFactName
;
if
(
factGroup
)
{
_fact
=
factGroup
->
getFact
(
factName
);
if
(
factName
.
isEmpty
())
{
nonEmptyFactName
=
_factValueNames
[
0
];
}
else
{
nonEmptyFactName
=
factName
;
}
_fact
=
factGroup
->
getFact
(
nonEmptyFactName
);
}
if
(
_fact
)
{
_factName
=
factName
;
_factGroupName
=
factGroupName
;
_
label
=
label
;
_
factName
=
nonEmptyFactName
;
}
else
{
_factName
.
clear
();
_factGroupName
.
clear
();
_label
.
clear
();
}
emit
label
Changed
(
_label
);
emit
factChanged
(
_fact
);
emit
factNameChanged
(
_factName
);
emit
fact
Group
NameChanged
(
_fact
Group
Name
);
emit
fact
Changed
(
_fact
);
emit
fact
Name
Changed
(
_fact
Name
);
emit
fact
Group
NameChanged
(
_fact
Group
Name
);
emit
fact
Value
Name
s
Changed
(
_fact
Value
Name
s
);
}
void
InstrumentValue
::
_setFontSize
(
FontSize
fontSize
)
...
...
@@ -423,7 +453,7 @@ void InstrumentValue::saveToSettings(QSettings& settings) const
{
if
(
_fact
)
{
settings
.
setValue
(
_factGroupNameKey
,
_factGroupName
);
settings
.
setValue
(
_factNameKey
,
_fact
->
n
ame
()
);
settings
.
setValue
(
_factNameKey
,
_fact
N
ame
);
}
else
{
settings
.
setValue
(
_factGroupNameKey
,
""
);
settings
.
setValue
(
_factNameKey
,
""
);
...
...
@@ -446,7 +476,7 @@ void InstrumentValue::readFromSettings(const QSettings& settings)
QString
factName
=
settings
.
value
(
_factNameKey
).
toString
();
if
(
!
factName
.
isEmpty
())
{
setFact
(
_factGroupName
,
factName
,
_label
);
setFact
(
_factGroupName
,
factName
);
}
emit
factChanged
(
_fact
);
...
...
src/FlightMap/Widgets/ValuesWidgetController.h
View file @
c7262637
...
...
@@ -38,7 +38,10 @@ public:
InstrumentValue
(
Vehicle
*
activeVehicle
,
FontSize
fontSize
,
QmlObjectListModel
*
rowModel
);
Q_PROPERTY
(
QStringList
factGroupNames
MEMBER
_factGroupNames
NOTIFY
factGroupNamesChanged
)
Q_PROPERTY
(
QStringList
factValueNames
MEMBER
_factValueNames
NOTIFY
factValueNamesChanged
)
Q_PROPERTY
(
QString
factGroupName
MEMBER
_factGroupName
NOTIFY
factGroupNameChanged
)
Q_PROPERTY
(
QString
factName
MEMBER
_factName
NOTIFY
factNameChanged
)
Q_PROPERTY
(
Fact
*
fact
READ
fact
NOTIFY
factChanged
)
Q_PROPERTY
(
QString
label
READ
label
WRITE
setLabel
NOTIFY
labelChanged
)
Q_PROPERTY
(
QString
icon
READ
icon
WRITE
setIcon
NOTIFY
iconChanged
)
///< If !isEmpty icon will be show instead of label
...
...
@@ -49,8 +52,8 @@ public:
Q_PROPERTY
(
QStringList
fontSizeNames
MEMBER
_fontSizeNames
CONSTANT
)
Q_PROPERTY
(
bool
showUnits
READ
showUnits
WRITE
setShowUnits
NOTIFY
showUnitsChanged
)
Q_INVOKABLE
void
setFact
(
QString
factGroupName
,
QString
factName
,
QString
label
);
Q_INVOKABLE
void
clearFact
(
void
);
Q_INVOKABLE
void
setFact
(
const
QString
&
factGroupName
,
const
QString
&
factName
);
Q_INVOKABLE
void
clearFact
(
void
);
Fact
*
fact
(
void
)
{
return
_fact
;
}
FontSize
fontSize
(
void
)
const
{
return
_fontSize
;
}
...
...
@@ -76,6 +79,8 @@ signals:
void
showUnitsChanged
(
bool
showUnits
);
void
iconChanged
(
const
QString
&
icon
);
void
iconPositionChanged
(
IconPosition
iconPosition
);
void
factGroupNamesChanged
(
const
QStringList
&
factGroupNames
);
void
factValueNamesChanged
(
const
QStringList
&
factValueNames
);
private:
void
_setFontSize
(
FontSize
fontSize
);
...
...
@@ -90,6 +95,8 @@ private:
FontSize
_fontSize
=
DefaultFontSize
;
QString
_icon
;
IconPosition
_iconPosition
=
IconLeft
;
QStringList
_factGroupNames
;
QStringList
_factValueNames
;
static
const
QStringList
_iconPositionNames
;
static
QStringList
_iconNames
;
...
...
@@ -102,6 +109,7 @@ private:
static
const
char
*
_showUnitsKey
;
static
const
char
*
_iconKey
;
static
const
char
*
_iconPositionKey
;
static
const
char
*
_vehicleFactGroupName
;
};
Q_DECLARE_METATYPE
(
InstrumentValue
::
FontSize
)
...
...
@@ -146,7 +154,7 @@ private:
InstrumentValue
*
_createNewInstrumentValueWorker
(
Vehicle
*
activeVehicle
,
InstrumentValue
::
FontSize
fontSize
,
QmlObjectListModel
*
rowModel
);
void
_loadSettings
(
void
);
void
_connectSignalsToController
(
InstrumentValue
*
value
,
ValuesWidgetController
*
controller
);
QString
_pascalCase
(
const
QString
&
text
);
MultiVehicleManager
*
_multiVehicleMgr
=
nullptr
;
QmlObjectListModel
*
_valuesModel
=
nullptr
;
...
...
src/api/QGCCorePlugin.cc
View file @
c7262637
...
...
@@ -417,21 +417,21 @@ QmlObjectListModel* QGCCorePlugin::valuesWidgetDefaultSettings(ValuesWidgetContr
QmlObjectListModel
*
columnModel
=
controller
.
appendRow
();
InstrumentValue
*
colValue
=
columnModel
->
value
<
InstrumentValue
*>
(
0
);
colValue
->
setFact
(
"Vehicle"
,
"
a
ltitudeRelative"
,
QString
()
);
colValue
->
setFact
(
"Vehicle"
,
"
A
ltitudeRelative"
);
colValue
->
setLabel
(
colValue
->
fact
()
->
shortDescription
());
colValue
->
setShowUnits
(
true
);
colValue
->
setFontSize
(
InstrumentValue
::
LargeFontSize
);
columnModel
=
controller
.
appendRow
();
colValue
=
columnModel
->
value
<
InstrumentValue
*>
(
0
);
colValue
->
setFact
(
"Vehicle"
,
"
g
roundSpeed"
,
QString
()
);
colValue
->
setFact
(
"Vehicle"
,
"
G
roundSpeed"
);
colValue
->
setLabel
(
colValue
->
fact
()
->
shortDescription
());
colValue
->
setShowUnits
(
true
);
colValue
->
setFontSize
(
InstrumentValue
::
DefaultFontSize
);
columnModel
=
controller
.
appendRow
();
colValue
=
columnModel
->
value
<
InstrumentValue
*>
(
0
);
colValue
->
setFact
(
"Vehicle"
,
"
f
lightTime"
,
QString
()
);
colValue
->
setFact
(
"Vehicle"
,
"
F
lightTime"
);
colValue
->
setLabel
(
colValue
->
fact
()
->
shortDescription
());
colValue
->
setShowUnits
(
false
);
colValue
->
setFontSize
(
InstrumentValue
::
DefaultFontSize
);
...
...
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