add focus in xdxf and stardict dialogs
authorjakub <jakub.jaszczynski@comarch.com>
Tue, 1 Mar 2011 09:45:27 +0000 (10:45 +0100)
committerjakub <jakub.jaszczynski@comarch.com>
Tue, 1 Mar 2011 09:45:27 +0000 (10:45 +0100)
src/mdictionary/gui/SearchBarWidget.cpp
src/mdictionary/qml/GoogleDialog.qml
src/mdictionary/qml/SearchBarWidget.qml
src/mdictionary/qml/StarDictDialog.qml
src/mdictionary/qml/XdxfDialog.qml

index 7e9e16d..1ac6a51 100644 (file)
@@ -263,9 +263,10 @@ QIcon SearchBarWidget::generateIcon(QIcon original, qreal rotation) {
 
 void SearchBarWidget::setFocus() {
 #ifndef Q_WS_MAEMO_5
-        view->setFocus();
+    view->setFocus();
+    emit focusOff();
 #else
-        searchWordLineEdit->setFocus();
+    searchWordLineEdit->setFocus();
 #endif
 }
 
index d27cec6..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,13 +31,40 @@ Rectangle{
         newPlugin=bool;
     }
 
-    signal saveButtonClicked(string langFrom, string langTo);
+    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;
+        }
+    }
 
+    Keys.onTabPressed: {
+        console.log("tab");
+        focusIndex++;
+        setFocus();
+    }
 
-    id:rectangle1
-    height: infoLabel.height + fromLabel.height + toLabel.height + saveButton.height + 50
-    width: 200
-    color : myPalette.window;
+    Keys.onPressed: {
+        console.log("taaaa");
+    }
+
+    signal saveButtonClicked(string langFrom, string langTo);
 
     SystemPalette {
         id: myPalette;
@@ -173,163 +207,3 @@ Rectangle{
     ]
 }
 
-
-/*
-Rectangle{
-    property bool newPlugin:false;
-
-    function setInfo(string){
-        infoLabel.text = string;
-    }
-    function setStartValues(startFrom, startTo, startFromIndex, startToIndex){
-        comboFrom.setStartValue(startFrom, startFromIndex)
-        comboTo.setStartValue(startTo, startToIndex)
-    }
-    function revertLang(){
-        var tmpidx = comboFrom.index
-        comboFrom.index = comboTo.index
-        comboTo.index = tmpidx
-
-        var tmpval = comboFrom.value
-        comboFrom.value = comboTo.value
-        comboTo.value = tmpval
-    }
-
-    function setNew(bool){
-        newPlugin=bool;
-    }
-
-    signal saveButtonClicked(string langFrom, string langTo);
-
-
-    id:rectangle1
-    height: infoLabel.height + fromLabel.height + toLabel.height + saveButton.height + 50
-    width: 200
-
-    SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
-    color : myPalette.window;
-
-
-    Text {
-        id: infoLabel
-        height: paintedHeight+5;
-        anchors.right: parent.right
-        anchors.left: parent.left
-        anchors.top: parent.top
-        wrapMode: Text.Wrap;
-        transformOrigin: Item.Left
-        font.pixelSize: 12
-        z: 15
-    }
-
-    Text {
-        id: fromLabel
-        text: qsTr("From: ")
-        height: paintedHeight+5;
-        anchors.top: infoLabel.bottom
-        anchors.left: parent.left
-        wrapMode: Text.Wrap;
-        transformOrigin: Item.Left
-        font.pixelSize: 12
-    }
-
-    Text {
-        id: toLabel
-        text: qsTr("To: ")
-        height: paintedHeight+5;
-        anchors.top: fromLabel.bottom
-        anchors.left: parent.left
-        wrapMode: Text.Wrap;
-        transformOrigin: Item.Left
-        font.pixelSize: 12
-    }
-
-    ComboBox{
-        //parentField: rectangle1
-
-        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
-        expanded: false
-        basicHeight: fromLabel.height
-        expandedHeight: parent.height - comboFrom.x - saveButton.height -20
-    }
-
-    ComboBox{
-        //parentField: rectangle1;
-        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
-        expanded: false
-        basicHeight: fromLabel.height
-        expandedHeight: parent.height - comboTo.x - saveButton.height - 20 - fromLabel.height
-    }
-
-    IconButton{
-        id: revertButton
-        width: height
-        height: fromLabel.height
-        anchors.top: fromLabel.top
-        anchors.topMargin: fromLabel.height /2
-        anchors.right: parent.right
-        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
-        onClicked: {
-            rectangle1.saveButtonClicked(comboFrom.value, comboTo.value);
-        }
-    }
-
-    states: [
-        State {
-            name: "new"
-            when: newPlugin==true
-            PropertyChanges { target: saveButton; textInButton: qsTr("Add") }
-        },
-        State {
-            name: "edit"
-            when: newPlugin==false
-            PropertyChanges { target: saveButton; textInButton: qsTr("Save settings") }
-        }
-    ]
-}
-*/
-
index 6590e45..40d33e6 100644 (file)
@@ -20,6 +20,7 @@ Rectangle {
     function setCompleterText(string) { inputSearchText.setCompleter(string) }
 
     function setFocus(){
+        console.log("setFocus");
         if(focusIndex==0){
             inputSearchText.setFocus();
             if(!inputSearchText.enabled)
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;
 
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 {