Debian Codegraph @

app/qml/Settings/ColorRow.qml

raw
1 /*
2 * Copyright (C) 2016 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
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 General Public License for more details.
12 *
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/>.
15 *
16 * Authored by: Florian Boucault <[email protected]>
17 */
18
19 import QtQuick 2.4
20 import Lomiri.Components 1.3
21 import Lomiri.Components.Popups 1.3
22 import QMLTermWidget 1.0
23
24 ColorSchemeEditor {
25 id: colorRow
26
27 property int start
28 property int count
29
30 spacing: units.gu(1)
31
32 Row {
33 id: colors
34 spacing: units.gu(1)
35 Repeater {
36 model: colorRow.count
37 Rectangle {
38 radius: units.dp(3)
39 width: units.gu(3)
40 height: width
41 border.color: theme.palette.normal.base
42 border.width: units.dp(1)
43 color: colorScheme.getColor(start+index)
44
45 function setColor(color) {
46 colorScheme.setColor(start+index, color);
47 }
48
49 MouseArea {
50 anchors.fill: parent
51 onClicked: {
52 var colorPicker = PopupUtils.open(Qt.resolvedUrl("ColorPickerPopup.qml"),
53 parent,
54 {"originalColor": colorScheme.getColor(start+index),
55 "setColor": setColor});
56 colorPicker.Component.onDestruction.connect(colorRow.saveCustomizedScheme);
57 colorRow.switchToCustomizedScheme();
58 }
59 }
60 }
61 }
62 }
63 }