X-Git-Url: http://git.maemo.org/git/?p=mdictionary;a=blobdiff_plain;f=src%2Fmdictionary%2Fqml%2FMySpinBox.qml;fp=src%2Fmdictionary%2Fqml%2FMySpinBox.qml;h=a30ecbabf79bef76bded53ab5d9a0793a0701c86;hp=9f0d47ced03295db6ef7a9f1b77ab0cbbda68d5b;hb=11ada56e37ed724c4777ad2ac555eabe19c65c12;hpb=ebd4c2c97364e18aae17e790155b8f4060981c37 diff --git a/src/mdictionary/qml/MySpinBox.qml b/src/mdictionary/qml/MySpinBox.qml index 9f0d47c..a30ecba 100644 --- a/src/mdictionary/qml/MySpinBox.qml +++ b/src/mdictionary/qml/MySpinBox.qml @@ -7,16 +7,22 @@ Rectangle { 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(valuemaxValue)?(maxValue):(stringToInt(text_input1.text)+singleStep); + else if (event.key == Qt.Key_Down){ + text_input1.text=((stringToInt(text_input1.text)-singleStep)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; } @@ -62,8 +86,11 @@ Rectangle { running: false; repeat: true onTriggered:{ - if(mouseAreaDown.pressedButtons==Qt.LeftButton) - 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; @@ -124,19 +151,21 @@ Rectangle { height: rectangle1.height/2; anchors.right: parent.right anchors.bottom: parent.bottom - onClicked: text_input1.text=((stringToInt(text_input1.text)-1)