add focus in xdxf and stardict dialogs
[mdictionary] / src / mdictionary / qml / StarDictDialog.qml
index b283f61..b2e75db 100644 (file)
@@ -1,6 +1,12 @@
 import Qt 4.7
 
 Rectangle{
+    id:rectangle1
+    width: 220
+    height: newPlugin ? textPath.height+50 : textInfo.height+50
+    focus: true;
+
+    property int focusIndex:-1;
     property bool newPlugin:false;
 
     function setInfo(string){
@@ -16,21 +22,37 @@ Rectangle{
         newPlugin=bool;
     }
 
+    function setFocus(){
+        if(focusIndex==0){
+            browseButton.focus=true;
+            if(!browseButton.opacity)
+                focusIndex++;
+        }
+        if(focusIndex==1){
+            saveButton.focus = true
+            if(!saveButton.enabled)
+                focusIndex++;
+        }
+        if(focusIndex>1){
+            focusIndex=-1;
+            focus=true;
+        }
+    }
+
     signal saveButtonClicked();
     signal browseButtonClicked();
     signal heightChange(int intiger);
 
-    id:rectangle1
-    width: 220
-    height: newPlugin ? textPath.height+50 : textInfo.height+50
+    Keys.onTabPressed: {
+        focusIndex++;
+        setFocus();
+    }
 
     onHeightChanged:{
         heightChange((newPlugin ? textPath.height+50 : textInfo.height+50));
         //console.log( "debug" + (newPlugin ? textPath.paintedHeight+55 : textInfo.paintedHeight+55));
     }
 
-
-
     SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
     color : myPalette.window;