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 | | |||
33 | height: childrenRect.height | | |||
34 | | ||||
35 | property string cfg_url | 32 | property string cfg_url | ||
36 | property alias cfg_labelMode: labelMode.currentIndex | 33 | property alias cfg_labelMode: labelMode.currentIndex | ||
37 | property alias cfg_labelText: labelText.text | 34 | property alias cfg_labelText: labelText.text | ||
38 | property bool titleVisible: !("containmentType" in plasmoid) | 35 | property bool titleVisible: !("containmentType" in plasmoid) | ||
39 | 36 | | |||
40 | onCfg_urlChanged: applyConfig() | 37 | onCfg_urlChanged: applyConfig() | ||
41 | 38 | | |||
42 | function applyConfig(force) { | 39 | function applyConfig(force) { | ||
43 | if (!force && locationGroup.current != null) { | 40 | if (!force && locationGroup.checkedButton != null) { | ||
44 | return; | 41 | return; | ||
45 | } | 42 | } | ||
46 | 43 | | |||
47 | if (cfg_url == "desktop:/") { | 44 | if (cfg_url == "desktop:/") { | ||
48 | locationDesktop.checked = true; | 45 | locationDesktop.checked = true; | ||
49 | locationCustomValue.text = ""; | 46 | locationCustomValue.text = ""; | ||
50 | } else if (cfg_url == "activities:/current/") { | 47 | } else if (cfg_url == "activities:/current/") { | ||
51 | locationCurrentActivity.checked = true; | 48 | locationCurrentActivity.checked = true; | ||
Show All 16 Lines | |||||
68 | 65 | | |||
69 | Folder.PlacesModel { | 66 | Folder.PlacesModel { | ||
70 | id: placesModel | 67 | id: placesModel | ||
71 | showDesktopEntry: false | 68 | showDesktopEntry: false | ||
72 | 69 | | |||
73 | onPlacesChanged: applyConfig(true) | 70 | onPlacesChanged: applyConfig(true) | ||
74 | } | 71 | } | ||
75 | 72 | | |||
76 | ExclusiveGroup { | 73 | ButtonGroup { | ||
77 | id: locationGroup | 74 | id: locationGroup | ||
78 | 75 | | |||
79 | onCurrentChanged: { | 76 | buttons: [locationDesktop, locationCurrentActivity, locationPlace, locationCustom] | ||
80 | if (current == locationDesktop) { | 77 | | ||
78 | onCheckedButtonChanged: { | ||||
79 | if (checkedButton == locationDesktop) { | ||||
81 | cfg_url = "desktop:/"; | 80 | cfg_url = "desktop:/"; | ||
82 | } else if (current == locationCurrentActivity) { | 81 | } else if (checkedButton == locationCurrentActivity) { | ||
83 | cfg_url = "activities:/current/"; | 82 | cfg_url = "activities:/current/"; | ||
84 | } | 83 | } | ||
85 | } | 84 | } | ||
86 | } | 85 | } | ||
87 | 86 | | |||
88 | Kirigami.FormLayout { | 87 | Kirigami.FormLayout { | ||
89 | anchors.horizontalCenter: parent.horizontalCenter | 88 | anchors.horizontalCenter: parent.horizontalCenter | ||
90 | 89 | | |||
91 | RadioButton { | 90 | RadioButton { | ||
92 | id: locationDesktop | 91 | id: locationDesktop | ||
93 | 92 | | |||
94 | Kirigami.FormData.label: i18n("Show:") | 93 | Kirigami.FormData.label: i18n("Show:") | ||
95 | 94 | | |||
96 | text: i18n("Desktop folder") | 95 | text: i18n("Desktop folder") | ||
97 | exclusiveGroup: locationGroup | | |||
98 | } | 96 | } | ||
99 | 97 | | |||
100 | RadioButton { | 98 | RadioButton { | ||
101 | id: locationCurrentActivity | 99 | id: locationCurrentActivity | ||
102 | visible: placesModel.activityLinkingEnabled | 100 | visible: placesModel.activityLinkingEnabled | ||
103 | 101 | | |||
104 | text: i18n("Files linked to the current activity") | 102 | text: i18n("Files linked to the current activity") | ||
105 | exclusiveGroup: locationGroup | | |||
106 | } | 103 | } | ||
107 | 104 | | |||
105 | RowLayout { | ||||
108 | RadioButton { | 106 | RadioButton { | ||
109 | id: locationPlace | 107 | id: locationPlace | ||
110 | 108 | | |||
111 | text: i18n("Places panel item:") | 109 | text: i18n("Places panel item:") | ||
112 | 110 | | |||
113 | exclusiveGroup: locationGroup | | |||
114 | | ||||
115 | onCheckedChanged: { | 111 | onCheckedChanged: { | ||
116 | locationPlaceValue.enabled = checked; | 112 | locationPlaceValue.enabled = checked; | ||
117 | } | 113 | } | ||
118 | } | 114 | } | ||
119 | RowLayout { | | |||
120 | Layout.fillWidth: true | | |||
121 | 115 | | |||
122 | Item { | | |||
123 | width: units.largeSpacing | | |||
124 | } | | |||
125 | ComboBox { | 116 | ComboBox { | ||
126 | id: locationPlaceValue | 117 | id: locationPlaceValue | ||
127 | 118 | | |||
128 | Layout.fillWidth: true | 119 | Layout.fillWidth: true | ||
129 | 120 | | |||
130 | model: placesModel | 121 | model: placesModel | ||
131 | textRole: "display" | 122 | textRole: "display" | ||
132 | 123 | | |||
133 | enabled: true | 124 | enabled: true | ||
134 | 125 | | |||
135 | onEnabledChanged: { | 126 | onEnabledChanged: { | ||
136 | if (enabled && currentIndex != -1) { | 127 | if (enabled && currentIndex != -1) { | ||
137 | cfg_url = placesModel.urlForIndex(currentIndex); | 128 | cfg_url = placesModel.urlForIndex(currentIndex); | ||
138 | } | 129 | } | ||
139 | } | 130 | } | ||
140 | 131 | | |||
141 | onActivated: { | 132 | onActivated: { | ||
142 | cfg_url = placesModel.urlForIndex(index); | 133 | cfg_url = placesModel.urlForIndex(index); | ||
143 | } | 134 | } | ||
144 | } | 135 | } | ||
145 | } | 136 | } | ||
146 | 137 | | |||
138 | RowLayout { | ||||
147 | RadioButton { | 139 | RadioButton { | ||
148 | id: locationCustom | 140 | id: locationCustom | ||
149 | 141 | | |||
150 | exclusiveGroup: locationGroup | | |||
151 | text: i18n("Custom location:") | 142 | text: i18n("Custom location:") | ||
152 | } | 143 | } | ||
153 | 144 | | |||
154 | RowLayout { | | |||
155 | Layout.fillWidth: true | | |||
156 | Item { | | |||
157 | width: units.largeSpacing | | |||
158 | } | | |||
159 | TextField { | 145 | TextField { | ||
160 | id: locationCustomValue | 146 | id: locationCustomValue | ||
161 | enabled: locationCustom.checked | 147 | enabled: locationCustom.checked | ||
162 | Layout.fillWidth: true | 148 | Layout.fillWidth: true | ||
163 | 149 | | |||
164 | placeholderText: i18n("Type a path or a URL here") | 150 | placeholderText: i18n("Type path or URL...") | ||
165 | 151 | | |||
166 | onEnabledChanged: { | 152 | onEnabledChanged: { | ||
167 | if (enabled && text != "") { | 153 | if (enabled && text != "") { | ||
168 | cfg_url = text; | 154 | cfg_url = text; | ||
169 | } | 155 | } | ||
170 | } | 156 | } | ||
171 | 157 | | |||
172 | onTextChanged: { | 158 | onTextChanged: { | ||
173 | if (enabled) { | 159 | if (enabled) { | ||
174 | cfg_url = text; | 160 | cfg_url = text; | ||
175 | } | 161 | } | ||
176 | } | 162 | } | ||
177 | } | 163 | } | ||
178 | Button { | 164 | Button { | ||
179 | iconName: "document-open" | 165 | icon.name: "document-open" | ||
180 | 166 | | |||
181 | enabled: locationCustom.checked | 167 | enabled: locationCustom.checked | ||
182 | 168 | | |||
183 | onClicked: { | 169 | onClicked: { | ||
184 | directoryPicker.open(); | 170 | directoryPicker.open(); | ||
185 | } | 171 | } | ||
186 | } | 172 | } | ||
187 | Folder.DirectoryPicker { | 173 | Folder.DirectoryPicker { | ||
188 | id: directoryPicker | 174 | id: directoryPicker | ||
189 | 175 | | |||
190 | onUrlChanged: { | 176 | onUrlChanged: { | ||
191 | locationCustomValue.text = url; | 177 | locationCustomValue.text = url; | ||
192 | } | 178 | } | ||
193 | } | 179 | } | ||
194 | } | 180 | } | ||
195 | 181 | | |||
196 | Item { | 182 | Item { | ||
197 | visible: titleVisible | 183 | visible: titleVisible | ||
198 | Kirigami.FormData.isSection: true | 184 | Kirigami.FormData.isSection: true | ||
199 | } | 185 | } | ||
200 | 186 | | |||
201 | ComboBox { | 187 | ComboBox { | ||
202 | id: labelMode | 188 | id: labelMode | ||
203 | visible: titleVisible | 189 | visible: titleVisible | ||
204 | Layout.fillWidth: true | | |||
205 | 190 | | |||
206 | Kirigami.FormData.label: i18n("Title:") | 191 | Kirigami.FormData.label: i18n("Title:") | ||
207 | 192 | | |||
208 | model: [i18n("None"), i18n("Default"), i18n("Full path"), i18n("Custom title")] | 193 | model: [i18n("None"), i18n("Default"), i18n("Full path"), i18n("Custom title")] | ||
209 | } | 194 | } | ||
210 | 195 | | |||
211 | RowLayout { | 196 | RowLayout { | ||
212 | Layout.fillWidth: true | | |||
213 | visible: titleVisible | 197 | visible: titleVisible | ||
214 | 198 | | |||
215 | Item { | 199 | 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 | 200 | width: units.largeSpacing | ||
217 | } | 201 | } | ||
202 | | ||||
218 | TextField { | 203 | TextField { | ||
219 | id: labelText | 204 | id: labelText | ||
220 | Layout.fillWidth: true | 205 | Layout.fillWidth: true | ||
221 | enabled: (labelMode.currentIndex == 3) | 206 | enabled: (labelMode.currentIndex == 3) | ||
222 | 207 | | |||
223 | placeholderText: i18n("Enter custom title here") | 208 | placeholderText: i18n("Enter custom title...") | ||
224 | } | 209 | } | ||
225 | } | 210 | } | ||
226 | } | 211 | } | ||
227 | } | 212 | } |
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.