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("Desktop Effects") | ||||
29 | | ||||
30 | Private.EffectsFilterProxyModel { | ||||
31 | id: searchModel | ||||
32 | sourceModel: kcm.effectsModel | ||||
33 | query: searchField.text | ||||
34 | } | ||||
35 | | ||||
36 | header: ColumnLayout { | ||||
37 | QtControls.Label { | ||||
38 | Layout.fillWidth: true | ||||
39 | text: i18n("Hint: To find out or configure how to activate an effect, look at the effect's settings.") | ||||
40 | elide: Text.ElideRight | ||||
41 | } | ||||
42 | | ||||
43 | RowLayout { | ||||
44 | QtControls.TextField { | ||||
45 | id: searchField | ||||
46 | Layout.fillWidth: true | ||||
47 | | ||||
48 | // TODO: Needs clear button, missing in Qt. | ||||
49 | placeholderText: i18n("Search...") | ||||
50 | } | ||||
51 | | ||||
52 | QtControls.Button { | ||||
53 | id: configureButton | ||||
54 | QtControls.ToolTip.visible: hovered | ||||
55 | QtControls.ToolTip.text: i18n("Configure filter") | ||||
56 | | ||||
57 | icon.name: "configure" | ||||
58 | | ||||
59 | onClicked: menu.opened ? menu.close() : menu.open() | ||||
60 | } | ||||
61 | | ||||
62 | QtControls.Menu { | ||||
63 | id: menu | ||||
64 | x: parent.width - width | ||||
65 | y: configureButton.height | ||||
66 | | ||||
67 | QtControls.MenuItem { | ||||
68 | text: i18n("Exclude Desktop Effects not supported by the Compositor") | ||||
69 | checkable: true | ||||
70 | checked: searchModel.excludeUnsupported | ||||
71 | onToggled: searchModel.excludeUnsupported = checked | ||||
72 | } | ||||
73 | | ||||
74 | QtControls.MenuItem { | ||||
75 | text: i18n("Exclude internal Desktop Effects") | ||||
76 | checkable: true | ||||
77 | checked: searchModel.excludeInternal | ||||
78 | onToggled: searchModel.excludeInternal = checked | ||||
79 | } | ||||
80 | } | ||||
81 | } | ||||
82 | } | ||||
83 | | ||||
84 | view: ListView { | ||||
85 | id: effectsList | ||||
86 | | ||||
87 | property var _buttonGroups: [] | ||||
88 | | ||||
89 | function findButtonGroup(name) { | ||||
90 | for (let item of effectsList._buttonGroups) { | ||||
91 | if (item.name == name) { | ||||
92 | return item.group; | ||||
93 | } | ||||
94 | } | ||||
95 | | ||||
96 | let group = Qt.createQmlObject( | ||||
97 | 'import QtQuick 2.1;' + | ||||
98 | 'import QtQuick.Controls 2.5;' + | ||||
99 | 'ButtonGroup {}', | ||||
100 | effectsList, | ||||
101 | "dynamicButtonGroup" + effectsList._buttonGroups.length | ||||
102 | ); | ||||
103 | | ||||
104 | effectsList._buttonGroups.push({ name, group }); | ||||
105 | | ||||
106 | return group; | ||||
107 | } | ||||
108 | | ||||
109 | model: searchModel | ||||
110 | | ||||
111 | delegate: Effect { | ||||
112 | width: effectsList.width | ||||
113 | } | ||||
114 | | ||||
115 | section.property: "CategoryRole" | ||||
116 | section.delegate: Item { | ||||
117 | width: effectsList.width | ||||
118 | height: sectionText.implicitHeight + 2 * Kirigami.Units.smallSpacing | ||||
119 | | ||||
120 | QtControls.Label { | ||||
121 | id: sectionText | ||||
122 | anchors.fill: parent | ||||
123 | font.weight: Font.Bold | ||||
124 | horizontalAlignment: Text.AlignHCenter | ||||
125 | verticalAlignment: Text.AlignVCenter | ||||
126 | text: section | ||||
127 | color: Kirigami.Theme.disabledTextColor | ||||
128 | } | ||||
129 | } | ||||
130 | | ||||
131 | spacing: Kirigami.Units.smallSpacing | ||||
132 | } | ||||
133 | | ||||
134 | footer: ColumnLayout { | ||||
135 | RowLayout { | ||||
136 | Layout.alignment: Qt.AlignRight | ||||
137 | | ||||
138 | QtControls.Button { | ||||
139 | text: i18n("Get New Desktop Effects...") | ||||
140 | icon.name: "get-hot-new-stuff" | ||||
141 | visible: KAuthorized.authorize("ghns") | ||||
142 | onClicked: kcm.openGHNS(this) | ||||
143 | } | ||||
144 | } | ||||
145 | } | ||||
146 | } |