5f32049ba372884bcf30c5506b00240e9990055d
[mdictionary] / src / mdictionary / qml / SettingsWidget.qml
1 import Qt 4.7
2
3 Rectangle {
4     id: rectangle1
5     width: 230
6     height:170
7
8     SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
9     color : myPalette.window;
10     focus: true;
11     property int focusIndex:-1;
12
13
14     signal historySizeValueChanged(int intiger);
15     signal searchResulValueChanged(int intiger);
16     signal dictionariesCheckBoxChanged(bool Boolean);
17     signal bookmarksCheckBoxChanged(bool Boolean);
18     signal saveButtonClicked();
19
20     function setMinHistory(intiger){
21         historySpinbox.minValue=intiger;
22     }
23     function setMaxHistory(intiger){
24         historySpinbox.maxValue=intiger;
25     }
26     function setValueHistory(intiger){
27         historySpinbox.value=intiger;
28     }
29
30     function setMaxSearchResult(intiger){
31         searchSpinbox.maxValue=intiger;
32     }
33     function setMinSearchResult(intiger){
34         searchSpinbox.minValue=intiger;
35     }
36     function setValueSearchResult(intiger){
37         searchSpinbox.value=intiger;
38     }
39
40     function setCheckedBookmarks(bool){
41         bookmarkCheckBox.selected=bool;
42     }
43     function setCheckedDictionaries(bool){
44         dictionariesCheckBox.selected=bool;
45     }
46     function setFocus(){
47         if(focusIndex==0){
48             searchSpinbox.setFocus();
49             if(!searchSpinbox.enabled)
50                 focusIndex++;
51         }
52         if(focusIndex==1){
53             historySpinbox.setFocus();
54             if(!historySpinbox.enabled)
55                 focusIndex++;
56         }
57         if(focusIndex==2){
58             bookmarkCheckBox.focus = true
59             if(!bookmarkCheckBox.enabled)
60                 focusIndex++;
61         }
62         if(focusIndex==3){
63             dictionariesCheckBox.focus = true
64             if(!dictionariesCheckBox.enabled)
65                 focusIndex++;
66         }
67         if(focusIndex==4){
68             saveButton.focus = true
69             if(!saveButton.enabled)
70                 focusIndex++;
71         }
72         if(focusIndex>4){
73             focusIndex=-1;
74             focus=true;
75         }
76     }
77
78     Keys.onTabPressed: {
79         focusIndex++;
80         setFocus();
81     }
82
83     Text {
84         id: textSearch
85         width: 120
86         height: paintedHeight+5;
87         text: qsTr("Search result size")
88         anchors.verticalCenterOffset: 2
89         anchors.left: parent.left
90         anchors.verticalCenter: searchSpinbox.verticalCenter
91         font.pixelSize: 12
92     }
93
94     Text {
95         id: textHistory
96         width: 120
97         height: paintedHeight+5;
98         text: qsTr("History size")
99         anchors.verticalCenterOffset: 2
100         anchors.left: parent.left
101         anchors.verticalCenter: historySpinbox.verticalCenter
102         font.pixelSize: 12
103     }
104
105     Text {
106         id: textSearchIn
107         width: 120
108         height: paintedHeight+5;
109         text: qsTr("Search in:")
110         anchors.top: textHistory.bottom
111         anchors.topMargin: 15
112         anchors.left: parent.left
113         font.pixelSize: 12
114     }
115
116     Text {
117         id: textBookmark
118         width: 120
119         height: 20
120         text: qsTr("Bookmarks")
121         anchors.verticalCenterOffset: 2
122         anchors.left: bookmarkCheckBox.right
123         anchors.leftMargin: 10
124         anchors.verticalCenter: bookmarkCheckBox.verticalCenter
125         font.pixelSize: 12
126     }
127
128     Text {
129         id: textDictionaries
130         width: 120
131         height: 20
132         text: qsTr("Dictionaries")
133         anchors.verticalCenterOffset: 2
134         anchors.left: dictionariesCheckBox.right
135         anchors.leftMargin: 10
136         anchors.verticalCenter: dictionariesCheckBox.verticalCenter
137         font.pixelSize: 12
138     }
139
140     MySpinBox {
141         id: searchSpinbox
142         width: 40
143         height: 20;
144         anchors.top: parent.top
145         anchors.topMargin: 10
146         anchors.left: textSearch.right
147         anchors.leftMargin: 20
148         onValueChange: rectangle1.searchResulValueChanged(intiger);
149         onFocusChanged: if(focus) focusIndex=0;
150     }
151
152     MySpinBox {
153         id: historySpinbox
154         width: 40
155         height: 20;
156         anchors.horizontalCenter: searchSpinbox.horizontalCenter
157         anchors.top: searchSpinbox.bottom
158         anchors.topMargin: 10
159         onValueChange: rectangle1.historySizeValueChanged(intiger);
160         onFocusChanged: if(focus) focusIndex=1;
161     }
162
163     Checkbox {
164         id: bookmarkCheckBox
165         width: 20
166         height: 20
167         anchors.left: parent.left
168         anchors.leftMargin: 20
169         anchors.top: textSearchIn.bottom
170         anchors.topMargin: 0
171         onChanged: rectangle1.bookmarksCheckBoxChanged(selected);
172         onFocusChanged: if(focus) focusIndex=2;
173     }
174
175     Checkbox {
176         id: dictionariesCheckBox
177         width: 20
178         height: 20
179         anchors.horizontalCenter: bookmarkCheckBox.horizontalCenter
180         anchors.top: bookmarkCheckBox.bottom
181         anchors.topMargin: 3
182         onChanged: rectangle1.dictionariesCheckBoxChanged(selected);
183         onFocusChanged: if(focus) focusIndex=3;
184     }
185
186     Button {
187         id: saveButton
188         width: 66
189         height:26
190         anchors.bottom: parent.bottom
191         anchors.bottomMargin: 5
192         anchors.right: parent.right
193         anchors.rightMargin: 5
194         textInButton: qsTr("Save")
195         onClicked: rectangle1.saveButtonClicked();
196         onFocusChanged: if(focus) focusIndex=4;
197     }
198 }