Changeset View
Changeset View
Standalone View
Standalone View
kcms/style/package/contents/ui/main.qml
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright 2019 Kai Uwe Broulik <kde@privat.broulik.de> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or | ||||
5 | * modify it under the terms of the GNU General Public License as | ||||
6 | * published by the Free Software Foundation; either version 2 of | ||||
7 | * the License or (at your option) version 3 or any later version | ||||
8 | * accepted by the membership of KDE e.V. (or its successor approved | ||||
9 | * by the membership of KDE e.V.), which shall act as a proxy | ||||
10 | * defined in Section 14 of version 3 of the license. | ||||
11 | * | ||||
12 | * This program is distributed in the hope that it will be useful, | ||||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
15 | * GNU General Public License for more details. | ||||
16 | * | ||||
17 | * You should have received a copy of the GNU General Public License | ||||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | */ | ||||
20 | | ||||
21 | import QtQuick 2.6 | ||||
22 | import QtQuick.Layouts 1.1 | ||||
23 | import QtQuick.Controls 2.3 as QtControls | ||||
24 | import org.kde.kirigami 2.4 as Kirigami | ||||
25 | import org.kde.kcm 1.1 as KCM | ||||
26 | import org.kde.private.kcms.style 1.0 as Private | ||||
27 | | ||||
28 | KCM.GridViewKCM { | ||||
29 | id: root | ||||
30 | | ||||
31 | KCM.ConfigModule.quickHelp: i18n("This module allows you to modify the visual appearance of applications' user interface elements.") | ||||
32 | | ||||
33 | view.model: kcm.model | ||||
34 | view.currentIndex: kcm.model.selectedStyleIndex | ||||
35 | | ||||
36 | Component.onCompleted: { | ||||
37 | // The widget thumbnails are a bit more elaborate and need more room, especially when translated | ||||
38 | view.implicitCellWidth = Kirigami.Units.gridUnit * 20; | ||||
39 | view.implicitCellHeight = Kirigami.Units.gridUnit * 14; | ||||
40 | } | ||||
41 | | ||||
42 | // putting the InlineMessage as header item causes it to show up initially despite visible false | ||||
43 | header: ColumnLayout { | ||||
44 | Kirigami.InlineMessage { | ||||
45 | id: infoLabel | ||||
46 | Layout.fillWidth: true | ||||
47 | | ||||
48 | showCloseButton: true | ||||
49 | visible: false | ||||
50 | | ||||
51 | Connections { | ||||
52 | target: kcm | ||||
53 | onShowErrorMessage: { | ||||
54 | infoLabel.type = Kirigami.MessageType.Error; | ||||
55 | infoLabel.text = message; | ||||
56 | infoLabel.visible = true; | ||||
57 | } | ||||
58 | } | ||||
59 | } | ||||
60 | } | ||||
61 | | ||||
62 | view.delegate: KCM.GridDelegate { | ||||
63 | id: delegate | ||||
64 | | ||||
65 | text: model.display | ||||
66 | toolTip: model.description | ||||
67 | | ||||
68 | thumbnailAvailable: thumbnailItem.valid | ||||
69 | thumbnail: Private.PreviewItem { | ||||
70 | id: thumbnailItem | ||||
71 | anchors.fill: parent | ||||
72 | styleName: model.styleName | ||||
73 | | ||||
74 | Connections { | ||||
75 | target: kcm | ||||
76 | onStyleReconfigured: { | ||||
77 | if (styleName === model.styleName) { | ||||
78 | thumbnailItem.reload(); | ||||
79 | } | ||||
80 | } | ||||
81 | } | ||||
82 | } | ||||
83 | | ||||
84 | actions: [ | ||||
85 | Kirigami.Action { | ||||
86 | iconName: "document-edit" | ||||
87 | tooltip: i18n("Configure Style...") | ||||
88 | enabled: model.configurable | ||||
89 | onTriggered: kcm.configure(model.styleName) | ||||
90 | } | ||||
91 | ] | ||||
92 | onClicked: { | ||||
93 | kcm.model.selectedStyle = model.styleName; | ||||
94 | view.forceActiveFocus(); | ||||
95 | } | ||||
96 | } | ||||
97 | | ||||
98 | footer: RowLayout { | ||||
99 | Layout.fillWidth: true | ||||
100 | | ||||
101 | QtControls.Button { | ||||
102 | id: effectSettingsButton | ||||
103 | text: i18n("Configure Icons and Toolbars") | ||||
104 | icon.name: "configure-toolbars" // proper icon? | ||||
105 | checkable: true | ||||
106 | checked: effectSettingsPopupLoader.item && effectSettingsPopupLoader.item.opened | ||||
107 | onClicked: { | ||||
108 | effectSettingsPopupLoader.active = true; | ||||
109 | effectSettingsPopupLoader.item.open(); | ||||
110 | } | ||||
111 | } | ||||
112 | } | ||||
113 | | ||||
114 | Loader { | ||||
115 | id: effectSettingsPopupLoader | ||||
116 | active: false | ||||
117 | sourceComponent: EffectSettingsPopup { | ||||
118 | parent: effectSettingsButton | ||||
119 | y: -height | ||||
120 | } | ||||
121 | } | ||||
122 | } |