summaryrefslogtreecommitdiff
path: root/prototype_2016/third_party/qml-material/src/window/AppTheme.qml
blob: bef7e3070c4e9391e36dbe2f93639ad687465a36 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
 * QML Material - An application framework implementing Material Design.
 *
 * Copyright (C) 2015-2016 Michael Spencer <sonrisesoftware@gmail.com>
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

import QtQuick 2.4
import Material 0.3

/*!
   \qmltype AppTheme
   \inqmlmodule Material

   \brief A helper class used in \l ApplicationWindow to set your app's theme colors.
 */
QtObject {
    id: appTheme

    /*!
       The accent theme color used in your app for a highlight color in many UI components.
       This is a helper property to set \l Theme::accentColor.
     */
    property string accentColor

    /*!
       The default background color used throughout the app. This is a helper property
       to set \l Theme::backgroundColor.
     */
    property string backgroundColor
    property string tabHighlightColor


    /*!
       The primary theme color used in your app for the toolbar and other primary UI elements.
       This is a helper property to set \l Theme::primaryColor.
     */
    property string primaryColor

    /*!
       A darker version of the primary theme color used by the system status bar and
       window decorations. This is a helper property to set \l Theme::primaryDarkColor.
     */
    property string primaryDarkColor: primaryColor

    onPrimaryColorChanged: Theme.primaryColor = getColor(primaryColor, "500")
    onPrimaryDarkColorChanged: Theme.primaryDarkColor = getColor(primaryDarkColor, "700")
    onAccentColorChanged: Theme.accentColor = getColor(accentColor, "A200")
    onBackgroundColorChanged: Theme.backgroundColor = getColor(backgroundColor, "500")
    onTabHighlightColorChanged: Theme.tabHighlightColor = getColor(tabHighlightColor, "500")

    function getColor(color, shade) {
        if (Palette.colors.hasOwnProperty(color)) {
            return Palette.colors[color][shade]
        } else {
            return color
        }
    }
}