Lomiri
Loading...
Searching...
No Matches
MainViewStyle.qml
1/*
2 * Copyright 2012 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
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 Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16import QtQuick 2.12
17import Lomiri.Components 1.3
18
19// FIXME: copied with slight modifications from Lomiri UI Toolkit's Ambiance's theme
20Item {
21 anchors.fill: parent
22 z: -1
23 id: mainViewStyle
24
25 property var theme
26
27 /*!
28 Color of the header's background.
29
30 \sa backgroundColor, footerColor
31 */
32 property color headerColor: styledItem.headerColor
33
34 /*!
35 Color of the background.
36
37 The background is usually a single color. However if \l headerColor
38 or \l footerColor are set then a gradient of colors will be drawn.
39
40 \sa footerColor, headerColor
41 */
42 property color backgroundColor: styledItem.backgroundColor
43
44 /*!
45 Color of the footer's background.
46
47 \sa backgroundColor, headerColor
48 */
49 property color footerColor: styledItem.footerColor
50
51 Gradient {
52 id: backgroundGradient
53 GradientStop { position: 0.0; color: mainViewStyle.headerColor }
54 GradientStop { position: 0.83; color: mainViewStyle.backgroundColor }
55 GradientStop { position: 1.0; color: mainViewStyle.footerColor }
56 }
57
58 Rectangle {
59 id: backgroundColor
60 anchors.fill: parent
61 color: mainViewStyle.backgroundColor
62 gradient: internals.isGradient ? backgroundGradient : null
63 }
64
65 QtObject {
66 id: internals
67 property bool isGradient: mainViewStyle.backgroundColor != mainViewStyle.headerColor ||
68 mainViewStyle.backgroundColor != mainViewStyle.footerColor
69
70 /*
71 As we don't know the order the property bindings and onXXXChanged signals are evaluated
72 we should rely only on one property when changing the theme to avoid intermediate
73 theme changes due to properties being evaluated separately.
74
75 Qt bug: https://bugreports.qt-project.org/browse/QTBUG-11712
76 */
77 property string theme: (ColorUtils.luminance(styledItem.backgroundColor) >= 0.85) ? "Ambiance" : "SuruDark"
78 }
79
80 // automatically select the appropriate theme depending on the background colors
81 Binding {
82 target: theme
83 property: "name"
84 value: internals.theme
85 when: internals.theme !== ""
86 }
87}