b2e75dbe55974317b78f7692d44446f1b6b551df
[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         //console.log( "debug" + (newPlugin ? textPath.paintedHeight+55 : textInfo.paintedHeight+55));
54     }
55
56     SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
57     color : myPalette.window;
58
59     Text {
60         id: textInfo
61         text: "Tekst: "
62         height: paintedHeight+5;
63         anchors.right: parent.right
64         anchors.left: parent.left
65         anchors.top: parent.top
66         wrapMode: Text.Wrap;
67         transformOrigin: Item.Left
68         font.pixelSize: 12
69     }
70
71     Text {
72         id: textPath
73         text: qsTr("Dictionary file: not selected")
74         height: paintedHeight+5;
75         anchors.top: parent.top
76         anchors.right: browseButton.left
77         anchors.left: parent.left
78         wrapMode: Text.Wrap;
79         transformOrigin: Item.Left
80         font.pixelSize: 12
81         opacity: 0
82     }
83
84     Button {
85         id: browseButton
86         width: 80;
87         height: 25;
88         textInButton: qsTr("Browse");
89         anchors.top: parent.top
90         anchors.topMargin: 10
91         anchors.right: parent.right
92         opacity: 0
93         onClicked: rectangle1.browseButtonClicked();
94     }
95
96     Button {
97         id: saveButton
98         height: 30
99         anchors.bottom: parent.bottom
100         textInButton: qsTr("Save")
101         anchors.right: parent.right
102         anchors.left: parent.left
103         onClicked: rectangle1.saveButtonClicked();
104     }
105
106     states: [
107         State {
108             name: "new"
109             when: newPlugin==true
110             PropertyChanges { target: textInfo; opacity: 0}
111             PropertyChanges { target: textPath; opacity: 1}
112             PropertyChanges { target: browseButton; opacity: 1 }
113         }
114     ]
115 }