b1efd50a68f7e6082e01e6e800d1c4db9b9989cf
[mdictionary] / src / mdictionary / qml / StarDictDialog.qml
1 import Qt 4.7
2
3 Rectangle{
4     id:rectangle1
5     width: 220
6     height: newPlugin ? textPath.height+50 : textInfo.height+50
7     focus: true;
8
9     property int focusIndex:-1;
10     property bool newPlugin:false;
11
12     function setInfo(string){
13         textInfo.text = string;
14     }
15     function setPath(string){
16         textPath.text = string;
17     }
18     function setButtonText(string){
19         saveButton.textInButton=string;
20     }
21     function setNew(bool){
22         newPlugin=bool;
23     }
24
25     function setFocus(){
26         if(focusIndex==0){
27             browseButton.focus=true;
28             if(!browseButton.opacity)
29                 focusIndex++;
30         }
31         if(focusIndex==1){
32             saveButton.focus = true
33             if(!saveButton.enabled)
34                 focusIndex++;
35         }
36         if(focusIndex>1){
37             focusIndex=-1;
38             focus=true;
39         }
40     }
41
42     signal saveButtonClicked();
43     signal browseButtonClicked();
44     signal heightChange(int intiger);
45
46     Keys.onTabPressed: {
47         focusIndex++;
48         setFocus();
49     }
50
51     onHeightChanged:{
52         heightChange((newPlugin ? textPath.height+50 : textInfo.height+50));
53     }
54
55     SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
56     color : myPalette.window;
57
58     Text {
59         id: textInfo
60         text: "Tekst: "
61         height: paintedHeight+5;
62         anchors.right: parent.right
63         anchors.left: parent.left
64         anchors.top: parent.top
65         wrapMode: Text.Wrap;
66         transformOrigin: Item.Left
67         font.pixelSize: 12
68     }
69
70     Text {
71         id: textPath
72         text: qsTr("Dictionary file: not selected")
73         height: paintedHeight+5;
74         anchors.top: parent.top
75         anchors.right: browseButton.left
76         anchors.left: parent.left
77         wrapMode: Text.Wrap;
78         transformOrigin: Item.Left
79         font.pixelSize: 12
80         opacity: 0
81     }
82
83     Button {
84         id: browseButton
85         width: 80;
86         height: 25;
87         textInButton: qsTr("Browse");
88         anchors.top: parent.top
89         anchors.topMargin: 10
90         anchors.right: parent.right
91         opacity: 0
92         onClicked: rectangle1.browseButtonClicked();
93     }
94
95     Button {
96         id: saveButton
97         height: 30
98         anchors.bottom: parent.bottom
99         textInButton: qsTr("Save")
100         anchors.right: parent.right
101         anchors.left: parent.left
102         onClicked: rectangle1.saveButtonClicked();
103     }
104
105     states: [
106         State {
107             name: "new"
108             when: newPlugin==true
109             PropertyChanges { target: textInfo; opacity: 0}
110             PropertyChanges { target: textPath; opacity: 1}
111             PropertyChanges { target: browseButton; opacity: 1 }
112         }
113     ]
114 }