registerShortcut
[apps/homescreen.git] / homescreen / qml / ShortcutIcon.qml
index 6f8e05e..e891c99 100644 (file)
  */
 
 import QtQuick 2.2
+import QtQuick.Controls 2.0
+import QtGraphicalEffects 1.0
 
 MouseArea {
     id: root
     width: 195
     height: 216.8
     property string name: 'Home'
+    property string icon:'./images/Shortcut/'
     property bool active: false
-    Image {
+    property bool isBlank: false
+
+    Item {
         id: icon
+        property real desaturation: 0
         anchors.fill: parent
-        source: './images/Shortcut/HMI_Shortcut_%1-01.png'.arg(root.name)
+        Image {
+            id: inactiveIcon
+            anchors.fill: parent
+            source: './images/Shortcut/blank.svg'
+//            source: isBlank ? './images/Shortcut/blank.svg' : root.icon
+            property string initial: root.name.substring(0,1).toUpperCase()
+            Label {
+                style: Text.Outline
+                styleColor: '#00FFFF'
+                color: 'transparent'
+                font.pixelSize: 75
+                anchors.centerIn: parent
+                text: inactiveIcon.initial
+                visible: root.isBlank
+            }
+        }
+        Image {
+            id: activeIcon
+            anchors.fill: parent
+            source: './images/Shortcut/blank_active.svg'
+//            source: isBlank ? './images/Shortcut/blank_active.svg' : root.icon
+            property string initial: root.name.substring(0,1).toUpperCase()
+            Label {
+                style: Text.Outline
+                styleColor: '#00FFFF'
+                color: 'transparent'
+                font.pixelSize: 75
+                anchors.centerIn: parent
+                text: activeIcon.initial
+                visible: root.isBlank
+            }
+            opacity: 0.0
+        }
+        Image {
+            id: sourceIcon
+            anchors.fill: parent
+            source: isBlank ? null : root.icon
+        }
+
+        layer.enabled: true
+        layer.effect: Desaturate {
+            id: desaturate
+            desaturation: icon.desaturation
+            cached: true
+        }
     }
-    Image {
-        anchors.fill: parent
-        source: './images/Shortcut/HMI_Shortcut_%1_Active-01.png'.arg(root.name)
-        opacity: 1.0 - icon.opacity
+
+    Label {
+        id: name
+        y: 160
+        width: root.width - 10
+        font.pixelSize: 15
+        font.letterSpacing: 5
+        // wrapMode: Text.WordWrap
+        anchors.horizontalCenter: parent.horizontalCenter
+        horizontalAlignment: Text.AlignHCenter
+        color: "white"
+        text: qsTr((root.name === "launcher" ? "home" : root.name).toUpperCase())
     }
+
     states: [
         State {
             when: root.active
             PropertyChanges {
-                target: icon
+                target: inactiveIcon
                 opacity: 0.0
             }
-        }
-    ]
-
-    transitions: [
-        Transition {
-            NumberAnimation {
-                properties: 'opacity'
-                easing.type: Easing.OutExpo
+            PropertyChanges {
+                target: activeIcon
+                opacity: 1.0
             }
         }
     ]