Source init for master branch.
[lichviet] / qml / DatePicker / component / Button.qml
diff --git a/qml/DatePicker/component/Button.qml b/qml/DatePicker/component/Button.qml
new file mode 100644 (file)
index 0000000..eb58bbb
--- /dev/null
@@ -0,0 +1,94 @@
+import QtQuick 1.0\r
+\r
+Item {\r
+    id: container\r
+\r
+    property string buttonName: "NOT SET"\r
+    property string target: "NOT SET"\r
+    property string text: "NOT SET"\r
+\r
+    property string fontName: "Helvetica"\r
+    property int fontSize: 14\r
+    property color fontColor: "black"\r
+\r
+    property bool active: false\r
+\r
+    property string bgImage: theme_manager.theme.datepicker.button\r
+    property string bgImagePressed: theme_manager.theme.datepicker.button_pressed\r
+    property string bgImageActive: theme_manager.theme.datepicker.button_active\r
+\r
+    // These Component properties can be used to modify the Button's LaF\r
+    // from the calling component. They have to define a BorderImage component.\r
+    property Component bg: defaultBackground\r
+    property Component bgPressed: defaultPressedBackground\r
+    property Component bgActive: defaultActiveBackground\r
+\r
+    signal clicked(string target, string button)\r
+\r
+    width: 140\r
+    height: 60\r
+    opacity: enabled ? 1.0 : 0.5    \r
+\r
+    Loader {\r
+        id: background\r
+        sourceComponent: container.bg\r
+        anchors.fill: parent\r
+    }\r
+\r
+    Component {\r
+        id: defaultBackground\r
+        BorderImage {\r
+            border { top: 8; bottom: 8; left: 8; right: 8 }\r
+            source: bgImage\r
+        }\r
+    }\r
+    Component {\r
+        id: defaultPressedBackground\r
+        BorderImage {\r
+            border { top: 8; bottom: 8; left: 8; right: 8 }\r
+            source: bgImagePressed\r
+        }\r
+    }\r
+\r
+    Component {\r
+        id: defaultActiveBackground\r
+        BorderImage {\r
+            border { top: 8; bottom: 8; left: 8; right: 8 }\r
+            source: bgImageActive\r
+        }\r
+    }\r
+\r
+    Text {\r
+        id: buttonLabel\r
+        text: parent.text\r
+        wrapMode: Text.WordWrap\r
+\r
+        anchors {\r
+            horizontalCenter: parent.horizontalCenter\r
+            verticalCenter: parent.verticalCenter\r
+        }\r
+        font {\r
+            family: container.fontName\r
+            pointSize: container.fontSize\r
+        }\r
+        color: container.fontColor\r
+    }\r
+\r
+    MouseArea {\r
+        id: mouseArea\r
+        anchors.fill: parent\r
+\r
+    }\r
+\r
+    states: [\r
+        State {\r
+            name: 'pressed'; when: mouseArea.pressed\r
+            PropertyChanges { target: background; sourceComponent: container.bgPressed }\r
+        },\r
+        State {\r
+            name: 'active'; when: container.active\r
+            PropertyChanges { target: background; sourceComponent: container.defaultActiveBackground; }\r
+        }\r
+    ]\r
+\r
+}\r