|
| 1 | +/* |
| 2 | + * Copyright 2018 Aditya Mehra <[email protected]> |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + * |
| 16 | + */ |
| 17 | + |
| 18 | +import QtQuick.Layouts 1.4 |
| 19 | +import QtQuick 2.4 |
| 20 | +import QtQuick.Controls 2.11 |
| 21 | +import org.kde.kirigami 2.11 as Kirigami |
| 22 | +import org.kde.plasma.core 2.0 as PlasmaCore |
| 23 | +import Mycroft 1.0 as Mycroft |
| 24 | +import OVOSPlugin 1.0 as OVOSPlugin |
| 25 | +import QtGraphicalEffects 1.12 |
| 26 | + |
| 27 | +Item { |
| 28 | + id: customizeSettingsView |
| 29 | + anchors.fill: parent |
| 30 | + property var colorSchemeModel |
| 31 | + property var setColorScheme |
| 32 | + |
| 33 | + Component.onCompleted: { |
| 34 | + OVOSPlugin.Configuration.updateSchemeList(); |
| 35 | + colorSchemeModel = OVOSPlugin.Configuration.getSchemeList(); |
| 36 | + colorSchemesView.model = colorSchemeModel.schemes; |
| 37 | + setColorScheme = OVOSPlugin.Configuration.getSelectedSchemeName(); |
| 38 | + console.log(setColorScheme); |
| 39 | + } |
| 40 | + |
| 41 | + Connections { |
| 42 | + target: OVOSPlugin.Configuration |
| 43 | + onSchemeChanged: { |
| 44 | + setColorScheme = OVOSPlugin.Configuration.getSelectedSchemeName(); |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + Item { |
| 49 | + id: topArea |
| 50 | + anchors.left: parent.left |
| 51 | + anchors.right: parent.right |
| 52 | + anchors.top: parent.top |
| 53 | + height: Kirigami.Units.gridUnit * 2 |
| 54 | + |
| 55 | + Kirigami.Heading { |
| 56 | + id: customizeSettingPageTextHeading |
| 57 | + level: 1 |
| 58 | + wrapMode: Text.WordWrap |
| 59 | + anchors.centerIn: parent |
| 60 | + font.bold: true |
| 61 | + text: "Customize Settings" |
| 62 | + color: Kirigami.Theme.textColor |
| 63 | + } |
| 64 | + } |
| 65 | + |
| 66 | + Item { |
| 67 | + anchors.top: topArea.bottom |
| 68 | + anchors.topMargin: Kirigami.Units.largeSpacing |
| 69 | + anchors.left: parent.left |
| 70 | + anchors.right: parent.right |
| 71 | + anchors.bottom: bottomArea.top |
| 72 | + |
| 73 | + GridView { |
| 74 | + id: colorSchemesView |
| 75 | + width: parent.width |
| 76 | + height: parent.height |
| 77 | + cellWidth: parent.width / 3 |
| 78 | + cellHeight: parent.height / 2 |
| 79 | + clip: true |
| 80 | + |
| 81 | + delegate: ItemDelegate { |
| 82 | + id: parentRectDelta |
| 83 | + implicitHeight: colorSchemesView.cellHeight - (Mycroft.Units.largeSpacing * 2) |
| 84 | + implicitWidth: colorSchemesView.cellWidth - (Mycroft.Units.largeSpacing * 2) |
| 85 | + |
| 86 | + background: Rectangle { |
| 87 | + color: modelData.primaryColor |
| 88 | + radius: 10 |
| 89 | + } |
| 90 | + |
| 91 | + Item { |
| 92 | + id: d1item |
| 93 | + anchors.top: parent.top |
| 94 | + anchors.left: parent.left |
| 95 | + anchors.right: parent.right |
| 96 | + anchors.margins: Mycroft.Units.gridUnit / 2 |
| 97 | + height: parent.height * 0.70 |
| 98 | + |
| 99 | + GridLayout { |
| 100 | + anchors.fill: parent |
| 101 | + anchors.margins: Mycroft.Units.gridUnit / 2 |
| 102 | + columns: 2 |
| 103 | + |
| 104 | + Rectangle { |
| 105 | + Layout.fillWidth: true |
| 106 | + Layout.fillHeight: true |
| 107 | + color: modelData.primaryColor |
| 108 | + border.width: 2 |
| 109 | + border.color: Qt.darker(Kirigami.Theme.backgroundColor, 1.5) |
| 110 | + |
| 111 | + Text { |
| 112 | + anchors.fill: parent |
| 113 | + anchors.margins: Mycroft.Units.gridUnit |
| 114 | + horizontalAlignment: Text.AlignHCenter |
| 115 | + verticalAlignment: Text.AlignVCenter |
| 116 | + text: "P" |
| 117 | + fontSizeMode: Text.Fit |
| 118 | + minimumPixelSize: 5 |
| 119 | + font.pixelSize: 40 |
| 120 | + color: Qt.darker(Kirigami.Theme.textColor, 1.5) |
| 121 | + font.bold: true |
| 122 | + } |
| 123 | + } |
| 124 | + |
| 125 | + Rectangle { |
| 126 | + Layout.fillWidth: true |
| 127 | + Layout.fillHeight: true |
| 128 | + color: modelData.secondaryColor |
| 129 | + border.width: 2 |
| 130 | + border.color: Qt.darker(Kirigami.Theme.backgroundColor, 1.5) |
| 131 | + |
| 132 | + Text { |
| 133 | + anchors.fill: parent |
| 134 | + anchors.margins: Mycroft.Units.gridUnit |
| 135 | + horizontalAlignment: Text.AlignHCenter |
| 136 | + verticalAlignment: Text.AlignVCenter |
| 137 | + text: "S" |
| 138 | + fontSizeMode: Text.Fit |
| 139 | + minimumPixelSize: 5 |
| 140 | + font.pixelSize: 40 |
| 141 | + color: Qt.darker(Kirigami.Theme.textColor, 1.5) |
| 142 | + font.bold: true |
| 143 | + } |
| 144 | + } |
| 145 | + Rectangle{ |
| 146 | + Layout.fillWidth: true |
| 147 | + Layout.fillHeight: true |
| 148 | + color: modelData.textColor |
| 149 | + border.width: 2 |
| 150 | + border.color: Qt.darker(Kirigami.Theme.backgroundColor, 1.5) |
| 151 | + |
| 152 | + Text { |
| 153 | + anchors.fill: parent |
| 154 | + anchors.margins: Mycroft.Units.gridUnit |
| 155 | + horizontalAlignment: Text.AlignHCenter |
| 156 | + verticalAlignment: Text.AlignVCenter |
| 157 | + text: "T" |
| 158 | + fontSizeMode: Text.Fit |
| 159 | + minimumPixelSize: 5 |
| 160 | + font.pixelSize: 40 |
| 161 | + color: Qt.darker(Kirigami.Theme.textColor, 1.5) |
| 162 | + font.bold: true |
| 163 | + } |
| 164 | + } |
| 165 | + Rectangle{ |
| 166 | + Layout.fillWidth: true |
| 167 | + Layout.fillHeight: true |
| 168 | + visible: modelData.name == setColorScheme ? 1 : 0 |
| 169 | + enabled: modelData.name == setColorScheme ? 1 : 0 |
| 170 | + color: "transparent" |
| 171 | + |
| 172 | + Kirigami.Icon { |
| 173 | + anchors.fill: parent |
| 174 | + anchors.margins: Mycroft.Units.gridUnit * 2 |
| 175 | + source: Qt.resolvedUrl("images/tick.svg") |
| 176 | + color: Kirigami.Theme.textColor |
| 177 | + } |
| 178 | + } |
| 179 | + } |
| 180 | + } |
| 181 | + |
| 182 | + Kirigami.Separator { |
| 183 | + id: cardSept |
| 184 | + anchors.top: d1item.bottom |
| 185 | + anchors.left: parent.left |
| 186 | + anchors.right: parent.right |
| 187 | + height: 16 |
| 188 | + color: modelData.secondaryColor |
| 189 | + } |
| 190 | + |
| 191 | + Item { |
| 192 | + id: d2item |
| 193 | + anchors.top: cardSept.bottom |
| 194 | + anchors.left: parent.left |
| 195 | + anchors.right: parent.right |
| 196 | + anchors.bottom: parent.bottom |
| 197 | + clip: true |
| 198 | + |
| 199 | + Label { |
| 200 | + anchors.fill: parent |
| 201 | + anchors.margins: Mycroft.Units.gridUnit / 2 |
| 202 | + horizontalAlignment: Text.AlignHCenter |
| 203 | + verticalAlignment: Text.AlignVCenter |
| 204 | + font.pixelSize: 20 |
| 205 | + minimumPixelSize: 5 |
| 206 | + fontSizeMode: Text.Fit |
| 207 | + maximumLineCount: 1 |
| 208 | + text: modelData.name |
| 209 | + color: modelData.textColor |
| 210 | + elide: Text.ElideRight |
| 211 | + } |
| 212 | + } |
| 213 | + |
| 214 | + onDoubleClicked: { |
| 215 | + OVOSPlugin.Configuration.setScheme(modelData.name, modelData.path) |
| 216 | + } |
| 217 | + } |
| 218 | + } |
| 219 | + } |
| 220 | + |
| 221 | + Item { |
| 222 | + id: bottomArea |
| 223 | + anchors.left: parent.left |
| 224 | + anchors.right: parent.right |
| 225 | + anchors.bottom: parent.bottom |
| 226 | + height: Mycroft.Units.gridUnit * 6 |
| 227 | + |
| 228 | + Kirigami.Separator { |
| 229 | + id: areaSep |
| 230 | + anchors.top: parent.top |
| 231 | + anchors.left: parent.left |
| 232 | + anchors.right: parent.right |
| 233 | + color: Kirigami.Theme.highlightColor |
| 234 | + height: 2 |
| 235 | + } |
| 236 | + |
| 237 | + RowLayout { |
| 238 | + anchors.top: areaSep.bottom |
| 239 | + anchors.bottom: parent.bottom |
| 240 | + anchors.left: parent.left |
| 241 | + anchors.right: parent.right |
| 242 | + |
| 243 | + Image { |
| 244 | + id: backIcon |
| 245 | + source: "images/back.png" |
| 246 | + Layout.preferredHeight: Kirigami.Units.iconSizes.medium |
| 247 | + Layout.preferredWidth: Kirigami.Units.iconSizes.medium |
| 248 | + |
| 249 | + ColorOverlay { |
| 250 | + anchors.fill: parent |
| 251 | + source: backIcon |
| 252 | + cached: true |
| 253 | + color: Kirigami.Theme.textColor |
| 254 | + } |
| 255 | + } |
| 256 | + |
| 257 | + Kirigami.Heading { |
| 258 | + level: 2 |
| 259 | + wrapMode: Text.WordWrap |
| 260 | + font.bold: true |
| 261 | + color: Kirigami.Theme.textColor |
| 262 | + text: "Device Settings" |
| 263 | + verticalAlignment: Text.AlignVCenter |
| 264 | + Layout.fillWidth: true |
| 265 | + Layout.preferredHeight: Kirigami.Units.gridUnit * 2 |
| 266 | + } |
| 267 | + } |
| 268 | + |
| 269 | + MouseArea { |
| 270 | + anchors.fill: parent |
| 271 | + onClicked: { |
| 272 | + triggerGuiEvent("mycroft.device.settings", {}) |
| 273 | + } |
| 274 | + } |
| 275 | + } |
| 276 | +} |
| 277 | + |
0 commit comments