2023-07-04 19:57:59 +02:00
|
|
|
// Copyright (C) 2023 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2023-07-27 12:00:45 +02:00
|
|
|
|
2023-07-04 19:57:59 +02:00
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Controls
|
2023-07-27 12:00:45 +02:00
|
|
|
import HelperWidgets as HelperWidgets
|
|
|
|
|
import StudioControls as StudioControls
|
|
|
|
|
import StudioTheme as StudioTheme
|
2023-07-04 19:57:59 +02:00
|
|
|
|
2023-07-27 12:00:45 +02:00
|
|
|
Column {
|
|
|
|
|
id: root
|
2023-07-04 19:57:59 +02:00
|
|
|
|
2023-07-27 12:00:45 +02:00
|
|
|
readonly property real horizontalSpacing: 10
|
2023-08-14 11:03:02 +02:00
|
|
|
readonly property real verticalSpacing: 16
|
2023-07-27 12:00:45 +02:00
|
|
|
readonly property real columnWidth: (root.width - root.horizontalSpacing) / 2
|
|
|
|
|
|
2023-08-29 18:10:37 +02:00
|
|
|
property var backend
|
|
|
|
|
|
2023-07-27 12:00:45 +02:00
|
|
|
|
2023-08-29 18:10:37 +02:00
|
|
|
/* replaced by ConnectionModelStatementDelegate defined in C++
|
2023-07-27 12:00:45 +02:00
|
|
|
enum ActionType {
|
|
|
|
|
CallFunction,
|
|
|
|
|
Assign,
|
|
|
|
|
ChangeState,
|
|
|
|
|
SetProperty,
|
|
|
|
|
PrintMessage,
|
|
|
|
|
Custom
|
2023-08-29 18:10:37 +02:00
|
|
|
} */
|
2023-07-27 12:00:45 +02:00
|
|
|
|
|
|
|
|
y: StudioTheme.Values.popupMargin
|
|
|
|
|
width: parent.width
|
|
|
|
|
spacing: root.verticalSpacing
|
|
|
|
|
|
|
|
|
|
Row {
|
|
|
|
|
spacing: root.horizontalSpacing
|
|
|
|
|
|
2023-08-31 16:24:18 +02:00
|
|
|
PopupLabel { text: qsTr("Signal"); tooltip: qsTr("The name of the signal.") }
|
|
|
|
|
PopupLabel { text: qsTr("Action"); tooltip: qsTr("The type of the action.") }
|
2023-07-27 12:00:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Row {
|
|
|
|
|
spacing: root.horizontalSpacing
|
2023-07-04 19:57:59 +02:00
|
|
|
|
2023-07-27 12:00:45 +02:00
|
|
|
StudioControls.TopLevelComboBox {
|
|
|
|
|
id: signal
|
2023-08-14 11:03:02 +02:00
|
|
|
style: StudioTheme.Values.connectionPopupControlStyle
|
2023-07-27 12:00:45 +02:00
|
|
|
width: root.columnWidth
|
2023-08-29 18:10:37 +02:00
|
|
|
|
|
|
|
|
model: backend.signal.name.model ?? 0
|
|
|
|
|
|
|
|
|
|
onActivated: backend.signal.name.activateIndex(signal.currentIndex)
|
|
|
|
|
property int currentTypeIndex: backend.signal.name.currentIndex ?? 0
|
|
|
|
|
onCurrentTypeIndexChanged: signal.currentIndex = signal.currentTypeIndex
|
2023-07-04 19:57:59 +02:00
|
|
|
}
|
|
|
|
|
|
2023-07-27 12:00:45 +02:00
|
|
|
StudioControls.TopLevelComboBox {
|
|
|
|
|
id: action
|
2023-08-14 11:03:02 +02:00
|
|
|
style: StudioTheme.Values.connectionPopupControlStyle
|
2023-07-27 12:00:45 +02:00
|
|
|
width: root.columnWidth
|
|
|
|
|
textRole: "text"
|
|
|
|
|
valueRole: "value"
|
2023-08-29 18:10:37 +02:00
|
|
|
///model.getData(currentIndex, "role")
|
|
|
|
|
property int indexFromBackend: indexOfValue(backend.actionType)
|
|
|
|
|
onIndexFromBackendChanged: action.currentIndex = action.indexFromBackend
|
|
|
|
|
onActivated: backend.changeActionType(action.currentValue)
|
2023-07-27 12:00:45 +02:00
|
|
|
|
|
|
|
|
model: [
|
2023-08-29 18:10:37 +02:00
|
|
|
{ value: ConnectionModelStatementDelegate.CallFunction, text: qsTr("Call Function") },
|
|
|
|
|
{ value: ConnectionModelStatementDelegate.Assign, text: qsTr("Assign") },
|
|
|
|
|
{ value: ConnectionModelStatementDelegate.ChangeState, text: qsTr("Change State") },
|
|
|
|
|
{ value: ConnectionModelStatementDelegate.SetProperty, text: qsTr("Set Property") },
|
|
|
|
|
{ value: ConnectionModelStatementDelegate.PrintMessage, text: qsTr("Print Message") },
|
2023-08-31 16:24:18 +02:00
|
|
|
{ value: ConnectionModelStatementDelegate.Custom, text: qsTr("Unknown") }
|
2023-07-27 12:00:45 +02:00
|
|
|
]
|
2023-07-04 19:57:59 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-31 18:02:29 +02:00
|
|
|
StatementEditor {
|
2023-09-01 10:08:03 +02:00
|
|
|
actionType: action.currentValue ?? ConnectionModelStatementDelegate.Custom
|
2023-08-31 18:02:29 +02:00
|
|
|
id: container
|
|
|
|
|
horizontalSpacing: root.horizontalSpacing
|
|
|
|
|
columnWidth: root.columnWidth
|
|
|
|
|
statement: backend.okStatement
|
|
|
|
|
spacing: root.verticalSpacing
|
2023-07-27 12:00:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HelperWidgets.AbstractButton {
|
2023-08-14 11:03:02 +02:00
|
|
|
style: StudioTheme.Values.connectionPopupButtonStyle
|
|
|
|
|
width: 160
|
2023-07-27 12:00:45 +02:00
|
|
|
buttonIcon: qsTr("Add Condition")
|
|
|
|
|
iconSize: StudioTheme.Values.baseFontSize
|
|
|
|
|
iconFont: StudioTheme.Constants.font
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2023-08-29 18:10:37 +02:00
|
|
|
visible: action.currentValue !== ConnectionModelStatementDelegate.Custom && !backend.hasCondition
|
|
|
|
|
|
|
|
|
|
onClicked: backend.addCondition()
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-31 18:02:29 +02:00
|
|
|
HelperWidgets.AbstractButton {
|
2023-08-29 18:10:37 +02:00
|
|
|
style: StudioTheme.Values.connectionPopupButtonStyle
|
|
|
|
|
width: 160
|
|
|
|
|
buttonIcon: qsTr("Remove Condition")
|
|
|
|
|
iconSize: StudioTheme.Values.baseFontSize
|
|
|
|
|
iconFont: StudioTheme.Constants.font
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
visible: action.currentValue !== ConnectionModelStatementDelegate.Custom && backend.hasCondition
|
|
|
|
|
|
|
|
|
|
onClicked: backend.removeCondition()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Flow {
|
|
|
|
|
spacing: root.horizontalSpacing
|
|
|
|
|
width: root.width
|
|
|
|
|
Repeater {
|
|
|
|
|
|
|
|
|
|
model: backend.conditionListModel
|
|
|
|
|
Text {
|
|
|
|
|
text: value
|
|
|
|
|
color: "white"
|
|
|
|
|
Rectangle {
|
|
|
|
|
z: -1
|
|
|
|
|
opacity: 0.2
|
|
|
|
|
color: {
|
|
|
|
|
if (type === ConditionListModel.Invalid)
|
2023-08-31 18:02:29 +02:00
|
|
|
return "red"
|
2023-08-29 18:10:37 +02:00
|
|
|
if (type === ConditionListModel.Operator)
|
2023-08-31 18:02:29 +02:00
|
|
|
return "blue"
|
2023-08-29 18:10:37 +02:00
|
|
|
if (type === ConditionListModel.Literal)
|
|
|
|
|
return "green"
|
|
|
|
|
if (type === ConditionListModel.Variable)
|
|
|
|
|
return "yellow"
|
|
|
|
|
}
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TextInput {
|
|
|
|
|
id: commandInput
|
|
|
|
|
width: root.width
|
|
|
|
|
onAccepted: backend.conditionListModel.command(commandInput.text)
|
|
|
|
|
}
|
2023-07-27 12:00:45 +02:00
|
|
|
|
2023-08-29 18:10:37 +02:00
|
|
|
Text {
|
|
|
|
|
text: "invalid " + backend.conditionListModel.error
|
|
|
|
|
visible: !backend.conditionListModel.valid
|
2023-07-27 12:00:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Editor
|
|
|
|
|
Rectangle {
|
|
|
|
|
id: editor
|
|
|
|
|
width: parent.width
|
2023-08-14 11:03:02 +02:00
|
|
|
height: 150
|
|
|
|
|
color: StudioTheme.Values.themeToolbarBackground
|
2023-07-04 19:57:59 +02:00
|
|
|
|
|
|
|
|
Text {
|
2023-07-27 12:00:45 +02:00
|
|
|
anchors.centerIn: parent
|
2023-08-29 18:10:37 +02:00
|
|
|
text: backend.source
|
2023-07-27 12:00:45 +02:00
|
|
|
color: StudioTheme.Values.themeTextColor
|
|
|
|
|
font.pixelSize: StudioTheme.Values.myFontSize
|
2023-07-04 19:57:59 +02:00
|
|
|
}
|
|
|
|
|
|
2023-07-27 12:00:45 +02:00
|
|
|
HelperWidgets.AbstractButton {
|
|
|
|
|
id: editorButton
|
2023-07-04 19:57:59 +02:00
|
|
|
|
2023-07-27 12:00:45 +02:00
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.margins: 4
|
2023-07-04 19:57:59 +02:00
|
|
|
|
2023-07-27 12:00:45 +02:00
|
|
|
style: StudioTheme.Values.viewBarButtonStyle
|
|
|
|
|
buttonIcon: StudioTheme.Constants.edit_medium
|
|
|
|
|
tooltip: qsTr("Add something.")
|
|
|
|
|
onClicked: console.log("OPEN EDITOR")
|
2023-07-04 19:57:59 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|