/*
* Obsługuje typy (opis typów w Core):
*
* 2
*
*/
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 : "0;1;0;100"
property string prop_p_1 : ""
property string prv_div : "0"
property int prv_value_change : 1
property int prv_value_min : 0
property int prv_value_max : 100
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 wartosc)
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 addValue(a_value) {
prop_setting_value += a_value;
if (prop_setting_value > prv_value_max) {
prop_setting_value = prv_value_max;
}
if (prop_setting_value < prv_value_min) {
prop_setting_value = prv_value_min;
}
valueChanged(prop_index, prop_setting_value);
}
Timer {
id: timer
property int prv_timer_interval_default : 170
property int prv_timer_interval : prv_timer_interval_default
property bool prv_timer_enabled : false
property int prv_timer_action : 0
interval: prv_timer_interval
running: true
repeat: true
onTriggered: {
if (prv_timer_enabled) {
if (prv_timer_interval > 10)
prv_timer_interval = prv_timer_interval * 0.9;
if (prv_timer_action) {
addValue(prv_value_change)
} else {
addValue(-prv_value_change)
}
} else {
prv_timer_interval = prv_timer_interval_default
}
}
}
Component.onCompleted: {
valueChanged.connect(updateValue);
commitValue.connect(setValue);
var tmp_value = prop_p_0.split(";");
prv_div = tmp_value[0];
prv_value_change = tmp_value[1];
prv_value_min = tmp_value[2];
prv_value_max = tmp_value[3];
}
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
onPressed: {
addValue(-prv_value_change)
}
onPressAndHold: {
timer.prv_timer_enabled = true
timer.prv_timer_action = 0
}
onReleased: {
timer.prv_timer_enabled = false
}
}
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
anchors.centerIn: parent
color: "#6e6e6e"
text: funct_getValue(prop_type, prop_setting_value, prv_div, prop_p_1, 1)
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
font.family: "Mukti Narrow"
font.strikeout: false
font.bold: false
font.italic: false
style: Text.Normal
textFormat: Text.RichText
font.pixelSize: 0.6 * parent.height
}
}
Item {
id: itm_plus
Layout.preferredHeight: 70
Layout.preferredWidth: 38
MouseArea {
anchors.fill: parent
onPressed: {
addValue(prv_value_change)
}
onPressAndHold: {
timer.prv_timer_enabled = true
timer.prv_timer_action = 1
}
onReleased: {
timer.prv_timer_enabled = false
}
}
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
}
}
}
}
}