用qml显示了航点参数,qml目前可能没有完善,很多部件都显示不了
This commit is contained in:
+211
-58
@@ -2,9 +2,12 @@ import QtQuick 2.6
|
||||
import QtQuick.Controls 2.5
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick.Templates 2.5
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
import QtQuick.Dialogs 1.2
|
||||
import QtGraphicalEffects 1.0
|
||||
import Qt.labs.calendar 1.0
|
||||
import QtQuick.Dialogs.qml 1.0
|
||||
import QtQuick.Window 2.10
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -18,55 +21,103 @@ Rectangle {
|
||||
width: 280
|
||||
height: 320
|
||||
color: "#fbfdca"
|
||||
|
||||
//property ComboBox name: "value"
|
||||
|
||||
//property ListModel json: 0
|
||||
|
||||
|
||||
property string rawName : "MAV_CMD_NAV_WAYPOINT"
|
||||
property string friendlyName: "Waypoint"
|
||||
property string description : "Disable,Enable,Enable+reset,Enable+reset route only"
|
||||
property bool specifiesCoordinate: true
|
||||
property bool friendlyEdit: true
|
||||
property string category: "Basic"
|
||||
property int number : 1
|
||||
|
||||
property real param1: 0
|
||||
property real param2: 0
|
||||
property real param3: 0
|
||||
property real param4: 0
|
||||
property real param5: 0
|
||||
property real param6: 0
|
||||
property real param7: 0
|
||||
|
||||
|
||||
|
||||
property bool isSettingCategory: false
|
||||
|
||||
|
||||
property var json: ["null"]
|
||||
|
||||
property ListModel model : ListModel { id: jsonModel }
|
||||
|
||||
antialiasing: true
|
||||
|
||||
|
||||
property int number : 1
|
||||
|
||||
onJsonChanged: {
|
||||
console.log(json)
|
||||
property bool isSettingCategory: false
|
||||
property bool isFirst: true
|
||||
|
||||
JSON.parse(json)
|
||||
|
||||
property var json: {
|
||||
"comment": "",
|
||||
"id": 0,
|
||||
"rawName": "",
|
||||
"friendlyName": "null",
|
||||
"description": "",
|
||||
"specifiesCoordinate": true,
|
||||
"friendlyEdit": true,
|
||||
"category": "",
|
||||
"param1": {
|
||||
"label": "",
|
||||
"units": "",
|
||||
"default": 0,
|
||||
"decimalPlaces": 0
|
||||
},
|
||||
"param2": {
|
||||
"label": "",
|
||||
"units": "",
|
||||
"default": 3,
|
||||
"decimalPlaces": 2
|
||||
},
|
||||
"param3": {
|
||||
"label": "",
|
||||
"units": "",
|
||||
"default": 0,
|
||||
"decimalPlaces": 0
|
||||
},
|
||||
"param4": {
|
||||
"label": "",
|
||||
"units": "",
|
||||
"nanUnchanged": true,
|
||||
"default": 0,
|
||||
"decimalPlaces": 0
|
||||
},
|
||||
"param5": {
|
||||
"label": "",
|
||||
"default": 0,
|
||||
"decimalPlaces": 0
|
||||
},
|
||||
"param6": {
|
||||
"label": "",
|
||||
"default": 0,
|
||||
"decimalPlaces": 0
|
||||
},
|
||||
"param7": {
|
||||
"label": "",
|
||||
"default": 0,
|
||||
"decimalPlaces": 0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Component{
|
||||
id: friendlyNameModel
|
||||
ListModel{
|
||||
id: friendlyNamelist
|
||||
}
|
||||
onJsonChanged: {
|
||||
if(isFirst == true)
|
||||
{
|
||||
//jsonModel.remove(0)
|
||||
jsonModel.clear()
|
||||
jsonModel.set(0,json)
|
||||
isFirst = false
|
||||
}
|
||||
else
|
||||
{
|
||||
jsonModel.append(json)
|
||||
|
||||
console.log(json)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
property ListModel model : ListModel { id: jsonModel }//总的模型
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
property var paraJson: {
|
||||
"label": "",
|
||||
"units": "",
|
||||
"defaultValue": 3,
|
||||
"decimalPlaces": 2
|
||||
}
|
||||
|
||||
onParaJsonChanged: {
|
||||
paramModel.append(paraJson)
|
||||
}
|
||||
|
||||
property ListModel _paramModel : ListModel { id: paramModel }//参数的模型
|
||||
|
||||
|
||||
|
||||
Rectangle {
|
||||
@@ -151,6 +202,7 @@ Rectangle {
|
||||
Text {
|
||||
id: seq_text
|
||||
text: number
|
||||
font.family: "Arial"
|
||||
clip: true
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
@@ -185,7 +237,7 @@ Rectangle {
|
||||
|
||||
Text {
|
||||
id: mav_cmd_text
|
||||
text: qsTr(friendlyName)
|
||||
text: ""
|
||||
clip: true
|
||||
anchors.rightMargin: 0
|
||||
anchors.bottomMargin: 0
|
||||
@@ -195,6 +247,12 @@ Rectangle {
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
anchors.fill: parent
|
||||
font.pixelSize: 12
|
||||
|
||||
onTextChanged: {
|
||||
//console.log(text)
|
||||
//console.log(jsonModel.get(0).friendlyName)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
@@ -230,6 +288,88 @@ Rectangle {
|
||||
radius: 9
|
||||
clip: true
|
||||
|
||||
Rectangle {
|
||||
id: rectangle
|
||||
color: "#eedbfe"
|
||||
radius: 10
|
||||
anchors.bottomMargin: 8
|
||||
anchors.topMargin: 8
|
||||
anchors.rightMargin: 8
|
||||
anchors.leftMargin: 8
|
||||
anchors.fill: parent
|
||||
visible: isSettingCategory?(false):(true)
|
||||
|
||||
ListView {
|
||||
id : param_listView
|
||||
anchors.bottomMargin: 8
|
||||
anchors.topMargin: 8
|
||||
anchors.rightMargin: 8
|
||||
anchors.leftMargin: 8
|
||||
anchors.fill: parent
|
||||
|
||||
model: paramModel
|
||||
delegate: paramDelegate
|
||||
spacing: 5
|
||||
clip: true
|
||||
focus: true
|
||||
}
|
||||
|
||||
Component {
|
||||
id: paramDelegate
|
||||
Rectangle {
|
||||
id: rect_param1
|
||||
x: 8
|
||||
y: 8
|
||||
width: 233
|
||||
height: 34
|
||||
color: "#ffffff"
|
||||
radius: 6
|
||||
|
||||
Label {
|
||||
x: 3
|
||||
y: 7
|
||||
width: 47
|
||||
height: 21
|
||||
text: label
|
||||
font.pointSize: 12
|
||||
font.family: "Arial"
|
||||
}
|
||||
|
||||
Label {
|
||||
x: 180
|
||||
y: 8
|
||||
|
||||
text: units
|
||||
font.pointSize: 12
|
||||
font.family: "Arial"
|
||||
}
|
||||
|
||||
TextEdit {
|
||||
id: textEdit
|
||||
x: 56
|
||||
y: 7
|
||||
width: 129
|
||||
height: 21
|
||||
text: defaultValue
|
||||
visible: true
|
||||
clip: false
|
||||
cursorVisible: false
|
||||
overwriteMode: false
|
||||
persistentSelection: true
|
||||
selectByMouse: true
|
||||
antialiasing: true
|
||||
font.family: "Arial"
|
||||
font.bold: true
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
font.pixelSize: 13
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
ListView {
|
||||
id : m_listView
|
||||
anchors.bottomMargin: 8
|
||||
@@ -238,7 +378,7 @@ Rectangle {
|
||||
anchors.leftMargin: 8
|
||||
anchors.fill: parent
|
||||
|
||||
model: json
|
||||
model: jsonModel
|
||||
delegate: numberDelegate
|
||||
spacing: 5
|
||||
clip: true
|
||||
@@ -251,18 +391,20 @@ Rectangle {
|
||||
|
||||
Rectangle {
|
||||
width: ListView.view.width
|
||||
height: 40
|
||||
color: ListView.isCurrentItem?"#157efb":"#53d769" //选中颜色设置
|
||||
height: ListView.isCurrentItem?100:40
|
||||
color: ListView.isCurrentItem?"#157efb":"#53d769"
|
||||
border.color: Qt.lighter(color, 1.1)
|
||||
radius: 10
|
||||
|
||||
|
||||
|
||||
Text {
|
||||
id:friendlyNameText
|
||||
anchors.top: parent.top
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.topMargin: 10
|
||||
font.pixelSize: 10
|
||||
text: modelData
|
||||
text: (friendlyName == null)?(rawName):(friendlyName)
|
||||
}
|
||||
|
||||
TextArea {
|
||||
@@ -270,16 +412,17 @@ Rectangle {
|
||||
|
||||
anchors.top:friendlyNameText.bottom
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.left: parent.left
|
||||
anchors.topMargin: 10
|
||||
anchors.leftMargin: 10
|
||||
anchors.rightMargin: 10
|
||||
|
||||
width: parent.width
|
||||
height: parent.height - friendlyNameText.height
|
||||
|
||||
visible: (parent.height == 100)?true:false
|
||||
font.pixelSize: 10
|
||||
text: description
|
||||
visible: false
|
||||
text: (description == null)?(""):(description)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -290,27 +433,35 @@ Rectangle {
|
||||
onClicked:{
|
||||
m_listView.currentIndex = index //实现item切换
|
||||
isSettingCategory = false
|
||||
mav_cmd_text.text = friendlyNameText.text
|
||||
|
||||
paraJson = jsonModel.get(index)
|
||||
|
||||
friendlyName = friendlyNameText.text
|
||||
}
|
||||
|
||||
|
||||
onEntered: {
|
||||
m_listView.currentIndex = index //实现item切换
|
||||
parent.height = 100
|
||||
descriptionText.visible = true
|
||||
m_listView.currentIndex = index //实现item切换
|
||||
mav_cmd_text.text = friendlyNameText.text
|
||||
|
||||
}
|
||||
onExited: {
|
||||
descriptionText.visible = false
|
||||
mav_cmd_text.text = friendlyNameText.text
|
||||
}
|
||||
|
||||
onExited: {
|
||||
parent.height = 40
|
||||
descriptionText.visible = false
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -329,3 +480,5 @@ Rectangle {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user