Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter editor usability #12282

Merged
merged 2 commits into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
253 changes: 162 additions & 91 deletions src/QmlControls/ParameterEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -37,63 +37,15 @@ Item {
id: controller
}

//---------------------------------------------
//-- Header
Row {
id: header
anchors.left: parent.left
anchors.right: parent.right
spacing: ScreenTools.defaultFontPixelWidth

Timer {
id: clearTimer
interval: 100;
running: false;
repeat: false
onTriggered: {
searchText.text = ""
controller.searchText = ""
}
}

QGCLabel {
anchors.verticalCenter: parent.verticalCenter
text: qsTr("Search:")
}

QGCTextField {
id: searchText
text: controller.searchText
onDisplayTextChanged: controller.searchText = displayText
anchors.verticalCenter: parent.verticalCenter
Timer {
id: clearTimer
interval: 100;
running: false;
repeat: false
onTriggered: {
searchText.text = ""
controller.searchText = ""
}

QGCButton {
text: qsTr("Clear")
onClicked: {
if(ScreenTools.isMobile) {
Qt.inputMethod.hide();
}
clearTimer.start()
}
anchors.verticalCenter: parent.verticalCenter
}

QGCCheckBox {
text: qsTr("Show modified only")
anchors.verticalCenter: parent.verticalCenter
checked: controller.showModifiedOnly
onClicked: controller.showModifiedOnly = checked
visible: QGroundControl.multiVehicleManager.activeVehicle.px4Firmware
}
} // Row - Header

QGCButton {
anchors.top: header.top
anchors.bottom: header.bottom
anchors.right: parent.right
text: qsTr("Tools")
onClicked: toolsMenu.popup()
}

QGCMenu {
Expand Down Expand Up @@ -148,6 +100,82 @@ Item {
}
}


QGCFileDialog {
id: fileDialog
folder: _appSettings.parameterSavePath
nameFilters: [ qsTr("Parameter Files (*.%1)").arg(_appSettings.parameterFileExtension) , qsTr("All Files (*)") ]

onAcceptedForSave: (file) => {
controller.saveToFile(file)
close()
}

onAcceptedForLoad: (file) => {
close()
if (controller.buildDiffFromFile(file)) {
parameterDiffDialog.createObject(mainWindow).open()
}
}
}

Component {
id: editorDialogComponent

ParameterEditorDialog {
fact: _editorDialogFact
showRCToParam: _showRCToParam
}
}

Component {
id: parameterDiffDialog

ParameterDiffDialog {
paramController: _controller
}
}

RowLayout {
id: header
anchors.left: parent.left
anchors.right: parent.right

RowLayout {
Layout.alignment: Qt.AlignLeft
spacing: ScreenTools.defaultFontPixelWidth

QGCTextField {
id: searchText
placeholderText: qsTr("Search")
onDisplayTextChanged: controller.searchText = displayText
}

QGCButton {
text: qsTr("Clear")
onClicked: {
if(ScreenTools.isMobile) {
Qt.inputMethod.hide();
}
clearTimer.start()
}
}

QGCCheckBox {
text: qsTr("Show modified only")
checked: controller.showModifiedOnly
onClicked: controller.showModifiedOnly = checked
visible: QGroundControl.multiVehicleManager.activeVehicle.px4Firmware
}
}

QGCButton {
Layout.alignment: Qt.AlignRight
text: qsTr("Tools")
onClicked: toolsMenu.popup()
}
}

/// Group buttons
QGCFlickable {
id : groupScroll
Expand Down Expand Up @@ -210,6 +238,83 @@ Item {
}
}

QGCFlickable {
id: parameterScroll
anchors.leftMargin: ScreenTools.defaultFontPixelWidth
anchors.top: header.bottom
anchors.bottom: parent.bottom
anchors.left: _searchFilter ? parent.left : groupScroll.right
anchors.right: parent.right
clip: true
contentHeight: parameterListGridLayout.height
contentWidth: parameterListGridLayout.width

Item {
width: parameterListGridLayout.width
height: parameterListGridLayout.height

GridLayout {
id: parameterListGridLayout
rows: controller.parameters.count
columnSpacing: ScreenTools.defaultFontPixelWidth
flow: GridLayout.TopToBottom

Repeater {
model: controller.parameters

QGCLabel {
text: object.name
property Fact fact: object
}
}

Repeater {
model: controller.parameters

QGCLabel {
Layout.alignment: Qt.AlignRight
Layout.maximumWidth: ScreenTools.defaultFontPixelWidth * 15
color: object.defaultValueAvailable ?
(object.valueEqualsDefault ? qgcPal.text : qgcPal.warningText) :
qgcPal.text
elide: Text.ElideRight
clip: true

text: {
if (object.enumStrings.length === 0) {
return object.valueString + " " + object.units
}
if (object.bitmaskStrings.length != 0) {
return object.selectedBitmaskStrings.join(',')
}
return object.enumStringValue
}
}
}

Repeater {
model: controller.parameters

QGCLabel {
text: object.shortDescription
maximumLineCount: 1
elide: Text.ElideRight
}
}
}

QGCMouseArea {
anchors.fill: parent
onClicked: mouse => {
let control = parameterListGridLayout.childAt(3, mouse.y)
_editorDialogFact = control.fact
editorDialogComponent.createObject(mainWindow).open()
}
}
}
}

/*
/// Parameter list
QGCListView {
id: editorListView
Expand Down Expand Up @@ -290,39 +395,5 @@ Item {
}
}
}

QGCFileDialog {
id: fileDialog
folder: _appSettings.parameterSavePath
nameFilters: [ qsTr("Parameter Files (*.%1)").arg(_appSettings.parameterFileExtension) , qsTr("All Files (*)") ]

onAcceptedForSave: (file) => {
controller.saveToFile(file)
close()
}

onAcceptedForLoad: (file) => {
close()
if (controller.buildDiffFromFile(file)) {
parameterDiffDialog.createObject(mainWindow).open()
}
}
}

Component {
id: editorDialogComponent

ParameterEditorDialog {
fact: _editorDialogFact
showRCToParam: _showRCToParam
}
}

Component {
id: parameterDiffDialog

ParameterDiffDialog {
paramController: _controller
}
}
*/
}
8 changes: 2 additions & 6 deletions src/QmlControls/ParameterEditorDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import QGroundControl.ScreenTools

QGCPopupDialog {
id: root
title: qsTr("Parameter Editor")
title: fact.componentId > 0 ? fact.name : qsTr("Value Editor")

buttons: Dialog.Save | (validate ? 0 : Dialog.Cancel)

property Fact fact
Expand Down Expand Up @@ -204,11 +205,6 @@ QGCPopupDialog {
}
}

QGCLabel {
text: qsTr("Parameter name: ") + fact.name
visible: fact.componentId > 0 // > 0 means it's a parameter fact
}

QGCLabel {
visible: fact.vehicleRebootRequired
text: qsTr("Vehicle reboot required after change")
Expand Down
Loading