2
* Copyright (C) 2014 Canonical, Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; version 3.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
import Ubuntu.Components 1.3
19
import Utils 0.1 as Utils
26
readonly property var parsedStyle: String(style)
27
.match(/^(color|gradient):\/\/\/(?:(#(?:[0-9a-f]{3,4}){1,2}|[a-z]{3,}))(?:\/(#(?:[0-9a-f]{3,4}){1,2}|[a-z]{3,}))?\/?$/i)
28
readonly property var luminance: {
29
if (!parsedStyle) return 0.5;
30
if (parsedStyle[1] === "color") return Utils.Style.luminance(parsedStyle[2]);
31
else if (parsedStyle[1] === "gradient") return Utils.Style.luminance(parsedStyle[2], parsedStyle[3]);
34
// FIXME this is only here for highlight purposes (see DashNavigation.qml, too)
35
readonly property color topColor: parsedStyle ? parsedStyle[2] : UbuntuColors.lightGrey
38
if (style == "") return null;
39
if (!parsedStyle) return image;
40
if (parsedStyle[1] === "color") return solid
41
if (parsedStyle[1] === "gradient") return gradient
44
onLoaded: if (item.hasOwnProperty("parsedStyle")) {
45
item.parsedStyle = Qt.binding(function() { return root.parsedStyle } );
54
property var parsedStyle
56
color: parsedStyle ? parsedStyle[2] : "#ffffff"
64
objectName: "gradient"
66
property var parsedStyle
69
GradientStop { position: 0; color: parsedStyle ? parsedStyle[2] : "#000000" }
70
GradientStop { position: 1; color: parsedStyle ? parsedStyle[3] : "#000000" }
81
source: width > 0 && height > 0 && root.style || ""
83
sourceSize.width: width
84
sourceSize.height: height