Changeset View
Changeset View
Standalone View
Standalone View
containments/desktop/package/contents/ui/ConfigLocation.qml
Show All 11 Lines | |||||
12 | * GNU General Public License for more details. * | 12 | * GNU General Public License for more details. * | ||
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 * | 15 | * along with this program; if not, write to the * | ||
16 | * Free Software Foundation, Inc., * | 16 | * Free Software Foundation, Inc., * | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * | ||
18 | ***************************************************************************/ | 18 | ***************************************************************************/ | ||
19 | 19 | | |||
20 | import QtQuick 2.0 | 20 | import QtQuick 2.5 | ||
21 | import QtQuick.Controls 1.0 | 21 | import QtQuick.Controls 2.5 | ||
22 | import QtQuick.Layouts 1.0 | 22 | import QtQuick.Layouts 1.0 | ||
23 | 23 | | |||
24 | import org.kde.plasma.plasmoid 2.0 | 24 | import org.kde.plasma.plasmoid 2.0 | ||
25 | import org.kde.kirigami 2.4 as Kirigami | 25 | import org.kde.kirigami 2.5 as Kirigami | ||
26 | 26 | | |||
27 | import org.kde.private.desktopcontainment.folder 0.1 as Folder | 27 | import org.kde.private.desktopcontainment.folder 0.1 as Folder | ||
28 | 28 | | |||
29 | Item { | 29 | Item { | ||
30 | id: configLocation | 30 | id: configLocation | ||
31 | 31 | | |||
32 | width: childrenRect.width | 32 | width: childrenRect.width | ||
33 | height: childrenRect.height | 33 | height: childrenRect.height | ||
34 | 34 | | |||
35 | property string cfg_url | 35 | property string cfg_url | ||
36 | property alias cfg_labelMode: labelMode.currentIndex | 36 | property alias cfg_labelMode: labelMode.currentIndex | ||
37 | property alias cfg_labelText: labelText.text | 37 | property alias cfg_labelText: labelText.text | ||
38 | property bool titleVisible: !("containmentType" in plasmoid) | 38 | property bool titleVisible: !("containmentType" in plasmoid) | ||
39 | 39 | | |||
40 | onCfg_urlChanged: applyConfig() | 40 | onCfg_urlChanged: applyConfig() | ||
41 | 41 | | |||
42 | function applyConfig(force) { | 42 | function applyConfig(force) { | ||
43 | if (!force && locationGroup.current != null) { | 43 | if (!force && locationGroup.checkedButton != null) { | ||
44 | return; | 44 | return; | ||
45 | } | 45 | } | ||
46 | 46 | | |||
47 | if (cfg_url == "desktop:/") { | 47 | if (cfg_url == "desktop:/") { | ||
48 | locationDesktop.checked = true; | 48 | locationDesktop.checked = true; | ||
49 | locationCustomValue.text = ""; | 49 | locationCustomValue.text = ""; | ||
50 | } else if (cfg_url == "activities:/current/") { | 50 | } else if (cfg_url == "activities:/current/") { | ||
51 | locationCurrentActivity.checked = true; | 51 | locationCurrentActivity.checked = true; | ||
Show All 16 Lines | |||||
68 | 68 | | |||
69 | Folder.PlacesModel { | 69 | Folder.PlacesModel { | ||
70 | id: placesModel | 70 | id: placesModel | ||
71 | showDesktopEntry: false | 71 | showDesktopEntry: false | ||
72 | 72 | | |||
73 | onPlacesChanged: applyConfig(true) | 73 | onPlacesChanged: applyConfig(true) | ||
74 | } | 74 | } | ||
75 | 75 | | |||
76 | ExclusiveGroup { | 76 | ButtonGroup { | ||
77 | id: locationGroup | 77 | id: locationGroup | ||
78 | 78 | | |||
79 | onCurrentChanged: { | 79 | buttons: [locationDesktop, locationCurrentActivity, locationPlace, locationCustom] | ||
80 | if (current == locationDesktop) { | 80 | | ||
81 | onCheckedButtonChanged: { | ||||
82 | if (checkedButton == locationDesktop) { | ||||
81 | cfg_url = "desktop:/"; | 83 | cfg_url = "desktop:/"; | ||
82 | } else if (current == locationCurrentActivity) { | 84 | } else if (checkedButton == locationCurrentActivity) { | ||
83 | cfg_url = "activities:/current/"; | 85 | cfg_url = "activities:/current/"; | ||
84 | } | 86 | } | ||
85 | } | 87 | } | ||
86 | } | 88 | } | ||
87 | 89 | | |||
88 | Kirigami.FormLayout { | 90 | Kirigami.FormLayout { | ||
89 | anchors.horizontalCenter: parent.horizontalCenter | 91 | anchors.horizontalCenter: parent.horizontalCenter | ||
90 | 92 | | |||
91 | RadioButton { | 93 | RadioButton { | ||
92 | id: locationDesktop | 94 | id: locationDesktop | ||
93 | 95 | | |||
94 | Kirigami.FormData.label: i18n("Show:") | 96 | Kirigami.FormData.label: i18n("Show:") | ||
95 | 97 | | |||
96 | text: i18n("Desktop folder") | 98 | text: i18n("Desktop folder") | ||
97 | exclusiveGroup: locationGroup | | |||
98 | } | 99 | } | ||
99 | 100 | | |||
100 | RadioButton { | 101 | RadioButton { | ||
101 | id: locationCurrentActivity | 102 | id: locationCurrentActivity | ||
102 | visible: placesModel.activityLinkingEnabled | 103 | visible: placesModel.activityLinkingEnabled | ||
103 | 104 | | |||
104 | text: i18n("Files linked to the current activity") | 105 | text: i18n("Files linked to the current activity") | ||
105 | exclusiveGroup: locationGroup | | |||
106 | } | 106 | } | ||
107 | 107 | | |||
108 | RowLayout { | ||||
108 | RadioButton { | 109 | RadioButton { | ||
109 | id: locationPlace | 110 | id: locationPlace | ||
110 | 111 | | |||
111 | text: i18n("Places panel item:") | 112 | text: i18n("Places panel item:") | ||
112 | 113 | | |||
113 | exclusiveGroup: locationGroup | | |||
114 | | ||||
115 | onCheckedChanged: { | 114 | onCheckedChanged: { | ||
116 | locationPlaceValue.enabled = checked; | 115 | locationPlaceValue.enabled = checked; | ||
117 | } | 116 | } | ||
118 | } | 117 | } | ||
119 | RowLayout { | | |||
120 | Layout.fillWidth: true | | |||
121 | 118 | | |||
122 | Item { | | |||
123 | width: units.largeSpacing | | |||
124 | } | | |||
125 | ComboBox { | 119 | ComboBox { | ||
126 | id: locationPlaceValue | 120 | id: locationPlaceValue | ||
127 | 121 | | |||
128 | Layout.fillWidth: true | 122 | Layout.fillWidth: true | ||
129 | 123 | | |||
130 | model: placesModel | 124 | model: placesModel | ||
131 | textRole: "display" | 125 | textRole: "display" | ||
132 | 126 | | |||
133 | enabled: true | 127 | enabled: true | ||
134 | 128 | | |||
135 | onEnabledChanged: { | 129 | onEnabledChanged: { | ||
136 | if (enabled && currentIndex != -1) { | 130 | if (enabled && currentIndex != -1) { | ||
137 | cfg_url = placesModel.urlForIndex(currentIndex); | 131 | cfg_url = placesModel.urlForIndex(currentIndex); | ||
138 | } | 132 | } | ||
139 | } | 133 | } | ||
140 | 134 | | |||
141 | onActivated: { | 135 | onActivated: { | ||
142 | cfg_url = placesModel.urlForIndex(index); | 136 | cfg_url = placesModel.urlForIndex(index); | ||
143 | } | 137 | } | ||
144 | } | 138 | } | ||
145 | } | 139 | } | ||
146 | 140 | | |||
141 | RowLayout { | ||||
147 | RadioButton { | 142 | RadioButton { | ||
148 | id: locationCustom | 143 | id: locationCustom | ||
149 | 144 | | |||
150 | exclusiveGroup: locationGroup | | |||
151 | text: i18n("Custom location:") | 145 | text: i18n("Custom location:") | ||
152 | } | 146 | } | ||
153 | 147 | | |||
154 | RowLayout { | | |||
155 | Layout.fillWidth: true | | |||
156 | Item { | | |||
157 | width: units.largeSpacing | | |||
158 | } | | |||
159 | TextField { | 148 | TextField { | ||
160 | id: locationCustomValue | 149 | id: locationCustomValue | ||
161 | enabled: locationCustom.checked | 150 | enabled: locationCustom.checked | ||
162 | Layout.fillWidth: true | 151 | Layout.fillWidth: true | ||
163 | 152 | | |||
164 | placeholderText: i18n("Type a path or a URL here") | 153 | placeholderText: i18n("Type path or URL...") | ||
165 | 154 | | |||
166 | onEnabledChanged: { | 155 | onEnabledChanged: { | ||
167 | if (enabled && text != "") { | 156 | if (enabled && text != "") { | ||
168 | cfg_url = text; | 157 | cfg_url = text; | ||
169 | } | 158 | } | ||
170 | } | 159 | } | ||
171 | 160 | | |||
172 | onTextChanged: { | 161 | onTextChanged: { | ||
173 | if (enabled) { | 162 | if (enabled) { | ||
174 | cfg_url = text; | 163 | cfg_url = text; | ||
175 | } | 164 | } | ||
176 | } | 165 | } | ||
177 | } | 166 | } | ||
178 | Button { | 167 | Button { | ||
179 | iconName: "document-open" | 168 | icon.name: "document-open" | ||
180 | 169 | | |||
181 | enabled: locationCustom.checked | 170 | enabled: locationCustom.checked | ||
182 | 171 | | |||
183 | onClicked: { | 172 | onClicked: { | ||
184 | directoryPicker.open(); | 173 | directoryPicker.open(); | ||
185 | } | 174 | } | ||
186 | } | 175 | } | ||
187 | Folder.DirectoryPicker { | 176 | Folder.DirectoryPicker { | ||
188 | id: directoryPicker | 177 | id: directoryPicker | ||
189 | 178 | | |||
190 | onUrlChanged: { | 179 | onUrlChanged: { | ||
191 | locationCustomValue.text = url; | 180 | locationCustomValue.text = url; | ||
192 | } | 181 | } | ||
193 | } | 182 | } | ||
194 | } | 183 | } | ||
195 | 184 | | |||
196 | Item { | 185 | Item { | ||
197 | visible: titleVisible | 186 | visible: titleVisible | ||
198 | Kirigami.FormData.isSection: true | 187 | Kirigami.FormData.isSection: true | ||
199 | } | 188 | } | ||
200 | 189 | | |||
201 | ComboBox { | 190 | ComboBox { | ||
202 | id: labelMode | 191 | id: labelMode | ||
203 | visible: titleVisible | 192 | visible: titleVisible | ||
204 | Layout.fillWidth: true | | |||
205 | 193 | | |||
206 | Kirigami.FormData.label: i18n("Title:") | 194 | Kirigami.FormData.label: i18n("Title:") | ||
207 | 195 | | |||
208 | model: [i18n("None"), i18n("Default"), i18n("Full path"), i18n("Custom title")] | 196 | model: [i18n("None"), i18n("Default"), i18n("Full path"), i18n("Custom title")] | ||
209 | } | 197 | } | ||
210 | 198 | | |||
211 | RowLayout { | 199 | RowLayout { | ||
212 | Layout.fillWidth: true | | |||
213 | visible: titleVisible | 200 | visible: titleVisible | ||
214 | 201 | | |||
215 | Item { | 202 | Item { | ||
filipf: Personally I don't think we need this indent as the enabled property already gives a clue what… | |||||
This is the correct way and like this in other places such as the Fonts KCM too. GB_2: This is the correct way and like this in other places such as the Fonts KCM too. | |||||
216 | width: units.largeSpacing | 203 | width: units.largeSpacing | ||
217 | } | 204 | } | ||
205 | | ||||
218 | TextField { | 206 | TextField { | ||
219 | id: labelText | 207 | id: labelText | ||
220 | Layout.fillWidth: true | 208 | Layout.fillWidth: true | ||
221 | enabled: (labelMode.currentIndex == 3) | 209 | enabled: (labelMode.currentIndex == 3) | ||
222 | 210 | | |||
223 | placeholderText: i18n("Enter custom title here") | 211 | placeholderText: i18n("Enter custom title...") | ||
224 | } | 212 | } | ||
225 | } | 213 | } | ||
226 | } | 214 | } | ||
227 | } | 215 | } |
Personally I don't think we need this indent as the enabled property already gives a clue what the text field is related to, but it's not particularly important one way or another.