qml ComboBox component and GoogleDialog complete
[mdictionary] / src / mdictionary / qml / GoogleDialog.qml
diff --git a/src/mdictionary/qml/GoogleDialog.qml b/src/mdictionary/qml/GoogleDialog.qml
new file mode 100644 (file)
index 0000000..8235499
--- /dev/null
@@ -0,0 +1,159 @@
+import Qt 4.7
+
+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);
+
+    height: infoLabel.height + fromLabel.height + toLabel.height + saveButton.height + 50
+    width: 200
+
+    id:rectangle1
+
+
+
+    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{
+        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{
+        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: //gimp again, ech
+        pathToIcon: "qrc:/button/up_enable.png"; //temp
+        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") }
+        }
+    ]
+}
+