Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/kwineffects/package/contents/ui/main.qml
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2013 Antonis Tsiapaliokas <kok3rs@gmail.com> | ||||
3 | * Copyright (C) 2019 Vlad Zagorodniy <vladzzag@gmail.com> | ||||
4 | * | ||||
5 | * This program is free software; you can redistribute it and/or modify | ||||
6 | * it under the terms of the GNU General Public License as published by | ||||
7 | * the Free Software Foundation; either version 2 of the License, or | ||||
8 | * (at your option) any later version. | ||||
9 | * | ||||
10 | * This program is distributed in the hope that it will be useful, | ||||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
13 | * GNU General Public License for more details. | ||||
14 | * | ||||
15 | * You should have received a copy of the GNU General Public License | ||||
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
17 | */ | ||||
18 | | ||||
19 | import QtQuick 2.1 | ||||
20 | import QtQuick.Controls 2.5 as QtControls | ||||
21 | import QtQuick.Layouts 1.1 | ||||
22 | import org.kde.kcm 1.2 | ||||
23 | import org.kde.kconfig 1.0 | ||||
24 | import org.kde.kirigami 2.5 as Kirigami | ||||
25 | import org.kde.private.kcms.kwin.effects 1.0 as Private | ||||
26 | | ||||
27 | ScrollViewKCM { | ||||
28 | ConfigModule.quickHelp: i18n("This module lets you configure desktop effects.") | ||||
29 | | ||||
30 | header: ColumnLayout { | ||||
31 | QtControls.Label { | ||||
32 | Layout.fillWidth: true | ||||
33 | | ||||
34 | elide: Text.ElideRight | ||||
35 | text: i18n("Hint: To find out or configure how to activate an effect, look at the effect's settings.") | ||||
36 | } | ||||
37 | | ||||
38 | RowLayout { | ||||
39 | QtControls.TextField { | ||||
40 | id: searchField | ||||
41 | | ||||
42 | Layout.fillWidth: true | ||||
43 | | ||||
44 | // TODO: Needs clear button, missing in Qt. | ||||
45 | placeholderText: i18n("Search...") | ||||
46 | } | ||||
47 | | ||||
48 | QtControls.Button { | ||||
49 | id: configureButton | ||||
50 | | ||||
51 | QtControls.ToolTip.visible: hovered | ||||
52 | QtControls.ToolTip.text: i18n("Configure filter") | ||||
53 | | ||||
54 | icon.name: "configure" | ||||
55 | | ||||
56 | onClicked: menu.opened ? menu.close() : menu.open() | ||||
57 | } | ||||
58 | | ||||
59 | QtControls.Menu { | ||||
60 | id: menu | ||||
61 | | ||||
62 | x: parent.width - width | ||||
63 | y: configureButton.height | ||||
64 | | ||||
65 | QtControls.MenuItem { | ||||
66 | checkable: true | ||||
67 | checked: searchModel.excludeUnsupported | ||||
68 | text: i18n("Exclude Desktop Effects not supported by the Compositor") | ||||
69 | | ||||
70 | onToggled: searchModel.excludeUnsupported = checked | ||||
71 | } | ||||
72 | | ||||
73 | QtControls.MenuItem { | ||||
74 | checkable: true | ||||
75 | checked: searchModel.excludeInternal | ||||
76 | text: i18n("Exclude internal Desktop Effects") | ||||
77 | | ||||
78 | onToggled: searchModel.excludeInternal = checked | ||||
79 | } | ||||
80 | } | ||||
81 | } | ||||
82 | } | ||||
83 | | ||||
84 | view: ListView { | ||||
85 | id: effectsList | ||||
86 | | ||||
87 | property var _buttonGroups: [] | ||||
88 | | ||||
89 | spacing: Kirigami.Units.smallSpacing | ||||
90 | | ||||
91 | model: Private.EffectsFilterProxyModel { | ||||
92 | id: searchModel | ||||
93 | | ||||
94 | query: searchField.text | ||||
95 | sourceModel: kcm.effectsModel | ||||
96 | } | ||||
97 | | ||||
98 | delegate: Effect { | ||||
99 | width: effectsList.width | ||||
100 | } | ||||
101 | | ||||
102 | section.property: "CategoryRole" | ||||
103 | section.delegate: Item { | ||||
104 | width: effectsList.width | ||||
105 | height: sectionText.implicitHeight + 2 * Kirigami.Units.smallSpacing | ||||
106 | | ||||
107 | QtControls.Label { | ||||
108 | id: sectionText | ||||
109 | | ||||
110 | anchors.fill: parent | ||||
111 | | ||||
112 | color: Kirigami.Theme.disabledTextColor | ||||
113 | font.weight: Font.Bold | ||||
114 | horizontalAlignment: Text.AlignHCenter | ||||
115 | text: section | ||||
116 | verticalAlignment: Text.AlignVCenter | ||||
117 | } | ||||
118 | } | ||||
119 | | ||||
120 | function findButtonGroup(name) { | ||||
121 | for (let item of effectsList._buttonGroups) { | ||||
122 | if (item.name == name) { | ||||
123 | return item.group; | ||||
124 | } | ||||
125 | } | ||||
126 | | ||||
127 | let group = Qt.createQmlObject( | ||||
128 | 'import QtQuick 2.1;' + | ||||
129 | 'import QtQuick.Controls 2.5;' + | ||||
130 | 'ButtonGroup {}', | ||||
131 | effectsList, | ||||
132 | "dynamicButtonGroup" + effectsList._buttonGroups.length | ||||
133 | ); | ||||
134 | | ||||
135 | effectsList._buttonGroups.push({ name, group }); | ||||
136 | | ||||
137 | return group; | ||||
138 | } | ||||
139 | } | ||||
140 | | ||||
141 | footer: ColumnLayout { | ||||
142 | RowLayout { | ||||
143 | Layout.alignment: Qt.AlignRight | ||||
144 | | ||||
145 | QtControls.Button { | ||||
146 | icon.name: "get-hot-new-stuff" | ||||
147 | text: i18n("Get New Desktop Effects...") | ||||
148 | visible: KAuthorized.authorize("ghns") | ||||
149 | | ||||
150 | onClicked: kcm.openGHNS(this) | ||||
151 | } | ||||
152 | } | ||||
153 | } | ||||
154 | } |