Changeset View
Changeset View
Standalone View
Standalone View
kcms/style/package/contents/ui/GtkStylePage.qml
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright 2020 Mikhail Zolotukhin <zomial@protonmail.com> | ||||
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.7 | ||||
22 | import QtQuick.Layouts 1.1 | ||||
23 | import QtQuick.Dialogs 1.0 as QtDialogs | ||||
24 | import QtQuick.Controls 2.10 as QtControls | ||||
25 | import org.kde.kirigami 2.10 as Kirigami | ||||
26 | import org.kde.private.kcms.style 1.0 as Private | ||||
27 | import org.kde.kcm 1.2 as KCM | ||||
28 | | ||||
29 | Kirigami.Page { | ||||
30 | id: gtkStylePage | ||||
31 | title: i18n("GNOME/GTK Application Style") | ||||
32 | | ||||
33 | ColumnLayout { | ||||
34 | anchors.fill: parent | ||||
35 | | ||||
36 | Kirigami.InlineMessage { | ||||
37 | id: infoLabel | ||||
38 | Layout.fillWidth: true | ||||
39 | | ||||
40 | showCloseButton: true | ||||
41 | visible: false | ||||
42 | | ||||
43 | Connections { | ||||
44 | target: kcm.gtkPage | ||||
45 | onShowErrorMessage: { | ||||
46 | infoLabel.type = Kirigami.MessageType.Error; | ||||
47 | infoLabel.text = message; | ||||
48 | infoLabel.visible = true; | ||||
49 | } | ||||
50 | } | ||||
51 | } | ||||
52 | | ||||
53 | Kirigami.FormLayout { | ||||
54 | wideMode: true | ||||
55 | | ||||
56 | Row { | ||||
57 | Kirigami.FormData.label: i18n("GTK2 theme:") | ||||
58 | | ||||
59 | Flow { | ||||
60 | spacing: Kirigami.Units.smallSpacing | ||||
61 | | ||||
62 | QtControls.ComboBox { | ||||
63 | id: gtk2ThemeCombo | ||||
64 | model: kcm.gtkPage.gtk2ThemesModel | ||||
65 | currentIndex: model.findThemeIndex(kcm.gtkPage.gtk2ThemeFromConfig()) | ||||
66 | onCurrentTextChanged: function() { | ||||
67 | model.selectedTheme = currentText | ||||
68 | gtk2RemoveButton.enabled = model.selectedThemeRemovable() | ||||
69 | } | ||||
70 | onActivated: model.setSelectedThemeDirty() | ||||
71 | textRole: "theme-name" | ||||
72 | | ||||
73 | Connections { | ||||
74 | target: kcm.gtkPage | ||||
75 | onSelectGtk2ThemeInCombobox: function(themeName) { | ||||
76 | gtk2ThemeCombo.currentIndex = gtk2ThemeCombo.model.findThemeIndex(themeName) | ||||
77 | } | ||||
78 | } | ||||
79 | } | ||||
80 | | ||||
81 | QtControls.Button { | ||||
82 | id: gtk2RemoveButton | ||||
83 | icon.name: "edit-delete" | ||||
84 | onClicked: gtk2ThemeCombo.model.removeSelectedTheme() | ||||
85 | } | ||||
86 | | ||||
87 | QtControls.Button { | ||||
88 | icon.name: "preview" | ||||
89 | text: i18n("Preview...") | ||||
90 | onClicked: kcm.gtkPage.showGtk2Preview() | ||||
91 | } | ||||
92 | } | ||||
93 | } | ||||
94 | | ||||
95 | Row { | ||||
96 | Kirigami.FormData.label: i18n("GTK3 theme:") | ||||
97 | | ||||
98 | Flow { | ||||
99 | spacing: Kirigami.Units.smallSpacing | ||||
100 | | ||||
101 | QtControls.ComboBox { | ||||
102 | id: gtk3ThemeCombo | ||||
103 | model: kcm.gtkPage.gtk3ThemesModel | ||||
104 | currentIndex: model.findThemeIndex(kcm.gtkPage.gtk3ThemeFromConfig()) | ||||
105 | onCurrentTextChanged: function() { | ||||
106 | model.selectedTheme = currentText | ||||
107 | gtk3RemoveButton.enabled = model.selectedThemeRemovable() | ||||
108 | } | ||||
109 | onActivated: model.setSelectedThemeDirty() | ||||
110 | textRole: "theme-name" | ||||
111 | | ||||
112 | Connections { | ||||
113 | target: kcm.gtkPage | ||||
114 | onSelectGtk3ThemeInCombobox: function(themeName) { | ||||
115 | gtk3ThemeCombo.currentIndex = gtk3ThemeCombo.model.findThemeIndex(themeName) | ||||
116 | } | ||||
117 | } | ||||
118 | } | ||||
119 | | ||||
120 | QtControls.Button { | ||||
121 | id: gtk3RemoveButton | ||||
122 | icon.name: "edit-delete" | ||||
123 | onClicked: gtk3ThemeCombo.model.removeSelectedTheme() | ||||
124 | } | ||||
125 | | ||||
126 | QtControls.Button { | ||||
127 | icon.name: "preview" | ||||
128 | text: i18n("Preview...") | ||||
129 | onClicked: kcm.gtkPage.showGtk3Preview() | ||||
130 | } | ||||
131 | | ||||
132 | } | ||||
133 | } | ||||
134 | | ||||
135 | } | ||||
136 | | ||||
137 | Item { | ||||
138 | Layout.fillHeight: true | ||||
139 | } | ||||
140 | | ||||
141 | RowLayout { | ||||
142 | Item { | ||||
143 | Layout.fillWidth: true | ||||
144 | } | ||||
145 | | ||||
146 | QtControls.Button { | ||||
147 | icon.name: "document-import" | ||||
148 | text: i18n("Install from File...") | ||||
149 | onClicked: fileDialogLoader.active = true | ||||
150 | } | ||||
151 | | ||||
152 | QtControls.Button { | ||||
153 | icon.name: "get-hot-new-stuff" | ||||
154 | text: i18n("Get New GNOME/GTK Application Styles...") | ||||
155 | onClicked: ghnsMenu.open() | ||||
156 | | ||||
157 | QtControls.Menu { | ||||
158 | id: ghnsMenu | ||||
159 | | ||||
160 | QtControls.MenuItem { | ||||
161 | icon.name: "get-hot-new-stuff" | ||||
162 | text: i18n("Get New GNOME/GTK2 Application Styles...") | ||||
163 | onClicked: function() { | ||||
164 | ghnsMenu.close() | ||||
165 | kcm.gtkPage.installGtk2ThemeFromGHNS() | ||||
166 | } | ||||
167 | } | ||||
168 | QtControls.MenuItem { | ||||
169 | icon.name: "get-hot-new-stuff" | ||||
170 | text: i18n("Get New GNOME/GTK3 Application Styles...") | ||||
171 | onClicked: function() { | ||||
172 | ghnsMenu.close() | ||||
173 | kcm.gtkPage.installGtk3ThemeFromGHNS() | ||||
174 | } | ||||
175 | } | ||||
176 | } | ||||
177 | } | ||||
178 | } | ||||
179 | } | ||||
180 | | ||||
181 | Loader { | ||||
182 | id: fileDialogLoader | ||||
183 | active: false | ||||
184 | sourceComponent: QtDialogs.FileDialog { | ||||
185 | title: i18n("Select GTK Theme Archive") | ||||
186 | folder: shortcuts.home | ||||
187 | nameFilters: [ i18n("GTK Theme Archive (*.tar.xz *.tar.gz *.tar.bz2)") ] | ||||
188 | Component.onCompleted: open() | ||||
189 | onAccepted: { | ||||
190 | kcm.gtkPage.installGtkThemeFromFile(fileUrls[0]) | ||||
191 | fileDialogLoader.active = false | ||||
192 | } | ||||
193 | onRejected: { | ||||
194 | fileDialogLoader.active = false | ||||
195 | } | ||||
196 | } | ||||
197 | } | ||||
198 | } |