Button: added disabled state
[situare] / src / qmlui / Button.qml
index 16fbe55..4489c58 100644 (file)
@@ -1,9 +1,11 @@
 import Qt 4.7
+import ColorizeEffect 1.0
 
 Rectangle {
     id: background
     property alias image: image.source
     property alias text: text.text
+    property bool enabled: true
     property int margins: 5
 
     signal buttonClicked()
@@ -33,12 +35,12 @@ Rectangle {
             anchors { left: contents.left; leftMargin: 1; verticalCenter: contents.verticalCenter; verticalCenterOffset: 1}
             width: sourceSize.width
             height: sourceSize.height
+            effect: Colorize { id: imageColorize; color: "black"; strength: 0 }
         }
 
         Text {
             id: text
             color: "#aaaaaa"
-            font.pixelSize: 18
             smooth: true
             height: paintedHeight
             width: paintedWidth
@@ -58,6 +60,26 @@ Rectangle {
                 target: background
                 color: palette.highlight
             }
+        },
+        State {
+            name: "disabled"
+            when: !enabled
+            PropertyChanges {
+                target: background
+                border.color: Qt.darker("#aaaaaa", 1.5)
+            }
+            PropertyChanges {
+                target: text
+                color: Qt.darker("#aaaaaa")
+            }
+            PropertyChanges {
+                target: imageColorize
+                strength: 1
+            }
+            PropertyChanges {
+                target: mouseArea
+                enabled: false
+            }
         }
     ]
 }