bi change + completer in line edit
[mdictionary] / src / mdictionary / qml / Button.qml
index d10edc6..dd94a40 100644 (file)
@@ -3,10 +3,17 @@ import Qt 4.7
 BorderImage {
     id: button
     property alias textInButton: buttonText.text
-    signal clicked
-    opacity: 1
+    property bool checkable: false
+    property bool checked: false
+
+    height: 20;
+    width: 60;
+
+    signal clicked;
+    signal changeCheck;
 
     function setText(string) { textInButton = qsTr(string); }
+    function press() { mouseArea.pressed }
     border { left: 10; top: 10; right: 10; bottom: 10 }
 
     MouseArea {
@@ -16,20 +23,27 @@ BorderImage {
         height: parent.height;
         onClicked: {
             button.clicked();
+            if(checkable){
+                button.checked=!button.checked;
+                button.changeCheck();
+            }
         }
     }
 
     Text {
         z:1
         id: buttonText
+        width: parent.width;
         anchors.centerIn: parent;
+        horizontalAlignment: Text.AlignHCenter
         font.pixelSize: parent.height * .5
+        elide: Text.ElideRight;
         style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true
     }
 
     Image {
         id: image1
-        width: (35*parent.height)/107 +1
+        width:  (image1.sourceSize.width*parent.height)/image1.sourceSize.height +1 //(35*parent.height)/107 +1
         height: parent.height
         anchors.left: parent.left
         source: "qrc:/button/buttonLeft.png"
@@ -52,7 +66,7 @@ BorderImage {
     Image {
         id: image2
         smooth: true
-        width: (35*parent.height)/107 +1
+        width: (image1.sourceSize.width*parent.height)/image1.sourceSize.height +1//(35*parent.height)/107 +1
         height: parent.height
         anchors.right: parent.right
         source: "qrc:/button/buttonR.png"
@@ -62,7 +76,7 @@ BorderImage {
     states: [
         State {
             name: "pressed";
-            when: (mouseArea.pressed == true && button.enabled == true);
+            when: ((button.enabled) && (mouseArea.pressed || (button.checkable && button.checked) ) )
 
             PropertyChanges { target: image1; source: "qrc:/button/buttonLeftPushed.png" }
             PropertyChanges { target: image3; source: "qrc:/button/buttonCenterPushed.png" }