property int maxValue:500;
property int minValue:0;
property alias value:text_input1.text
+ property bool isTextInMinValue:true;
+ property string textInMinValue:"inf";
+ property int singleStep: 2;
signal valueChange(int intiger);
function stringToInt(string){
var value=0;
var pow10=1;
- for (var i=string.length-1;i>=0;i--){
- value+=(string.charCodeAt(i)-48)*pow10;
- pow10= pow10*10;
- }
+ if(isTextInMinValue && textInMinValue==string)
+ value=minValue;
+ else
+ for (var i=string.length-1;i>=0;i--){
+ value+=(string.charCodeAt(i)-48)*pow10;
+ pow10= pow10*10;
+ }
if(value>maxValue)
return maxValue;
if(value<minValue)
selectByMouse: true;
font.pixelSize: rectangle1.height * .5;
onCursorPositionChanged: moveCursorSelection(cursorPosition);
- onTextChanged: rectangle1.valueChange(stringToInt(text_input1.text));
+ onTextChanged:{
+ if(isTextInMinValue && text_input1.text!="" && stringToInt(text_input1.text)==minValue)
+ text_input1.text=textInMinValue;
+
+ rectangle1.valueChange(stringToInt(text_input1.text));
+ }
onFocusChanged: {
if(focus==false)
text=stringToInt(text);
repeat: true
onTriggered:{
if(mouseAreaUp.pressedButtons==Qt.LeftButton)
- text_input1.text=((stringToInt(text_input1.text)+1)>maxValue)?(maxValue):(stringToInt(text_input1.text)+1);
+ text_input1.text=((stringToInt(text_input1.text)+singleStep)>maxValue)?(maxValue):(stringToInt(text_input1.text)+singleStep);
else
running=false;
}
running: false;
repeat: true
onTriggered:{
- if(mouseAreaDown.pressedButtons==Qt.LeftButton)
- text_input1.text=((stringToInt(text_input1.text)-1)<minValue)?(minValue):(stringToInt(text_input1.text)-1);
+ if(mouseAreaDown.pressedButtons==Qt.LeftButton){
+ text_input1.text=((stringToInt(text_input1.text)-singleStep)<minValue)?(minValue):(stringToInt(text_input1.text)-singleStep);
+ if(isTextInMinValue && stringToInt(text_input1.text)==minValue)
+ text_input1.text=textInMinValue
+ }
else
running=false;
}
height: rectangle1.height/2;
anchors.right: parent.right
anchors.top: parent.top
- onClicked: text_input1.text=((stringToInt(text_input1.text)+1)>maxValue)?(maxValue):(stringToInt(text_input1.text)+1);
+ onClicked: text_input1.text=((stringToInt(text_input1.text)+singleStep)>maxValue)?(maxValue):(stringToInt(text_input1.text)+singleStep);
onPressAndHold:{
timerUp.restart;
timerUp.running=true;
height: rectangle1.height/2;
anchors.right: parent.right
anchors.bottom: parent.bottom
- onClicked: text_input1.text=((stringToInt(text_input1.text)-1)<minValue)?(minValue):(stringToInt(text_input1.text)-1);
+ onClicked:{
+ text_input1.text=((stringToInt(text_input1.text)-singleStep)<minValue)?(minValue):(stringToInt(text_input1.text)-singleStep);
+ if(isTextInMinValue && stringToInt(text_input1.text)==minValue)
+ text_input1.text=textInMinValue
+ }
onPressAndHold:{
timerDown.restart;
timerDown.running=true;
}
}
-
- /* states: [
- State {
- name: "DisableState"; when: rectangle1.enabled==false;
- PropertyChanges { target: shadeDisable; z: 3; opacity: 0.5 }
- }
- ]
- */
}