2023-03-14 02:52:16 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
import QtQml.Models 2.14
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
2023-03-22 23:21:44 +00:00
|
|
|
import StatusQ.Controls.Validators 0.1
|
2023-03-14 02:52:16 +00:00
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
import StatusQ.Popups.Dialog 0.1
|
|
|
|
import StatusQ.Core.Utils 0.1
|
|
|
|
|
|
|
|
import shared.controls 1.0
|
|
|
|
|
|
|
|
import "../stores"
|
|
|
|
|
|
|
|
StatusDialog {
|
|
|
|
id: root
|
|
|
|
|
2024-05-22 08:13:39 +00:00
|
|
|
property DevicesStore devicesStore
|
|
|
|
property AdvancedStore advancedStore
|
2023-03-14 02:52:16 +00:00
|
|
|
property var deviceModel
|
|
|
|
|
|
|
|
readonly property string deviceName: d.deviceName
|
|
|
|
|
|
|
|
title: qsTr("Personalize %1").arg(deviceModel.name)
|
|
|
|
width: implicitWidth
|
|
|
|
padding: 16
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
property string deviceName: ""
|
2023-03-22 23:21:44 +00:00
|
|
|
|
|
|
|
function saveNewName() {
|
|
|
|
if (!nameInput.valid)
|
|
|
|
return
|
|
|
|
root.devicesStore.setInstallationName(root.deviceModel.installationId, nameInput.text.trim())
|
|
|
|
root.close()
|
|
|
|
}
|
2023-03-14 02:52:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onOpened: {
|
|
|
|
nameInput.text = deviceModel.name
|
2023-04-29 10:33:08 +00:00
|
|
|
nameInput.forceActiveFocus()
|
2023-03-14 02:52:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
contentItem: ColumnLayout {
|
2023-06-14 13:02:57 +00:00
|
|
|
spacing: 8
|
2023-03-14 02:52:16 +00:00
|
|
|
StatusInput {
|
|
|
|
id: nameInput
|
|
|
|
Layout.fillWidth: true
|
|
|
|
label: qsTr("Device name")
|
2023-03-22 23:21:44 +00:00
|
|
|
validators: [
|
|
|
|
StatusValidator {
|
|
|
|
errorMessage: qsTr("Device name can not be empty")
|
|
|
|
validate: (value) => {
|
|
|
|
return value.trim() !== ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
Keys.onReturnPressed: {
|
|
|
|
d.saveNewName()
|
|
|
|
}
|
2023-03-14 02:52:16 +00:00
|
|
|
}
|
2023-06-14 13:02:57 +00:00
|
|
|
StatusInput {
|
|
|
|
id: idInput
|
|
|
|
Layout.fillWidth: true
|
|
|
|
label: qsTr("Installation ID")
|
|
|
|
enabled: false
|
|
|
|
text: root.deviceModel.installationId
|
|
|
|
visible: root.advancedStore.isDebugEnabled
|
|
|
|
}
|
2023-03-14 02:52:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
footer: StatusDialogFooter {
|
|
|
|
rightButtons: ObjectModel {
|
|
|
|
StatusButton {
|
|
|
|
text: qsTr("Done")
|
2023-03-22 23:21:44 +00:00
|
|
|
enabled: nameInput.valid
|
2023-03-14 02:52:16 +00:00
|
|
|
onClicked : {
|
2023-03-22 23:21:44 +00:00
|
|
|
d.saveNewName()
|
2023-03-14 02:52:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|