Button: added disabled state
authorSami Rämö <sami.ramo@ixonos.com>
Thu, 25 Nov 2010 08:08:47 +0000 (10:08 +0200)
committerSami Rämö <sami.ramo@ixonos.com>
Thu, 25 Nov 2010 08:08:47 +0000 (10:08 +0200)
src/engine/engine.cpp
src/qmlui/Button.qml

index fba7466..acdfe19 100644 (file)
@@ -56,6 +56,7 @@
 #include "updatelocation.h"
 #include "routing/searchhistorymodel.h"
 #include "routing/searchresultsmodel.h"
+#include "QGraphicsColorizeEffect"
 
 #ifdef Q_WS_MAEMO_5
 #include <QX11Info>
@@ -224,6 +225,7 @@ SituareEngine::SituareEngine()
 
 #ifdef QML_UI
     qmlRegisterType<GeoMap>("MapPlugin", 1, 0, "GeoMap");
+    qmlRegisterType<QGraphicsColorizeEffect>("ColorizeEffect", 1, 0, "Colorize");
 
     Q_D(SituareEngine);
 
index 4b4c40d..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,6 +35,7 @@ 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 {
@@ -57,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
+            }
         }
     ]
 }