add focus in xdxf and stardict dialogs
[mdictionary] / src / mdictionary / qml / GoogleDialog.qml
index 8235499..331bd73 100644 (file)
@@ -1,6 +1,13 @@
 import Qt 4.7
 
 Rectangle{
+    id:rectangle1
+    height: infoLabel.height + fromLabel.height + toLabel.height + saveButton.height + 50
+    width: 200
+    color : myPalette.window;
+    focus: true;
+    property int focusIndex:-1;
+
     property bool newPlugin:false;
 
     function setInfo(string){
@@ -24,18 +31,57 @@ Rectangle{
         newPlugin=bool;
     }
 
-    signal saveButtonClicked(string langFrom, string langTo);
-
-    height: infoLabel.height + fromLabel.height + toLabel.height + saveButton.height + 50
-    width: 200
+    function setFocus(){
+        if(focusIndex==0){
+            console.log("01");
+        }
+        if(focusIndex==1){
+            console.log("02");
+        }
+        if(focusIndex==2){
+            revertButton.focus = true
+            if(!revertButton.enabled)
+                focusIndex++;
+        }
+        if(focusIndex==3){
+            saveButton.focus = true
+            if(!saveButton.enabled)
+                focusIndex++;
+        }
+        if(focusIndex>3){
+            focusIndex=-1;
+            focus=true;
+        }
+    }
 
-    id:rectangle1
+    Keys.onTabPressed: {
+        console.log("tab");
+        focusIndex++;
+        setFocus();
+    }
 
+    Keys.onPressed: {
+        console.log("taaaa");
+    }
 
+    signal saveButtonClicked(string langFrom, string langTo);
 
-    SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
-    color : myPalette.window;
+    SystemPalette {
+        id: myPalette;
+        colorGroup:SystemPalette.Active
+    }
 
+    Item {
+        id: comboField
+        anchors.bottomMargin: 6
+        anchors.rightMargin: 0
+        anchors.left: fromLabel.right
+        anchors.right: revertButton.left
+        anchors.bottom: saveButton.top
+        anchors.top: parent.top
+        anchors.leftMargin: 2
+        z:2;
+    }
 
     Text {
         id: infoLabel
@@ -46,9 +92,9 @@ Rectangle{
         wrapMode: Text.Wrap;
         transformOrigin: Item.Left
         font.pixelSize: 12
-        z: 15
     }
 
+
     Text {
         id: fromLabel
         text: qsTr("From: ")
@@ -63,6 +109,7 @@ Rectangle{
     Text {
         id: toLabel
         text: qsTr("To: ")
+        anchors.topMargin: 3
         height: paintedHeight+5;
         anchors.top: fromLabel.bottom
         anchors.left: parent.left
@@ -74,67 +121,58 @@ Rectangle{
     ComboBox{
         id: comboFrom
         model: comboBoxModel
-        anchors.left: parent.left
-        anchors.leftMargin: {
-            if (fromLabel.width < 30 && toLabel.width < 30){
-                return 30
-            }
-            else if (fromLabel.width > toLabel.width){
-                return fromLabel.width + 10
-            }
-            else {
-                return toLabel.width + 10
-            }
-        }
-
-        anchors.top: infoLabel.bottom
         anchors.right: revertButton.left
-        anchors.rightMargin: 10
+        anchors.rightMargin: 5
+        anchors.left: fromLabel.right
+        anchors.leftMargin: 10
+        anchors.verticalCenter: fromLabel.verticalCenter
+
+        parentField: comboField
         expanded: false
         basicHeight: fromLabel.height
-        expandedHeight: parent.height - comboFrom.x - saveButton.height -20
+        onExpandedChanged: {
+            if(expanded==true)
+                z=2;
+            else
+                z=0;
+        }
     }
 
     ComboBox{
         id: comboTo
         model:  comboBoxModel
-        anchors.left: parent.left
-        anchors.leftMargin: {
-            if (fromLabel.width < 30 && toLabel.width < 30){
-                return 30
-            }
-            else if (fromLabel.width > toLabel.width){
-                return fromLabel.width + 10
-            }
-            else {
-                return toLabel.width + 10
-            }
-        }
-
         anchors.right: revertButton.left
-        anchors.rightMargin: 10
-        anchors.top: comboFrom.bottom
+        anchors.rightMargin: 5
+        anchors.left: fromLabel.right
+        anchors.leftMargin: 10
+        anchors.verticalCenter: toLabel.verticalCenter
+
+        parentField: comboField;
         expanded: false
         basicHeight: fromLabel.height
-        expandedHeight: parent.height - comboTo.x - saveButton.height - 20 - fromLabel.height
+
+        onExpandedChanged: {
+            if(expanded==true)
+                z=2;
+            else
+                z=0;
+        }
     }
 
     IconButton{
         id: revertButton
         width: height
         height: fromLabel.height
-        anchors.top: fromLabel.top
-        anchors.topMargin: fromLabel.height /2
+        anchors.top: fromLabel.bottom
+        anchors.topMargin: -8
         anchors.right: parent.right
-//        pathToIcon: //gimp again, ech
-        pathToIcon: "qrc:/button/up_enable.png"; //temp
+        pathToIcon: "qrc:/button/revert.png"
         onClicked: { rectangle1.revertLang() }
     }
 
     Button {
         id: saveButton
         height: 30
-        z: 1
         anchors.bottom: parent.bottom
         anchors.right: parent.right
         anchors.left: parent.left
@@ -143,6 +181,18 @@ Rectangle{
         }
     }
 
+    MouseArea {
+        id: mouse_area1
+        anchors.fill: parent
+        z:-1
+        onClicked: {
+            comboTo.expanded=false;
+            comboFrom.expanded=false;
+        }
+    }
+
+
+
     states: [
         State {
             name: "new"