draft of spinbox
[mdictionary] / src / mdictionary / qml / MySpinBox.qml
1 import Qt 4.7
2
3 Rectangle {
4     id: rectangle1
5     radius: 10
6     border.color: "#000666";
7     property int maxValue:500;
8     property int minValue:0;
9     property alias value:text_input1.text
10
11     TextInput {
12         id: text_input1
13         x: 1
14         width: rectangle1.width-15
15         height: rectangle1.height*0.6;
16         text: "0"
17         anchors.centerIn: parent
18         validator: IntValidator{bottom: 0; top: 500;}
19         transformOrigin: Item.Left
20         selectByMouse: true;
21         font.pixelSize: rectangle1.height * .5;
22         onCursorPositionChanged:  moveCursorSelection(cursorPosition);
23         focus: rectangle1.focus;
24  /*       Keys.onPressed: {
25             if ((event.key == Qt.Key_Enter) || (event.key == Qt.Key_Return))
26                 rectangle1.enterPressed(text_input1.text)
27         }
28 */
29     }
30
31     Rectangle {
32         id: shadeDisable
33         anchors.centerIn: parent;
34         radius: parent.radius
35         color: "grey";
36         opacity: 0
37         width:  parent.width;
38         height: parent.height;
39     }
40
41     Image {
42         id: imageUp
43         z:4;
44         anchors.right: parent.right
45         anchors.top: parent.top
46         anchors.rightMargin: 2
47         anchors.topMargin: 2
48         width: 11;
49         height: 6;
50
51         source: "qrc:/button/up_enable.png";
52     }
53
54     Image {
55         id: imageDown
56         z:4;
57         width: 11;
58         height: 6;
59         anchors.right: parent.right
60         anchors.bottom: parent.bottom
61         anchors.rightMargin: 2
62         anchors.bottomMargin: 2
63         source: "qrc:/button/down_enable.png";
64     }
65
66     MouseArea {
67         id: mouseAreaUp
68         anchors.right: parent.right
69         anchors.top: parent.top
70         anchors.rightMargin: 2
71         anchors.topMargin: 2
72         width: 11;
73         height: rectangle1/2;
74         onClicked: {
75             console.log("t1");
76             //rectangle.clicked();
77         }
78     }
79
80     MouseArea {
81         id: mouseAreaDown
82         anchors.right: parent.right
83         anchors.top: parent.top
84         anchors.rightMargin: 2
85         anchors.topMargin: 2
86         width: 11;
87         height: rectangle1/2;
88         onClicked: {
89             console.log("t2");
90             //rectangle.clicked();
91         }
92
93     }
94
95     states: [
96         State {
97             name: "DisableState"; when: rectangle1.enabled==false;
98             PropertyChanges { target: shadeDisable; z: 3; opacity: 0.5 }
99         }
100     ]
101 }
102