ColorsGallery.qml 4.12 KB
Newer Older
Marco Martin's avatar
Marco Martin committed
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
/*
 *   Copyright 2016 Aleix Pol Gonzalez <aleixpol@kde.org>
 *
 *   This program 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 or
 *   (at your option) any later version.
 *
 *   This program 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 program; if not, write to the
 *   Free Software Foundation, Inc.,
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

import QtQuick 2.0
import QtQuick.Layouts 1.2
import org.kde.kirigami 2.4
import QtQuick.Controls 2.0 as Controls

ScrollablePage {
    id: page
    title: "Colors"

   // leftPadding: 20//Units.gridUnit
    function endsWith(subject, predicate) {
        var idx = subject.indexOf(predicate);
        return idx + predicate.length == subject.length;
    }

    function getkeys() {
         var keys = ["textColor",
            "disabledTextColor",
            "highlightedTextColor",
            "activeTextColor",
            "linkColor",
            "visitedLinkColor",
            "negativeTextColor",
            "neutralTextColor",
            "positiveTextColor",
            "backgroundColor",
            "highlightColor",
47
48
49
50
51
52
            "activeBackgroundColor",
            "linkBackgroundColor",
            "visitedLinkBackgroundColor",
            "negativeBackgroundColor",
            "neutralBackgroundColor",
            "positiveBackgroundColor",
53
            "alternateBackgroundColor",
Marco Martin's avatar
Marco Martin committed
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
            "focusColor",
            "hoverColor"];

            return keys;
    }

    function setName(id) {
        switch(id) {
        case 0:
            return "Theme.View";
        case 1:
            return "Theme.Window";
        case 2:
            return "Theme.Button";
        case 3:
            return "Theme.Selection";
        case 4:
            return "Theme.Tooltip";
        case 5:
            return "Theme.Complementary";
74
75
        case 6:
            return "Theme.Header";
Marco Martin's avatar
Marco Martin committed
76
77
78
79
80
81
82
83
        }
    }

    Column {
        Heading {
            text: "Colors by Theme.colorSet"
        }
        Repeater {
84
            model: Theme.Header + 1
Marco Martin's avatar
Marco Martin committed
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
            delegate: Column {
                width: parent.width
                Heading {
                    level: 2
                    text: setName(modelData)
                }
                Flow {
                    id: view
                    Theme.colorSet: modelData
                    Theme.inherit: false
                    anchors.horizontalCenter: parent.horizontalCenter
                    width: Math.floor(parent.width / (Units.gridUnit * 9)) * (Units.gridUnit * 9)
                    Repeater {
                        model: page.getkeys()

                        delegate: ColumnLayout {
                            width: Units.gridUnit * 9
                            Rectangle {
                                Layout.alignment: Qt.AlignHCenter
                                width: Units.gridUnit * 7
                                height: Units.gridUnit * 3
                                color: Theme[modelData]
                                border {
                                    width: 1
                                    color: "black"
                                }
                            }
                            Controls.Label {
                                Theme.colorSet: Theme.Window
                                Theme.inherit: false
                                Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
                                text: modelData
                            }
                            Item {
                                width: 1
                                height: Units.smallSpacing
                            }
                        }
                    }
                }
            }
        }
    }
}