Add offset profiles

Addresses #149
This commit is contained in:
Kung-vr
2019-10-02 15:25:03 +09:00
parent d3b4d30807
commit 6dc7bc6837
6 changed files with 292 additions and 3 deletions
+144 -1
View File
@@ -8,6 +8,69 @@ import "common"
MyStackViewPage {
headerText: "Space Offsets"
MyDialogOkPopup {
id: offsetMessageDialog
function showMessage(title, text) {
dialogTitle = title
dialogText = text
open()
}
}
MyDialogOkCancelPopup {
id: offsetDeleteProfileDialog
property int profileIndex: -1
dialogTitle: "Delete Profile"
dialogText: "Do you really want to delete this profile?"
onClosed: {
if (okClicked) {
MoveCenterTabController.deleteOffsetProfile(profileIndex)
}
}
}
MyDialogOkCancelPopup {
id: offsetNewProfileDialog
dialogTitle: "Create New Profile"
dialogWidth: 800
dialogHeight: 400
dialogContentItem: ColumnLayout {
RowLayout {
Layout.topMargin: 16
Layout.leftMargin: 16
Layout.rightMargin: 16
MyText {
text: "Name: "
}
MyTextField {
id: offsetNewProfileName
keyBoardUID: 105
color: "#cccccc"
text: ""
Layout.fillWidth: true
font.pointSize: 20
function onInputEvent(input) {
offsetNewProfileName.text = input
}
}
}
}
onClosed: {
if (okClicked) {
if (offsetNewProfileName.text == "") {
offsetMessageDialog.showMessage("Create New Profile", "ERROR: Empty profile name.")
} else {
MoveCenterTabController.addOffsetProfile(offsetNewProfileName.text)
}
}
}
function openPopup() {
offsetNewProfileName.text = ""
open()
}
}
content: ColumnLayout {
spacing: 18
@@ -29,6 +92,74 @@ MyStackViewPage {
text: "Settings Tab: 'Disable Motion in Seated Mode' checked"
}
ColumnLayout {
Layout.bottomMargin: 32
spacing: 18
RowLayout {
spacing: 18
MyText {
text: "Profile:"
}
MyComboBox {
id: offsetProfileComboBox
Layout.maximumWidth: 799
Layout.minimumWidth: 799
Layout.preferredWidth: 799
Layout.fillWidth: true
model: [""]
onCurrentIndexChanged: {
if (currentIndex > 0) {
offsetApplyProfileButton.enabled = true
offsetDeleteProfileButton.enabled = true
} else {
offsetApplyProfileButton.enabled = false
offsetDeleteProfileButton.enabled = false
}
}
}
MyPushButton {
id: offsetApplyProfileButton
enabled: false
Layout.preferredWidth: 200
text: "Apply"
onClicked: {
if (offsetProfileComboBox.currentIndex > 0) {
MoveCenterTabController.applyOffsetProfile(offsetProfileComboBox.currentIndex - 1)
offsetProfileComboBox.currentIndex = 0
}
}
}
}
RowLayout {
spacing: 18
Item {
Layout.fillWidth: true
}
MyPushButton {
id: offsetDeleteProfileButton
enabled: false
Layout.preferredWidth: 200
text: "Delete Profile"
onClicked: {
if (offsetProfileComboBox.currentIndex > 0) {
offsetDeleteProfileDialog.profileIndex = offsetProfileComboBox.currentIndex - 1
offsetDeleteProfileDialog.open()
}
}
}
MyPushButton {
Layout.preferredWidth: 200
text: "New Profile"
onClicked: {
offsetNewProfileDialog.openPopup()
}
}
}
}
GroupBox {
Layout.fillWidth: true
id: offsetsGroupBox
@@ -416,6 +547,7 @@ MyStackViewPage {
resetButtonRow.visible = false
seatedDisableWarningText.visible = false
}
reloadOffsetProfiles()
}
Connections {
@@ -481,8 +613,19 @@ MyStackViewPage {
seatedDisableWarningText.visible = false
}
}
onOffsetProfilesUpdated: {
reloadOffsetProfiles()
}
}
}
function reloadOffsetProfiles() {
var profiles = [""]
var profileCount = MoveCenterTabController.getOffsetProfileCount()
for (var i = 0; i < profileCount; i++) {
profiles.push(MoveCenterTabController.getOffsetProfileName(i))
}
offsetProfileComboBox.currentIndex = 0
offsetProfileComboBox.model = profiles
}
}