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 | 33 | width: childrenRect.width | ||
32 | height: childrenRect.height | 34 | height: childrenRect.height | ||
davidedmundson: These lines are quite wrong to begin with, but resizing childenRect inside a columnLayout now… | |||||
33 | 35 | | |||
34 | property alias cfg_filterMode: filterMode.currentIndex | 36 | property alias cfg_filterMode: filterMode.currentIndex | ||
35 | property alias cfg_filterPattern: filterPattern.text | 37 | property alias cfg_filterPattern: filterPattern.text | ||
36 | property alias cfg_filterMimeTypes: mimeTypesModel.checkedTypes | 38 | property alias cfg_filterMimeTypes: mimeTypesModel.checkedTypes | ||
37 | 39 | | |||
38 | PlasmaCore.SortFilterModel { | 40 | PlasmaCore.SortFilterModel { | ||
39 | id: filteredMimeTypesModel | 41 | id: filteredMimeTypesModel | ||
40 | 42 | | |||
Show All 25 Lines | 65 | function uncheckFiltered() { | |||
66 | for (var i = 0; i < count; ++i) { | 68 | for (var i = 0; i < count; ++i) { | ||
67 | types.push(get(i).name); | 69 | types.push(get(i).name); | ||
68 | } | 70 | } | ||
69 | 71 | | |||
70 | mimeTypesModel.checkedTypes = mimeTypesModel.checkedTypes.filter(function(x) { | 72 | mimeTypesModel.checkedTypes = mimeTypesModel.checkedTypes.filter(function(x) { | ||
71 | return types.indexOf(x) < 0; }); | 73 | return types.indexOf(x) < 0; }); | ||
72 | } | 74 | } | ||
73 | } | 75 | } | ||
74 | 76 | Kirigami.FormLayout { | |||
75 | ColumnLayout { | | |||
76 | width: parent.width | | |||
77 | height: parent.height | | |||
78 | | ||||
79 | ComboBox { | 77 | ComboBox { | ||
80 | id: filterMode | 78 | id: filterMode | ||
81 | 79 | Kirigami.FormData.label: i18n("Files:") | |||
82 | Layout.fillWidth: true | 80 | 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 | } | 81 | } | ||
92 | 82 | | |||
93 | TextField { | 83 | TextField { | ||
94 | id: filterPattern | 84 | id: filterPattern | ||
95 | 85 | Kirigami.FormData.label: i18n("File name pattern:") | |||
96 | Layout.fillWidth: true | | |||
97 | | ||||
98 | enabled: (filterMode.currentIndex > 0) | 86 | enabled: (filterMode.currentIndex > 0) | ||
99 | } | 87 | } | ||
100 | 88 | | |||
101 | Label { | | |||
102 | Layout.fillWidth: true | | |||
103 | | ||||
104 | text: i18n("File types:") | | |||
105 | } | | |||
106 | | ||||
107 | TextField { | 89 | TextField { | ||
108 | id: mimeFilter | 90 | id: mimeFilter | ||
109 | 91 | Kirigami.FormData.label: i18n("File types:") | |||
110 | Layout.fillWidth: true | | |||
111 | | ||||
112 | enabled: (filterMode.currentIndex > 0) | 92 | enabled: (filterMode.currentIndex > 0) | ||
113 | 93 | placeholderText: i18n("Search...") | |||
114 | placeholderText: i18n("Search file type...") | 94 | } | ||
115 | } | 95 | } | ||
116 | 96 | | |||
117 | RowLayout { | 97 | ColumnLayout { | ||
118 | Layout.fillWidth: true | 98 | Layout.fillWidth: true | ||
119 | Layout.fillHeight: true | 99 | Layout.fillHeight: true | ||
120 | 100 | | |||
121 | CheckBox { // Purely for metrics. | 101 | CheckBox { // Purely for metrics. | ||
122 | id: metricsCheckBox | 102 | id: metricsCheckBox | ||
123 | visible: false | 103 | visible: false | ||
124 | } | 104 | } | ||
125 | 105 | | |||
126 | TableView { | 106 | QQC1.TableView { | ||
127 | id: mimeTypesView | 107 | id: mimeTypesView | ||
128 | 108 | | |||
129 | // Signal the delegates listen to when user presses space to toggle current row. | 109 | // Signal the delegates listen to when user presses space to toggle current row. | ||
130 | signal toggleCurrent | 110 | signal toggleCurrent | ||
131 | 111 | | |||
132 | Layout.fillWidth: true | 112 | Layout.fillWidth: true | ||
133 | Layout.fillHeight: true | 113 | Layout.fillHeight: true | ||
134 | 114 | | |||
Show All 20 Lines | 130 | function adjustColumns() { | |||
155 | } | 135 | } | ||
156 | descriptionColumn.width = width; | 136 | descriptionColumn.width = width; | ||
157 | } | 137 | } | ||
158 | 138 | | |||
159 | onWidthChanged: adjustColumns() | 139 | onWidthChanged: adjustColumns() | ||
160 | // Component.onCompleted is too early to do this... | 140 | // Component.onCompleted is too early to do this... | ||
161 | onRowCountChanged: adjustColumns() | 141 | onRowCountChanged: adjustColumns() | ||
162 | 142 | | |||
163 | TableViewColumn { | 143 | QQC1.TableViewColumn { | ||
164 | role: "checked" | 144 | role: "checked" | ||
165 | width: metricsCheckBox.width | 145 | width: metricsCheckBox.width | ||
166 | resizable: false | 146 | resizable: false | ||
167 | movable: false | 147 | movable: false | ||
168 | 148 | | |||
169 | delegate: CheckBox { | 149 | delegate: CheckBox { | ||
170 | id: checkBox | 150 | id: checkBox | ||
171 | 151 | | |||
Show All 14 Lines | 165 | onToggleCurrent: { | |||
186 | if (styleData.row === mimeTypesView.currentRow) { | 166 | if (styleData.row === mimeTypesView.currentRow) { | ||
187 | model.checked = !checkBox.checked | 167 | model.checked = !checkBox.checked | ||
188 | } | 168 | } | ||
189 | } | 169 | } | ||
190 | } | 170 | } | ||
191 | } | 171 | } | ||
192 | } | 172 | } | ||
193 | 173 | | |||
194 | TableViewColumn { | 174 | QQC1.TableViewColumn { | ||
195 | role: "decoration" | 175 | role: "decoration" | ||
196 | width: units.iconSizes.small | 176 | width: units.iconSizes.small | ||
197 | resizable: false | 177 | resizable: false | ||
198 | movable: false | 178 | movable: false | ||
199 | 179 | | |||
200 | delegate: PlasmaCore.IconItem { | 180 | delegate: PlasmaCore.IconItem { | ||
201 | width: units.iconSizes.small | 181 | width: units.iconSizes.small | ||
202 | height: units.iconSizes.small | 182 | height: units.iconSizes.small | ||
203 | animated: false // TableView re-uses delegates, avoid animation when sorting/filtering. | 183 | animated: false // TableView re-uses delegates, avoid animation when sorting/filtering. | ||
204 | source: styleData.value | 184 | source: styleData.value | ||
205 | } | 185 | } | ||
206 | } | 186 | } | ||
207 | 187 | | |||
208 | TableViewColumn { | 188 | QQC1.TableViewColumn { | ||
209 | id: nameColumn | 189 | id: nameColumn | ||
210 | role: "name" | 190 | role: "name" | ||
211 | title: i18n("File type") | 191 | title: i18n("File type") | ||
212 | width: units.gridUnit * 10 // Assume somewhat reasonable default for mime type name. | 192 | width: units.gridUnit * 10 // Assume somewhat reasonable default for mime type name. | ||
213 | onWidthChanged: mimeTypesView.adjustColumns() | 193 | onWidthChanged: mimeTypesView.adjustColumns() | ||
214 | movable: false | 194 | movable: false | ||
215 | } | 195 | } | ||
216 | TableViewColumn { | 196 | | ||
197 | QQC1.TableViewColumn { | ||||
217 | id: descriptionColumn | 198 | id: descriptionColumn | ||
218 | role: "comment" | 199 | role: "comment" | ||
219 | title: i18n("Description") | 200 | title: i18n("Description") | ||
220 | movable: false | 201 | movable: false | ||
221 | resizable: false | 202 | resizable: false | ||
222 | } | 203 | } | ||
223 | } | 204 | } | ||
224 | 205 | | |||
225 | ColumnLayout { | 206 | 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 { | 207 | Button { | ||
232 | id: selectAllButton | 208 | id: selectAllButton | ||
233 | Layout.fillWidth: true | | |||
234 | | ||||
235 | enabled: (filterMode.currentIndex > 0) | 209 | enabled: (filterMode.currentIndex > 0) | ||
236 | 210 | icon.name: "edit-select-all" | |||
237 | text: i18n("Select All") | 211 | 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 | 212 | ToolTip.timeout: 5000 | |||
213 | ToolTip.visible: (Kirigami.Settings.isMobile ? pressed : hovered) && ToolTip.text.length > 0 | ||||
214 | ToolTip.text: i18n("Select All") | ||||
239 | onClicked: filteredMimeTypesModel.checkFiltered() | 215 | onClicked: filteredMimeTypesModel.checkFiltered() | ||
240 | } | 216 | } | ||
241 | 217 | | |||
242 | Button { | 218 | Button { | ||
243 | id: deselectAllButton | 219 | id: deselectAllButton | ||
244 | Layout.fillWidth: true | | |||
245 | | ||||
246 | enabled: (filterMode.currentIndex > 0) | 220 | enabled: (filterMode.currentIndex > 0) | ||
247 | 221 | icon.name: "edit-select-none" | |||
248 | text: i18n("Deselect All") | 222 | ToolTip.delay: 1000 | ||
249 | 223 | ToolTip.timeout: 5000 | |||
224 | ToolTip.visible: (Kirigami.Settings.isMobile ? pressed : hovered) && ToolTip.text.length > 0 | ||||
225 | ToolTip.text: i18n("Deselect All") | ||||
250 | onClicked: filteredMimeTypesModel.uncheckFiltered() | 226 | onClicked: filteredMimeTypesModel.uncheckFiltered() | ||
251 | } | 227 | } | ||
252 | } | 228 | } | ||
253 | } | 229 | } | ||
254 | } | 230 | } | ||
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.