add focus in xdxf and stardict dialogs
[mdictionary] / src / mdictionary / qml / XdxfDialog.qml
index 1b2a960..7fb2c78 100644 (file)
@@ -6,9 +6,11 @@ Rectangle{
     height: textPlugin.height + textFrom.height + textTo.height + textDescription.height + textInfo.height +90
 
     property bool newPlugin:false;
+    property int focusIndex:-1;
 
     SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
     color : myPalette.window;
+    focus: true;
 
     function setPlugin(string){
         textPlugin.text = qsTr("Plugin") + ": " + string;
@@ -41,6 +43,43 @@ Rectangle{
         textPath.text=string;
     }
 
+    function setFocus(){
+        if(focusIndex==0){
+            browseButton.focus= true;
+            if(!browseButton.opacity)
+                focusIndex++;
+        }
+        if(focusIndex==1){
+            downloadButton.focus=true;
+            if(!downloadButton.opacity)
+                focusIndex++;
+        }
+        if(focusIndex==2){
+            optimalizeCheckbox.focus = true
+            if(!optimalizeCheckbox.enabled)
+                focusIndex++;
+        }
+        if(focusIndex==3){
+            stripCheckbox.focus = true
+            if(!stripCheckbox.enabled)
+                focusIndex++;
+        }
+        if(focusIndex==4){
+            saveButton.focus = true
+            if(!saveButton.enabled)
+                focusIndex++;
+        }
+        if(focusIndex>4){
+            focusIndex=-1;
+            focus=true;
+        }
+    }
+
+    Keys.onTabPressed: {
+        focusIndex++;
+        setFocus();
+    }
+
     signal saveButtonClicked();
     signal downloadButtonClicked();
     signal browseButtonClicked();
@@ -126,6 +165,7 @@ Rectangle{
         anchors.left: parent.left
         anchors.leftMargin: 5
         onChanged: rectangle1.optimalizeCheckboxChanged(selected);
+        onFocusChanged: if(focus) focusIndex=2;
     }
 
     Checkbox {
@@ -136,6 +176,7 @@ Rectangle{
         anchors.bottomMargin: 15
         anchors.horizontalCenter: optimalizeCheckbox.horizontalCenter
         onChanged: rectangle1.stripCheckboxChanged(selected);
+        onFocusChanged: if(focus) focusIndex=3;
     }
 
     Text {