Differential D17211 Diff 46398 desktoppackage/contents/configuration/ConfigurationContainmentAppearance.qml
Changeset View
Changeset View
Standalone View
Standalone View
desktoppackage/contents/configuration/ConfigurationContainmentAppearance.qml
Show All 12 Lines | |||||
13 | * | 13 | * | ||
14 | * You should have received a copy of the GNU General Public License | 14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | 15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. | 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. | ||
17 | */ | 17 | */ | ||
18 | 18 | | |||
19 | import QtQuick 2.0 | 19 | import QtQuick 2.0 | ||
20 | import org.kde.plasma.configuration 2.0 | 20 | import org.kde.plasma.configuration 2.0 | ||
21 | import QtQuick.Controls 1.0 as QtControls | 21 | import QtQuick.Controls 2.3 as QtControls | ||
22 | import QtQuick.Layouts 1.1 | 22 | import QtQuick.Layouts 1.1 | ||
23 | 23 | | |||
24 | import org.kde.kconfig 1.0 // for KAuthorized | 24 | import org.kde.kconfig 1.0 // for KAuthorized | ||
25 | import org.kde.plasma.private.shell 2.0 as ShellPrivate // for WallpaperPlugin | 25 | import org.kde.plasma.private.shell 2.0 as ShellPrivate // for WallpaperPlugin | ||
26 | import org.kde.kirigami 2.5 as Kirigami | ||||
26 | 27 | | |||
27 | ColumnLayout { | 28 | ColumnLayout { | ||
28 | id: root | 29 | id: root | ||
29 | 30 | | |||
30 | property int formAlignment: wallpaperComboBox.x + (units.largeSpacing/2) | 31 | property int formAlignment: wallpaperComboBox.Kirigami.ScenePosition.x - root.Kirigami.ScenePosition.x + (units.largeSpacing/2) | ||
31 | property string currentWallpaper: "" | 32 | property string currentWallpaper: "" | ||
32 | property string containmentPlugin: "" | 33 | property string containmentPlugin: "" | ||
33 | signal configurationChanged | 34 | signal configurationChanged | ||
34 | 35 | | |||
35 | //BEGIN functions | 36 | //BEGIN functions | ||
36 | function saveConfig() { | 37 | function saveConfig() { | ||
37 | if (main.currentItem.saveConfig) { | 38 | if (main.currentItem.saveConfig) { | ||
38 | main.currentItem.saveConfig() | 39 | main.currentItem.saveConfig() | ||
Show All 9 Lines | |||||
48 | } | 49 | } | ||
49 | //END functions | 50 | //END functions | ||
50 | 51 | | |||
51 | Component.onCompleted: { | 52 | Component.onCompleted: { | ||
52 | for (var i = 0; i < configDialog.containmentPluginsConfigModel.count; ++i) { | 53 | for (var i = 0; i < configDialog.containmentPluginsConfigModel.count; ++i) { | ||
53 | var data = configDialog.containmentPluginsConfigModel.get(i); | 54 | var data = configDialog.containmentPluginsConfigModel.get(i); | ||
54 | if (configDialog.containmentPlugin == data.pluginName) { | 55 | if (configDialog.containmentPlugin == data.pluginName) { | ||
55 | pluginComboBox.currentIndex = i | 56 | pluginComboBox.currentIndex = i | ||
57 | pluginComboBox.activated(i); | ||||
56 | break; | 58 | break; | ||
57 | } | 59 | } | ||
58 | } | 60 | } | ||
59 | 61 | | |||
60 | for (var i = 0; i < configDialog.wallpaperConfigModel.count; ++i) { | 62 | for (var i = 0; i < configDialog.wallpaperConfigModel.count; ++i) { | ||
61 | var data = configDialog.wallpaperConfigModel.get(i); | 63 | var data = configDialog.wallpaperConfigModel.get(i); | ||
62 | if (configDialog.currentWallpaper == data.pluginName) { | 64 | if (configDialog.currentWallpaper == data.pluginName) { | ||
63 | wallpaperComboBox.currentIndex = i | 65 | wallpaperComboBox.currentIndex = i | ||
66 | wallpaperComboBox.activated(i); | ||||
64 | break; | 67 | break; | ||
65 | } | 68 | } | ||
66 | } | 69 | } | ||
67 | } | 70 | } | ||
68 | 71 | | |||
69 | Row { | 72 | Kirigami.InlineMessage { | ||
70 | spacing: units.largeSpacing / 2 | 73 | visible: plasmoid.immutable || animating | ||
71 | visible: pluginComboBox.count > 1 | 74 | text: i18nd("plasma_shell_org.kde.plasma.desktop", "Layout cannot be changed while widgets are locked") | ||
72 | QtControls.Label { | 75 | showCloseButton: true | ||
73 | width: formAlignment - units.largeSpacing | 76 | Layout.fillWidth: true | ||
74 | anchors.verticalCenter: pluginComboBox.verticalCenter | 77 | Layout.leftMargin: Kirigami.Units.smallSpacing | ||
75 | text: i18nd("plasma_shell_org.kde.plasma.desktop", "Layout:") | 78 | Layout.rightMargin: Kirigami.Units.smallSpacing | ||
76 | horizontalAlignment: Text.AlignRight | | |||
77 | } | 79 | } | ||
80 | | ||||
81 | Kirigami.FormLayout { | ||||
82 | Layout.fillWidth: true | ||||
78 | QtControls.ComboBox { | 83 | QtControls.ComboBox { | ||
79 | id: pluginComboBox | 84 | id: pluginComboBox | ||
85 | Layout.preferredWidth: Math.max(implicitWidth, wallpaperComboBox.implicitWidth) | ||||
86 | Kirigami.FormData.label: i18nd("plasma_shell_org.kde.plasma.desktop", "Layout:") | ||||
80 | enabled: !plasmoid.immutable | 87 | enabled: !plasmoid.immutable | ||
81 | model: configDialog.containmentPluginsConfigModel | 88 | model: configDialog.containmentPluginsConfigModel | ||
82 | width: theme.mSize(theme.defaultFont).width * 24 | 89 | width: theme.mSize(theme.defaultFont).width * 24 | ||
83 | textRole: "name" | 90 | textRole: "name" | ||
84 | onCurrentIndexChanged: { | 91 | onActivated: { | ||
85 | var model = configDialog.containmentPluginsConfigModel.get(currentIndex) | 92 | var model = configDialog.containmentPluginsConfigModel.get(currentIndex) | ||
86 | root.containmentPlugin = model.pluginName | 93 | root.containmentPlugin = model.pluginName | ||
87 | root.configurationChanged() | 94 | root.configurationChanged() | ||
88 | } | 95 | } | ||
89 | } | 96 | } | ||
97 | | ||||
98 | RowLayout { | ||||
99 | Layout.fillWidth: true | ||||
100 | visible: !switchContainmentWarning.visible | ||||
101 | Kirigami.FormData.label: i18nd("plasma_shell_org.kde.plasma.desktop", "Wallpaper Type:") | ||||
102 | QtControls.ComboBox { | ||||
103 | id: wallpaperComboBox | ||||
104 | Layout.preferredWidth: Math.max(implicitWidth, pluginComboBox.implicitWidth) | ||||
105 | model: configDialog.wallpaperConfigModel | ||||
106 | width: theme.mSize(theme.defaultFont).width * 24 | ||||
107 | textRole: "name" | ||||
108 | onActivated: { | ||||
109 | var model = configDialog.wallpaperConfigModel.get(currentIndex) | ||||
110 | root.currentWallpaper = model.pluginName | ||||
111 | configDialog.currentWallpaper = model.pluginName | ||||
112 | main.sourceFile = model.source | ||||
113 | root.configurationChanged() | ||||
114 | } | ||||
115 | } | ||||
116 | QtControls.Button { | ||||
117 | icon.name: "get-hot-new-stuff" | ||||
118 | QtControls.ToolTip { | ||||
119 | text: i18nd("plasma_shell_org.kde.plasma.desktop", "Get New Wallpaper Plugins...") | ||||
120 | } | ||||
121 | visible: KAuthorized.authorize("ghns") | ||||
122 | onClicked: wallpaperPlugin.getNewWallpaperPlugin(this) | ||||
123 | Layout.preferredHeight: wallpaperComboBox.height | ||||
124 | | ||||
125 | ShellPrivate.WallpaperPlugin { | ||||
126 | id: wallpaperPlugin | ||||
127 | } | ||||
128 | } | ||||
129 | } | ||||
90 | } | 130 | } | ||
91 | 131 | | |||
92 | ColumnLayout { | 132 | ColumnLayout { | ||
93 | id: switchContainmentWarning | 133 | id: switchContainmentWarning | ||
94 | Layout.fillWidth: true | 134 | Layout.fillWidth: true | ||
95 | visible: configDialog.containmentPlugin != root.containmentPlugin | 135 | visible: configDialog.containmentPlugin != root.containmentPlugin | ||
96 | QtControls.Label { | 136 | QtControls.Label { | ||
97 | Layout.fillWidth: true | 137 | Layout.fillWidth: true | ||
98 | text: i18nd("plasma_shell_org.kde.plasma.desktop", "Layout changes must be applied before other changes can be made") | 138 | text: i18nd("plasma_shell_org.kde.plasma.desktop", "Layout changes must be applied before other changes can be made") | ||
99 | wrapMode: Text.Wrap | 139 | wrapMode: Text.Wrap | ||
100 | horizontalAlignment: Text.AlignHCenter | 140 | horizontalAlignment: Text.AlignHCenter | ||
101 | } | 141 | } | ||
102 | QtControls.Button { | 142 | QtControls.Button { | ||
103 | Layout.alignment: Qt.AlignHCenter | 143 | Layout.alignment: Qt.AlignHCenter | ||
104 | text: i18nd("plasma_shell_org.kde.plasma.desktop", "Apply now") | 144 | text: i18nd("plasma_shell_org.kde.plasma.desktop", "Apply now") | ||
105 | onClicked: saveConfig() | 145 | onClicked: saveConfig() | ||
106 | } | 146 | } | ||
107 | 147 | | |||
108 | Binding { | 148 | Binding { | ||
109 | target: categoriesScroll //from parent scope AppletConfiguration | 149 | target: categoriesScroll //from parent scope AppletConfiguration | ||
110 | property: "enabled" | 150 | property: "enabled" | ||
111 | value: !switchContainmentWarning.visible | 151 | value: !switchContainmentWarning.visible | ||
112 | } | 152 | } | ||
113 | Item { | | |||
114 | Layout.fillHeight: true | | |||
115 | } | | |||
116 | } | | |||
117 | | ||||
118 | QtControls.Label { | | |||
119 | Layout.fillWidth: true | | |||
120 | | ||||
121 | visible: plasmoid.immutable | | |||
122 | | ||||
123 | text: i18nd("plasma_shell_org.kde.plasma.desktop", "Layout cannot be changed while widgets are locked") | | |||
124 | wrapMode: Text.Wrap | | |||
125 | } | 153 | } | ||
126 | 154 | | |||
127 | Row { | | |||
128 | visible: !switchContainmentWarning.visible | | |||
129 | id: wallpaperRow | | |||
130 | spacing: units.largeSpacing / 2 | | |||
131 | Item { | 155 | Item { | ||
132 | width: units.largeSpacing | 156 | Layout.fillHeight: true | ||
133 | height: parent.height | 157 | visible: switchContainmentWarning.visible | ||
134 | } | | |||
135 | QtControls.Label { | | |||
136 | anchors.verticalCenter: wallpaperComboBox.verticalCenter | | |||
137 | text: i18nd("plasma_shell_org.kde.plasma.desktop", "Wallpaper Type:") | | |||
138 | } | | |||
139 | QtControls.ComboBox { | | |||
140 | id: wallpaperComboBox | | |||
141 | model: configDialog.wallpaperConfigModel | | |||
142 | width: theme.mSize(theme.defaultFont).width * 24 | | |||
143 | textRole: "name" | | |||
144 | onCurrentIndexChanged: { | | |||
145 | var model = configDialog.wallpaperConfigModel.get(currentIndex) | | |||
146 | root.currentWallpaper = model.pluginName | | |||
147 | configDialog.currentWallpaper = model.pluginName | | |||
148 | main.sourceFile = model.source | | |||
149 | root.configurationChanged() | | |||
150 | } | | |||
151 | } | | |||
152 | QtControls.Button { | | |||
153 | iconName: "get-hot-new-stuff" | | |||
154 | text: i18nd("plasma_shell_org.kde.plasma.desktop", "Get New Wallpaper Plugins...") | | |||
155 | visible: KAuthorized.authorize("ghns") | | |||
156 | onClicked: wallpaperPlugin.getNewWallpaperPlugin(this) | | |||
157 | | ||||
158 | ShellPrivate.WallpaperPlugin { | | |||
159 | id: wallpaperPlugin | | |||
160 | } | | |||
161 | } | | |||
162 | } | 158 | } | ||
163 | 159 | | |||
164 | Item { | 160 | Item { | ||
165 | id: emptyConfig | 161 | id: emptyConfig | ||
166 | } | 162 | } | ||
167 | 163 | | |||
168 | QtControls.StackView { | 164 | QtControls.StackView { | ||
169 | id: main | 165 | id: main | ||
170 | 166 | | |||
171 | Layout.fillHeight: true; | 167 | Layout.fillHeight: true; | ||
172 | anchors { | 168 | Layout.fillWidth: true; | ||
173 | left: parent.left; | 169 | | ||
174 | right: parent.right; | | |||
175 | } | | |||
176 | visible: !switchContainmentWarning.visible | 170 | visible: !switchContainmentWarning.visible | ||
177 | 171 | | |||
178 | // Bug 360862: if wallpaper has no config, sourceFile will be "" | 172 | // Bug 360862: if wallpaper has no config, sourceFile will be "" | ||
179 | // so we wouldn't load emptyConfig and break all over the place | 173 | // so we wouldn't load emptyConfig and break all over the place | ||
180 | // hence set it to some random value initially | 174 | // hence set it to some random value initially | ||
181 | property string sourceFile: "tbd" | 175 | property string sourceFile: "tbd" | ||
182 | onSourceFileChanged: { | 176 | onSourceFileChanged: { | ||
183 | if (sourceFile) { | 177 | if (sourceFile) { | ||
184 | var props = {} | 178 | var props = {} | ||
185 | 179 | | |||
186 | var wallpaperConfig = configDialog.wallpaperConfiguration | 180 | var wallpaperConfig = configDialog.wallpaperConfiguration | ||
187 | for (var key in wallpaperConfig) { | 181 | for (var key in wallpaperConfig) { | ||
188 | props["cfg_" + key] = wallpaperConfig[key] | 182 | props["cfg_" + key] = wallpaperConfig[key] | ||
189 | } | 183 | } | ||
190 | 184 | | |||
191 | var newItem = push({ | 185 | var newItem = replace(Qt.resolvedUrl(sourceFile), props) | ||
192 | item: Qt.resolvedUrl(sourceFile), | | |||
193 | replace: true, | | |||
194 | properties: props | | |||
195 | }) | | |||
196 | 186 | | |||
197 | for (var key in wallpaperConfig) { | 187 | for (var key in wallpaperConfig) { | ||
198 | var changedSignal = newItem["cfg_" + key + "Changed"] | 188 | var changedSignal = newItem["cfg_" + key + "Changed"] | ||
199 | if (changedSignal) { | 189 | if (changedSignal) { | ||
200 | changedSignal.connect(root.configurationChanged) | 190 | changedSignal.connect(root.configurationChanged) | ||
201 | } | 191 | } | ||
202 | } | 192 | } | ||
203 | } else { | 193 | } else { | ||
204 | replace(emptyConfig) | 194 | replace(emptyConfig) | ||
205 | } | 195 | } | ||
206 | } | 196 | } | ||
207 | } | 197 | } | ||
208 | } | 198 | } |