Changeset View
Changeset View
Standalone View
Standalone View
containments/desktop/package/contents/ui/ConfigFilter.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.Controls 1.0 as QQC1 | ||||
22 | import QtQuick.Layouts 1.0 | 23 | import QtQuick.Layouts 1.0 | ||
23 | 24 | | |||
25 | import org.kde.kirigami 2.5 as Kirigami | ||||
24 | import org.kde.plasma.core 2.0 as PlasmaCore | 26 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
25 | 27 | | |||
26 | import org.kde.private.desktopcontainment.folder 0.1 as Folder | 28 | import org.kde.private.desktopcontainment.folder 0.1 as Folder | ||
27 | 29 | | |||
28 | Item { | 30 | ColumnLayout { | ||
29 | id: configIcons | 31 | id: configIcons | ||
30 | 32 | | |||
31 | width: childrenRect.width | | |||
32 | height: childrenRect.height | | |||
33 | | ||||
34 | property alias cfg_filterMode: filterMode.currentIndex | 33 | property alias cfg_filterMode: filterMode.currentIndex | ||
davidedmundson: These lines are quite wrong to begin with, but resizing childenRect inside a columnLayout now… | |||||
35 | property alias cfg_filterPattern: filterPattern.text | 34 | property alias cfg_filterPattern: filterPattern.text | ||
36 | property alias cfg_filterMimeTypes: mimeTypesModel.checkedTypes | 35 | property alias cfg_filterMimeTypes: mimeTypesModel.checkedTypes | ||
37 | 36 | | |||
38 | PlasmaCore.SortFilterModel { | 37 | PlasmaCore.SortFilterModel { | ||
39 | id: filteredMimeTypesModel | 38 | id: filteredMimeTypesModel | ||
40 | 39 | | |||
41 | sourceModel: Folder.MimeTypesModel { | 40 | sourceModel: Folder.MimeTypesModel { | ||
42 | id: mimeTypesModel | 41 | id: mimeTypesModel | ||
Show All 23 Lines | 62 | function uncheckFiltered() { | |||
66 | for (var i = 0; i < count; ++i) { | 65 | for (var i = 0; i < count; ++i) { | ||
67 | types.push(get(i).name); | 66 | types.push(get(i).name); | ||
68 | } | 67 | } | ||
69 | 68 | | |||
70 | mimeTypesModel.checkedTypes = mimeTypesModel.checkedTypes.filter(function(x) { | 69 | mimeTypesModel.checkedTypes = mimeTypesModel.checkedTypes.filter(function(x) { | ||
71 | return types.indexOf(x) < 0; }); | 70 | return types.indexOf(x) < 0; }); | ||
72 | } | 71 | } | ||
73 | } | 72 | } | ||
74 | 73 | Kirigami.FormLayout { | |||
75 | ColumnLayout { | | |||
76 | width: parent.width | | |||
77 | height: parent.height | | |||
78 | | ||||
79 | ComboBox { | 74 | ComboBox { | ||
80 | id: filterMode | 75 | id: filterMode | ||
81 | 76 | Kirigami.FormData.label: i18n("Files:") | |||
82 | Layout.fillWidth: true | 77 | model: [i18n("Show all"), i18n("Show matching"), i18n("Hide matching")] | ||
83 | | ||||
84 | model: [i18n("Show All Files"), i18n("Show Files Matching"), i18n("Hide Files Matching")] | | |||
85 | } | | |||
86 | | ||||
87 | Label { | | |||
88 | Layout.fillWidth: true | | |||
89 | | ||||
90 | text: i18n("File name pattern:") | | |||
91 | } | 78 | } | ||
92 | 79 | | |||
93 | TextField { | 80 | TextField { | ||
94 | id: filterPattern | 81 | id: filterPattern | ||
95 | 82 | Kirigami.FormData.label: i18n("File name pattern:") | |||
96 | Layout.fillWidth: true | | |||
97 | | ||||
98 | enabled: (filterMode.currentIndex > 0) | 83 | enabled: (filterMode.currentIndex > 0) | ||
99 | } | 84 | } | ||
100 | 85 | | |||
101 | Label { | | |||
102 | Layout.fillWidth: true | | |||
103 | | ||||
104 | text: i18n("File types:") | | |||
105 | } | | |||
106 | | ||||
107 | TextField { | 86 | TextField { | ||
108 | id: mimeFilter | 87 | id: mimeFilter | ||
109 | 88 | Kirigami.FormData.label: i18n("File types:") | |||
110 | Layout.fillWidth: true | | |||
111 | | ||||
112 | enabled: (filterMode.currentIndex > 0) | 89 | enabled: (filterMode.currentIndex > 0) | ||
113 | 90 | placeholderText: i18n("Search...") | |||
114 | placeholderText: i18n("Search file type...") | 91 | } | ||
115 | } | 92 | } | ||
116 | 93 | | |||
117 | RowLayout { | 94 | ColumnLayout { | ||
118 | Layout.fillWidth: true | 95 | Layout.fillWidth: true | ||
119 | Layout.fillHeight: true | 96 | Layout.fillHeight: true | ||
120 | 97 | | |||
121 | CheckBox { // Purely for metrics. | 98 | CheckBox { // Purely for metrics. | ||
122 | id: metricsCheckBox | 99 | id: metricsCheckBox | ||
123 | visible: false | 100 | visible: false | ||
124 | } | 101 | } | ||
125 | 102 | | |||
126 | TableView { | 103 | QQC1.TableView { | ||
127 | id: mimeTypesView | 104 | id: mimeTypesView | ||
128 | 105 | | |||
129 | // Signal the delegates listen to when user presses space to toggle current row. | 106 | // Signal the delegates listen to when user presses space to toggle current row. | ||
130 | signal toggleCurrent | 107 | signal toggleCurrent | ||
131 | 108 | | |||
132 | Layout.fillWidth: true | 109 | Layout.fillWidth: true | ||
133 | Layout.fillHeight: true | 110 | Layout.fillHeight: true | ||
134 | 111 | | |||
Show All 20 Lines | 127 | function adjustColumns() { | |||
155 | } | 132 | } | ||
156 | descriptionColumn.width = width; | 133 | descriptionColumn.width = width; | ||
157 | } | 134 | } | ||
158 | 135 | | |||
159 | onWidthChanged: adjustColumns() | 136 | onWidthChanged: adjustColumns() | ||
160 | // Component.onCompleted is too early to do this... | 137 | // Component.onCompleted is too early to do this... | ||
161 | onRowCountChanged: adjustColumns() | 138 | onRowCountChanged: adjustColumns() | ||
162 | 139 | | |||
163 | TableViewColumn { | 140 | QQC1.TableViewColumn { | ||
164 | role: "checked" | 141 | role: "checked" | ||
165 | width: metricsCheckBox.width | 142 | width: metricsCheckBox.width | ||
166 | resizable: false | 143 | resizable: false | ||
167 | movable: false | 144 | movable: false | ||
168 | 145 | | |||
169 | delegate: CheckBox { | 146 | delegate: CheckBox { | ||
170 | id: checkBox | 147 | id: checkBox | ||
171 | 148 | | |||
Show All 14 Lines | 162 | onToggleCurrent: { | |||
186 | if (styleData.row === mimeTypesView.currentRow) { | 163 | if (styleData.row === mimeTypesView.currentRow) { | ||
187 | model.checked = !checkBox.checked | 164 | model.checked = !checkBox.checked | ||
188 | } | 165 | } | ||
189 | } | 166 | } | ||
190 | } | 167 | } | ||
191 | } | 168 | } | ||
192 | } | 169 | } | ||
193 | 170 | | |||
194 | TableViewColumn { | 171 | QQC1.TableViewColumn { | ||
195 | role: "decoration" | 172 | role: "decoration" | ||
196 | width: units.iconSizes.small | 173 | width: units.iconSizes.small | ||
197 | resizable: false | 174 | resizable: false | ||
198 | movable: false | 175 | movable: false | ||
199 | 176 | | |||
200 | delegate: PlasmaCore.IconItem { | 177 | delegate: PlasmaCore.IconItem { | ||
201 | width: units.iconSizes.small | 178 | width: units.iconSizes.small | ||
202 | height: units.iconSizes.small | 179 | height: units.iconSizes.small | ||
203 | animated: false // TableView re-uses delegates, avoid animation when sorting/filtering. | 180 | animated: false // TableView re-uses delegates, avoid animation when sorting/filtering. | ||
204 | source: styleData.value | 181 | source: styleData.value | ||
205 | } | 182 | } | ||
206 | } | 183 | } | ||
207 | 184 | | |||
208 | TableViewColumn { | 185 | QQC1.TableViewColumn { | ||
209 | id: nameColumn | 186 | id: nameColumn | ||
210 | role: "name" | 187 | role: "name" | ||
211 | title: i18n("File type") | 188 | title: i18n("File type") | ||
212 | width: units.gridUnit * 10 // Assume somewhat reasonable default for mime type name. | 189 | width: units.gridUnit * 10 // Assume somewhat reasonable default for mime type name. | ||
213 | onWidthChanged: mimeTypesView.adjustColumns() | 190 | onWidthChanged: mimeTypesView.adjustColumns() | ||
214 | movable: false | 191 | movable: false | ||
215 | } | 192 | } | ||
216 | TableViewColumn { | 193 | | ||
194 | QQC1.TableViewColumn { | ||||
217 | id: descriptionColumn | 195 | id: descriptionColumn | ||
218 | role: "comment" | 196 | role: "comment" | ||
219 | title: i18n("Description") | 197 | title: i18n("Description") | ||
220 | movable: false | 198 | movable: false | ||
221 | resizable: false | 199 | resizable: false | ||
222 | } | 200 | } | ||
223 | } | 201 | } | ||
224 | 202 | | |||
225 | ColumnLayout { | 203 | RowLayout { | ||
226 | Layout.alignment: Qt.AlignTop | | |||
227 | // Need to explicitly base the size off the button's implicitWidth | | |||
228 | // to avoid the column from growing way too wide due to fillWidth... | | |||
229 | Layout.maximumWidth: Math.max(selectAllButton.implicitWidth, deselectAllButton.implicitWidth) | | |||
230 | | ||||
231 | Button { | 204 | Button { | ||
232 | id: selectAllButton | 205 | id: selectAllButton | ||
233 | Layout.fillWidth: true | | |||
234 | | ||||
235 | enabled: (filterMode.currentIndex > 0) | 206 | enabled: (filterMode.currentIndex > 0) | ||
236 | 207 | icon.name: "edit-select-all" | |||
237 | text: i18n("Select All") | 208 | ToolTip.delay: 1000 | ||
I think using ToolTip attached property is discouraged as that cannot inherit the default times from the desktop style. ToolTip { ... } broulik: I think using `ToolTip` attached property is discouraged as that cannot inherit the default… | |||||
238 | 209 | ToolTip.timeout: 5000 | |||
210 | ToolTip.visible: (Kirigami.Settings.isMobile ? pressed : hovered) && ToolTip.text.length > 0 | ||||
211 | ToolTip.text: i18n("Select All") | ||||
239 | onClicked: filteredMimeTypesModel.checkFiltered() | 212 | onClicked: filteredMimeTypesModel.checkFiltered() | ||
240 | } | 213 | } | ||
241 | 214 | | |||
242 | Button { | 215 | Button { | ||
243 | id: deselectAllButton | 216 | id: deselectAllButton | ||
244 | Layout.fillWidth: true | | |||
245 | | ||||
246 | enabled: (filterMode.currentIndex > 0) | 217 | enabled: (filterMode.currentIndex > 0) | ||
247 | 218 | icon.name: "edit-select-none" | |||
248 | text: i18n("Deselect All") | 219 | ToolTip.delay: 1000 | ||
249 | 220 | ToolTip.timeout: 5000 | |||
221 | ToolTip.visible: (Kirigami.Settings.isMobile ? pressed : hovered) && ToolTip.text.length > 0 | ||||
222 | ToolTip.text: i18n("Deselect All") | ||||
250 | onClicked: filteredMimeTypesModel.uncheckFiltered() | 223 | onClicked: filteredMimeTypesModel.uncheckFiltered() | ||
251 | } | 224 | } | ||
252 | } | 225 | } | ||
253 | } | 226 | } | ||
254 | } | 227 | } | ||
255 | } | |
These lines are quite wrong to begin with, but resizing childenRect inside a columnLayout now becomes doubly wrong. It's a clear binding loop as children are resized to the layout.
If you don't have a tonne of warnings being printed, it probably means these properties get override by the instantiator of this Item.
Please kill them.