/*
* Obsługuje typy (opis typów w Core):
*
* 1
*
*/
import QtQuick 2.3
import QtQuick.Layouts 1.1
Core {
id: container
property string prop_title: ""
property int prop_setting_value : 0
property int prop_index : 0
property int prop_type : 1
property string prop_p_0 : ""
property string prop_p_1 : ""
property int prv_value_index : 0
Layout.fillWidth: true
Layout.minimumWidth: 150
Layout.maximumWidth: 600
Layout.fillHeight: true
Layout.minimumHeight: 100
Layout.maximumHeight: 250
Layout.alignment: Qt.AlignHCenter
// width: 300
// height: 100
color: "#00000000"
signal valueChanged(int a_index, int a_value)
// sygnal z rodzica (zmieniono wartość)
function setValue(a_index, a_setting_value, a_counter_value) {
if (a_index === prop_index) {
if (a_setting_value != 65535) {
prop_setting_value = a_setting_value;
} else {
prop_setting_value = a_counter_value;
}
}
}
function getMaxValueIndex() {
var tmp_key = prop_p_1.split(";");
return tmp_key.length - 1;
}
function valueIndexChanged() {
var tmp_value = prop_p_0.split(";");
prop_setting_value = tmp_value[prv_value_index];
valueChanged(prop_index, prop_setting_value);
}
Component.onCompleted: {
valueChanged.connect(updateValue);
commitValue.connect(setValue);
}
ColumnLayout {
anchors.fill: parent
spacing: 5
Item {
Layout.fillWidth: true
Layout.preferredHeight: 25
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
Text {
text: prop_title
font.pixelSize: parent.height
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
clip: true
wrapMode: Text.WordWrap
elide: Text.ElideRight
}
}
RowLayout{
spacing: 0
Item {
id: itm_minus
Layout.preferredHeight: 70
Layout.preferredWidth: 38
MouseArea {
anchors.fill: parent
onClicked: {
if (prv_value_index) {
--prv_value_index;
} else {
prv_value_index = getMaxValueIndex();
}
valueIndexChanged();
}
}
Image {
source: "../images/C_value_set_01/buttonMinus.svg"
sourceSize.height: height
sourceSize.width: width
height: parent/2
fillMode: Image.PreserveAspectFit
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
}
}
Item {
id: itm_value
Layout.fillHeight: true
Layout.fillWidth: true
Rectangle{
id: rec_value
anchors.fill: parent
radius: 10
border.width: 2
border.color: "#b8b8b8"
color: "#e9e9e9"
}
Text {
id: txt_value
width: 0.7 * parent.width
height: 0.7 * parent.height
anchors.centerIn: parent
color: "#6e6e6e"
text: funct_getValue(prop_type, prop_setting_value, prop_p_0, prop_p_1, 0)
font.family: "Mukti Narrow"
textFormat: Text.StyledText
font.pixelSize: height
minimumPixelSize: 0.1 * height
elide: Text.ElideRight
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
fontSizeMode: Text.Fit
}
}
Item {
id: itm_plus
Layout.preferredHeight: 70
Layout.preferredWidth: 38
MouseArea {
anchors.fill: parent
onClicked: {
if (prv_value_index < getMaxValueIndex()) {
++prv_value_index;
} else {
prv_value_index = 0;
}
valueIndexChanged();
}
}
Image {
source: "../images/C_value_set_01/buttonPlus.svg"
sourceSize.height: height
sourceSize.width: width
height: parent/2
fillMode: Image.PreserveAspectFit
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
}
}
}
}
}