1 /*******************************************************************************
3 This file is part of mDictionary.
5 mDictionary is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 mDictionary is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
18 Copyright 2010 Comarch S.A.
20 *******************************************************************************/
22 author: Marcin Kaźmierczak <marcin.kazmierczak@comarch.pl>
28 SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
30 function setEnableRemove(Boolean) { removeButton.enabled = Boolean }
31 function setEnableSettings(Boolean) { settingsButton.enabled = Boolean }
32 function changeDictionaryState(nr, state) {
33 dictList.currentIndex = nr
34 dictModel.setModelProperty(dictList.currentIndex, state, "isSelected")
35 rectangle1.setEnableRemove(true)
36 rectangle1.setEnableSettings(true)
43 signal addButtonClicked;
44 signal removeButtonClicked;
45 signal settingsButtonClicked;
46 signal saveButtonClicked;
47 signal itemActivated(int nr);
55 width: rectangle1.width
56 // height: rectangle1.height
57 anchors.top: parent.top
58 anchors.bottom: buttonsBox.top
59 anchors.bottomMargin: buttonsBox.height + buttonsBox.anchors.topMargin
60 highlightResizeSpeed: 1000
63 if ((currentIndex < 0 || currentIndex >= count) && (event.key == Qt.Key_Up || event.key == Qt.Key_Down)){
67 if ((event.key == Qt.Key_Return || event.key == Qt.Key_Enter) && currentIndex >= 0){
68 itemActivated(currentIndex)
70 if ((event.key == Qt.Key_Delete) && currentIndex >= 0){
73 if (event.key == Qt.Key_S && event.modifiers == Qt.ControlModifier){
76 if (event.key == Qt.Key_T && event.modifiers == Qt.ControlModifier){
79 if ((event.key == Qt.Key_Space) && currentIndex >= 0){
80 dictModel.setModelProperty(dictList.currentIndex, "isSelected")
84 onCurrentIndexChanged: {
85 dictModel.itemSelected(dictList.currentIndex)
91 width: rectangle1.width
93 if (nameText.height + 4 > logo.height)
94 return nameText.height + 4;
101 dictList.currentIndex = number
102 rectangle1.setEnableRemove(true)
103 rectangle1.setEnableSettings(true)
106 rectangle1.itemActivated(dictList.currentIndex)
113 width: nameText.height
115 onChanged: rectangle1.changeDictionaryState(number, selected)
123 var aspectRatio = sourceSize.height / sourceSize.width
124 return logo.width * aspectRatio
126 anchors.leftMargin: 5
127 anchors.verticalCenter: parent.verticalCenter
128 width: nameText.height + 4
134 anchors.leftMargin: 5
135 anchors.verticalCenter: parent.verticalCenter
149 anchors.bottom: parent.bottom
150 anchors.top: dictList.bottom
155 width: (parent.width - 4) / 4
156 height: buttonsBox.height
157 anchors.left: buttonsBox.left
158 anchors.leftMargin: 4
159 anchors.verticalCenter: parent.verticalCenter
160 textInButton: qsTr("Add")
161 onClicked: addButtonClicked();
166 width: (parent.width - 4) / 4
167 height: buttonsBox.height
168 anchors.left: addButton.right
169 anchors.leftMargin: 4
170 anchors.verticalCenter: parent.verticalCenter
171 textInButton: qsTr("Remove")
173 onClicked: removeButtonClicked();
178 width: (parent.width - 4) / 4
179 height: buttonsBox.height
180 anchors.left: removeButton.right
181 anchors.leftMargin: 4
182 anchors.verticalCenter: parent.verticalCenter
183 textInButton: qsTr("Settings")
185 onClicked: settingsButtonClicked();
190 width: (parent.width - 4) / 4
191 height: buttonsBox.height
192 anchors.left: settingsButton.right
193 anchors.leftMargin: 4
194 anchors.right: buttonsBox.right
195 anchors.rightMargin: 4
196 anchors.verticalCenter: parent.verticalCenter
197 textInButton: qsTr("Save")
198 onClicked: saveButtonClicked()