2019-07-13 19:39:01 +10:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
2019-04-28 08:00:28 +10:00
|
|
|
|
2019-08-18 03:01:43 +10:00
|
|
|
HRectangle {
|
2019-04-28 08:00:28 +10:00
|
|
|
id: interfaceBox
|
2019-08-18 03:01:43 +10:00
|
|
|
color: theme.controls.box.background
|
|
|
|
implicitWidth: Math.min(
|
|
|
|
parent.width, theme.minimumSupportedWidthPlusSpacing * multiplyWidth
|
|
|
|
)
|
|
|
|
implicitHeight: childrenRect.height
|
|
|
|
|
|
|
|
property real multiplyWidth: 1.0
|
|
|
|
property real multiplyHorizontalSpacing: 1.5
|
|
|
|
property real multiplyVerticalSpacing: 1.5
|
|
|
|
|
|
|
|
property int horizontalSpacing:
|
|
|
|
Math.min(theme.spacing * width / 400, theme.spacing) *
|
|
|
|
multiplyHorizontalSpacing
|
|
|
|
|
|
|
|
property int verticalSpacing: theme.spacing * multiplyVerticalSpacing
|
2019-04-28 08:00:28 +10:00
|
|
|
|
|
|
|
property alias title: interfaceTitle.text
|
|
|
|
property alias buttonModel: interfaceButtonsRepeater.model
|
|
|
|
property var buttonCallbacks: []
|
|
|
|
property string enterButtonTarget: ""
|
|
|
|
|
|
|
|
default property alias body: interfaceBody.children
|
|
|
|
|
|
|
|
function clickEnterButtonTarget() {
|
2019-07-18 19:18:13 +10:00
|
|
|
for (let i = 0; i < buttonModel.length; i++) {
|
|
|
|
let btn = interfaceButtonsRepeater.itemAt(i)
|
2019-08-17 06:44:28 +10:00
|
|
|
if (btn.enabled && btn.name === enterButtonTarget) btn.clicked()
|
2019-04-28 08:00:28 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-18 03:01:43 +10:00
|
|
|
Keys.onReturnPressed: clickEnterButtonTarget()
|
|
|
|
Keys.onEnterPressed: clickEnterButtonTarget()
|
|
|
|
|
2019-04-29 02:47:51 +10:00
|
|
|
HColumnLayout {
|
2019-04-28 08:00:28 +10:00
|
|
|
id: mainColumn
|
2019-08-18 03:01:43 +10:00
|
|
|
width: parent.width
|
|
|
|
spacing: interfaceBox.verticalSpacing
|
2019-04-28 08:00:28 +10:00
|
|
|
|
2019-08-18 03:01:43 +10:00
|
|
|
HLabel {
|
|
|
|
id: interfaceTitle
|
|
|
|
visible: Boolean(text)
|
|
|
|
font.pixelSize: theme.fontSize.bigger
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
wrapMode: Text.Wrap
|
2019-04-28 08:00:28 +10:00
|
|
|
|
2019-08-18 03:01:43 +10:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.topMargin: interfaceBox.verticalSpacing
|
|
|
|
Layout.leftMargin: interfaceBox.horizontalSpacing
|
|
|
|
Layout.rightMargin: interfaceBox.horizontalSpacing
|
2019-04-28 08:00:28 +10:00
|
|
|
}
|
|
|
|
|
2019-08-18 03:01:43 +10:00
|
|
|
HColumnLayout {
|
|
|
|
id: interfaceBody
|
|
|
|
spacing: interfaceBox.verticalSpacing
|
2019-04-28 11:07:20 +10:00
|
|
|
|
2019-08-18 03:01:43 +10:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.leftMargin: interfaceBox.horizontalSpacing
|
|
|
|
Layout.rightMargin: interfaceBox.horizontalSpacing
|
|
|
|
}
|
2019-04-28 11:07:20 +10:00
|
|
|
|
2019-04-28 08:00:28 +10:00
|
|
|
HRowLayout {
|
|
|
|
Repeater {
|
|
|
|
id: interfaceButtonsRepeater
|
|
|
|
model: []
|
|
|
|
|
2019-08-21 07:41:24 +10:00
|
|
|
HButton {
|
2019-04-28 08:00:28 +10:00
|
|
|
property string name: modelData.name
|
|
|
|
|
|
|
|
id: button
|
|
|
|
text: modelData.text
|
2019-08-22 05:45:13 +10:00
|
|
|
icon.name: modelData.iconName || ""
|
2019-08-21 07:41:24 +10:00
|
|
|
enabled: modelData.enabled
|
2019-04-28 08:00:28 +10:00
|
|
|
onClicked: buttonCallbacks[modelData.name](button)
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
2019-08-18 03:01:43 +10:00
|
|
|
Layout.preferredHeight: theme.baseElementsHeight
|
2019-04-28 08:00:28 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|