Merge branch 'qml'
[mdictionary] / src / mdictionary / qml / ComboBox.qml
index b863e3c..5ceb5b5 100644 (file)
@@ -12,7 +12,9 @@ Rectangle {
     property int expandedHeight
     property int basicHeight
     property string startValue
-    height: basicHeight
+    height: 20
+
+    property variant parentField : rectangle1
 
     function show(Boolean){
         expanded = Boolean
@@ -25,6 +27,19 @@ Rectangle {
 
     signal valueSelected(string selected);
 
+   /* Keys.onPressed: {
+        console.log("tu ----");
+        if (event.key == Qt.Key_Escape)
+            rectangle1.expanded=false;
+        else if (event.key == Qt.Key_Space)
+            rectangle1.expanded=true;
+        else if (event.key == Qt.Key_Return){
+            rectangle1.expanded=false;
+            console.log("tu enter "+list1.content);
+        }
+    }
+    */
+
     Text {
         id: text1
         width: rectangle1.width-15
@@ -33,6 +48,7 @@ Rectangle {
         anchors.centerIn: parent
         font.pixelSize: rectangle1.height * .5;
         onTextChanged: { rectangle1.valueSelected(text) }
+        z: expanded?0:1;
     }
 
     Rectangle {
@@ -77,9 +93,7 @@ Rectangle {
 
     ElementsListView{
         id: list1
-        width: parent.width
         visible: false
-        z: 0
         property string selected: rectangle1.startValue
 
         function selectedValue(nr, value) {
@@ -88,10 +102,13 @@ Rectangle {
             rectangle1.show(false)
         }
 
-        anchors.left: parent.left
-        anchors.verticalCenter: parent.verticalCenter
-        highlightResizeSpeed: 1000
+        anchors.rightMargin: 5
+        anchors.leftMargin: 5
+        anchors.bottomMargin: 10
+        anchors.topMargin: 10
+        anchors.fill: parent
 
+        highlightResizeSpeed: 1000
         delegate: Component{
             id: list1Delegate
             Item {
@@ -118,6 +135,7 @@ Rectangle {
                         id: contentText
                         anchors.verticalCenter: parent.verticalCenter
                         anchors.leftMargin: 5
+                        elide: Text.ElideRight;
                         text: content
                     }
                 }
@@ -142,10 +160,11 @@ Rectangle {
             when: (rectangle1.expanded == true && rectangle1.disabled == false)
             PropertyChanges { target: list1; z: 10; visible: true }
             PropertyChanges { target: text1; z: 10; visible: false }
-            PropertyChanges { target: rectangle1; border.width: 0}
+            PropertyChanges { target: rectangle1; border.width: 1}
             PropertyChanges { target: rectangle1; height: rectangle1.expandedHeight}
             PropertyChanges { target: imageDown; height: 0.5 * rectangle1.basicHeight}
             PropertyChanges { target: shadeDisable; visible: false; z: -1}
+            PropertyChanges { target: rectangle1; anchors.fill: parentField}
         },
         State {
             name: "disabled";