Tizen: Added style for RadioButton. Examples adapted.
authorTomasz Olszak <olszak.tomasz@gmail.com>
Mon, 2 Dec 2013 23:02:17 +0000 (00:02 +0100)
committerTomasz Olszak <olszak.tomasz@gmail.com>
Mon, 2 Dec 2013 23:34:51 +0000 (00:34 +0100)
Change-Id: I89ef57cbd5a71e053707cd7804e1b355c4755a19
Reviewed-by: Jarosław Staniek <staniek@kde.org>
examples/touch/content/ConfigurationPage.qml
src/styles/DefaultSettings.js
src/styles/RadioButtonStyle.qml [new file with mode: 0644]
src/styles/SwitchStyle.qml
src/styles/qmldir
src/styles/styles.pro

index 8e94e05..200c7dc 100644 (file)
@@ -138,19 +138,24 @@ Item {
                 checkBoxWhite.checked = TizenControls.currentTheme === "white"
                 checkBoxBlack.checked = TizenControls.currentTheme === "black"
             }
-            CheckBox {
+            ExclusiveGroup {
+                id: exclGroup
+            }
+            RadioButton {
                 id: checkBoxWhite
+                exclusiveGroup: exclGroup
                 Layout.fillWidth: true
                 Layout.fillHeight: true
                 text: "White"
-                onClicked: TizenControls.changeTheme("white")
+                onCheckedChanged: if (checked) TizenControls.changeTheme("white")
             }
-            CheckBox {
+            RadioButton {
                 id: checkBoxBlack
                 Layout.fillWidth: true
+                exclusiveGroup: exclGroup
                 Layout.fillHeight: true
                 text: "Black"
-                onClicked: TizenControls.changeTheme("black")
+                onCheckedChanged: if (checked) TizenControls.changeTheme("black")
             }
         }
     }
index 9b82e9b..dd94f22 100644 (file)
@@ -275,6 +275,25 @@ function createCheckBox(th) {
         },
         onOff: {
             source: {
+                normal: images.img_00_button_radio_bg,
+                disabled: images.img_00_button_radio_dim_bg,
+                pressed: images.img_00_button_radio_press_bg,
+                highlighted: images.img_00_button_radio_focus,
+                selected: images.img_00_button_radio_bg
+            },
+            indicator: {
+                source: {
+                    normal: images.img_00_button_radio_activated,
+                    disabled: images.img_00_button_radio_activated_dim,
+                    pressed: images.img_00_button_radio_activated_press,
+                    highlighted: images.img_00_button_radio_activated,
+                    selected: images.img_00_button_radio_activated
+                }
+            }
+        },
+
+        onOffSliding: {
+            source: {
                 normal: images.img_00_button_on_off_bg,
                 disabled: images.img_00_button_on_off_bg_dim,
                 pressed: images.img_00_button_on_off_bg,
diff --git a/src/styles/RadioButtonStyle.qml b/src/styles/RadioButtonStyle.qml
new file mode 100644 (file)
index 0000000..42e7bcf
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2013 Tomasz Olszak <olszak.tomasz@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+import QtQuick 2.2
+import QtQuick.Controls.Styles 1.1
+import QtQuick.Controls.Styles.Tizen 1.0
+import "private"
+
+RadioButtonStyle {
+    label: Text {
+        text: control.text
+        font.pointSize: TizenConfig.checkBox.font.pixelSize
+        color:if (control.enabled) {
+                  if (control.pressed) {
+                      TizenConfig.checkBox.text.color.pressed
+                  } else {
+                      TizenConfig.checkBox.text.color.normal
+                  }
+              } else {
+                  TizenConfig.checkBox.text.color.disabled
+              }
+        verticalAlignment: Text.AlignVCenter
+    }
+
+    indicator: Image {
+        source: control.enabled ? (control.pressed? TizenConfig.checkBox.onOff.source.pressed: TizenConfig.checkBox.onOff.source.normal):TizenConfig.checkBox.onOff.source.disabled
+        Image {
+            visible: control.checked
+            source: control.enabled ? (control.pressed || !control.checked ? TizenConfig.checkBox.onOff.indicator.source.pressed: TizenConfig.checkBox.onOff.indicator.source.normal):TizenConfig.checkBox.onOff.indicator.source.disabled
+        }
+    }
+
+    background: PrivatePanel {
+        id:panel
+        pressed: control.pressed
+        property var pressedColor: control.styleHints && control.styleHints["pressedColor"] ? control.styleHints["pressedColor"]: TizenConfig.panel.color.pressed
+        property var normalColor: control.styleHints && control.styleHints["color"] ? control.styleHints["color"]: TizenConfig.panel.color.normal
+        backgroundColor: control.pressed ? pressedColor : normalColor
+        implicitWidth: 600
+        implicitHeight: 100
+    }
+}
index 8221144..25eee6a 100644 (file)
@@ -32,7 +32,7 @@ SwitchStyle {
         Image {
             id:icon
             anchors.fill: parent
-            source: control.enabled ? ( control.checked ? TizenConfig.checkBox.onOff.on.handler.source.normal : TizenConfig.checkBox.onOff.off.handler.source.normal) :  ( control.checked ? TizenConfig.checkBox.onOff.on.handler.source.disabled : TizenConfig.checkBox.onOff.off.handler.source.disabled)
+            source: control.enabled ? ( control.checked ? TizenConfig.checkBox.onOffSliding.on.handler.source.normal : TizenConfig.checkBox.onOffSliding.off.handler.source.normal) :  ( control.checked ? TizenConfig.checkBox.onOffSliding.on.handler.source.disabled : TizenConfig.checkBox.onOffSliding.off.handler.source.disabled)
         }
     }
 
@@ -42,7 +42,7 @@ SwitchStyle {
         Image {
             id:onOffBackground
             anchors.fill: parent
-            source: control.enabled ? TizenConfig.checkBox.onOff.source.normal :  TizenConfig.checkBox.on.source.disabled
+            source: control.enabled ? TizenConfig.checkBox.onOffSliding.source.normal :  TizenConfig.checkBox.on.source.disabled
         }
     }
 }
index 7362221..4c6aace 100644 (file)
@@ -21,3 +21,4 @@ TitleBarStyle 1.0 TitleBarStyle.qml
 ToolBarStyle 1.0 ToolBarStyle.qml
 ToolBarButton 1.0 ToolBarButton.qml
 ViewStyle 1.0 ViewStyle.qml
+RadioButtonStyle 1.0 RadioButtonStyle.qml
index 29c4c38..ed66891 100644 (file)
@@ -27,7 +27,8 @@ QML_FILES = \
     TimeEditStyle.qml \
     ToolBarStyle.qml \
     ToolBarButton.qml \
-    PanelStyle.qml
+    PanelStyle.qml \
+    RadioButtonStyle.qml
 
 QML_FILES += \
     private/DateEditField.qml\