Changeset View
Changeset View
Standalone View
Standalone View
src/controls/GlobalDrawer.qml
Show First 20 Lines • Show All 232 Lines • ▼ Show 20 Line(s) | 67 | OverlayDrawer { | |||
---|---|---|---|---|---|
233 | */ | 233 | */ | ||
234 | function resetMenu() { | 234 | function resetMenu() { | ||
235 | stackView.pop(stackView.get(0, T2.StackView.DontLoad)); | 235 | stackView.pop(stackView.get(0, T2.StackView.DontLoad)); | ||
236 | if (root.modal) { | 236 | if (root.modal) { | ||
237 | root.drawerOpen = false; | 237 | root.drawerOpen = false; | ||
238 | } | 238 | } | ||
239 | } | 239 | } | ||
240 | 240 | | |||
241 | rightPadding: !Settings.isMobile && mainFlickable.contentHeight > mainFlickable.height ? Units.gridUnit : Units.smallSpacing | 241 | leftPadding: 0 | ||
242 | rightPadding: 0 | ||||
243 | topPadding: 0 | ||||
244 | bottomPadding: 0 | ||||
ahiemstra: +1 for getting rid of these paddings. | |||||
242 | 245 | | |||
243 | contentItem: ScrollView { | 246 | contentItem: ColumnLayout { | ||
247 | spacing: 0 | ||||
248 | implicitWidth: Math.min (Units.gridUnit * 20, root.parent.width * 0.8) | ||||
249 | | ||||
250 | ColumnLayout { | ||||
251 | id: topContent | ||||
252 | spacing: 0 | ||||
ahiemstra: Uhm, what's this value? | |||||
253 | Layout.alignment: Qt.AlignHCenter | ||||
254 | Layout.fillWidth: true | ||||
255 | Layout.preferredHeight: implicitHeight * opacity | ||||
256 | //NOTE: why this? just Layout.fillWidth: true doesn't seem sufficient | ||||
257 | //as items are added only after this column creation | ||||
258 | Layout.minimumWidth: parent.width | ||||
General rule of thumb:
If you ever mix them you're asking for recursive loops. davidedmundson: General rule of thumb:
* implicit size goes up from children to parent (including Layout. | |||||
259 | visible: children.length > 0 && childrenRect.height > 0 && opacity > 0 | ||||
260 | opacity: (!root.collapsed || showTopContentWhenCollapsed) ? 1 : 0 | ||||
In my opinion, it is nicer to be explicit about types instead of relying on implicit conversion. So this should be (!root.collapsed || showTopContentWhenCollapsed) ? 1 : 0. ahiemstra: In my opinion, it is nicer to be explicit about types instead of relying on implicit conversion. | |||||
261 | Behavior on opacity { | ||||
262 | //not an animator as is binded | ||||
263 | NumberAnimation { | ||||
264 | duration: Units.longDuration | ||||
265 | easing.type: Easing.InOutQuad | ||||
266 | } | ||||
267 | } | ||||
268 | } | ||||
269 | | ||||
270 | ScrollView { | ||||
244 | id: scrollView | 271 | id: scrollView | ||
272 | Layout.fillWidth: true | ||||
273 | Layout.fillHeight: true | ||||
245 | //ensure the attached property exists | 274 | //ensure the attached property exists | ||
246 | Theme.inherit: true | 275 | Theme.inherit: true | ||
247 | anchors.fill: parent | | |||
248 | implicitWidth: Math.min (Units.gridUnit * 20, root.parent.width * 0.8) | | |||
249 | horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff | 276 | horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff | ||
250 | 277 | | |||
251 | Flickable { | 278 | Flickable { | ||
252 | id: mainFlickable | 279 | id: mainFlickable | ||
253 | contentWidth: width | 280 | contentWidth: width | ||
254 | contentHeight: mainColumn.Layout.minimumHeight | 281 | contentHeight: mainColumn.Layout.minimumHeight | ||
255 | 282 | | |||
256 | ColumnLayout { | 283 | ColumnLayout { | ||
257 | id: mainColumn | 284 | id: mainColumn | ||
258 | width: mainFlickable.width | 285 | width: mainFlickable.width | ||
259 | spacing: 0 | 286 | spacing: 0 | ||
260 | height: Math.max(root.height, Layout.minimumHeight) | 287 | height: scrollView.height | ||
261 | 288 | | |||
262 | //TODO: cable visible of bannerimage | 289 | //TODO: cable visible of bannerimage | ||
263 | Item { | 290 | Item { | ||
264 | implicitHeight: root.collapsible | 291 | implicitHeight: root.collapsible | ||
265 | ? Math.max(collapseButton.height + Units.smallSpacing, bannerImage.Layout.preferredHeight) | 292 | ? Math.max(collapseButton.height + Units.smallSpacing, bannerImage.Layout.preferredHeight) | ||
266 | : bannerImage.Layout.preferredHeight | 293 | : bannerImage.Layout.preferredHeight | ||
267 | 294 | | |||
268 | Layout.fillWidth: true | 295 | Layout.fillWidth: true | ||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | 358 | kirigamiAction: Action { | |||
332 | icon.name: "application-menu" | 359 | icon.name: "application-menu" | ||
333 | checkable: true | 360 | checkable: true | ||
334 | checked: !root.collapsed | 361 | checked: !root.collapsed | ||
335 | onCheckedChanged: root.collapsed = !checked | 362 | onCheckedChanged: root.collapsed = !checked | ||
336 | } | 363 | } | ||
337 | } | 364 | } | ||
338 | } | 365 | } | ||
339 | 366 | | |||
340 | ColumnLayout { | | |||
341 | id: topContent | | |||
342 | spacing: 0 | | |||
343 | Layout.alignment: Qt.AlignHCenter | | |||
344 | Layout.leftMargin: root.leftPadding | | |||
345 | Layout.rightMargin: root.rightPadding | | |||
346 | Layout.bottomMargin: Units.smallSpacing | | |||
347 | Layout.topMargin: root.topPadding | | |||
348 | Layout.fillWidth: true | | |||
349 | Layout.fillHeight: true | | |||
350 | Layout.preferredHeight: implicitHeight * opacity | | |||
351 | //NOTE: why this? just Layout.fillWidth: true doesn't seem sufficient | | |||
352 | //as items are added only after this column creation | | |||
353 | Layout.minimumWidth: parent.width - root.leftPadding - root.rightPadding | | |||
354 | visible: children.length > 0 && childrenRect.height > 0 && opacity > 0 | | |||
355 | opacity: !root.collapsed || showTopContentWhenCollapsed | | |||
356 | Behavior on opacity { | | |||
357 | //not an animator as is binded | | |||
358 | NumberAnimation { | | |||
359 | duration: Units.longDuration | | |||
360 | easing.type: Easing.InOutQuad | | |||
361 | } | | |||
362 | } | | |||
363 | } | | |||
364 | | ||||
365 | T2.StackView { | 367 | T2.StackView { | ||
366 | id: stackView | 368 | id: stackView | ||
367 | Layout.fillWidth: true | 369 | Layout.fillWidth: true | ||
370 | Layout.rightMargin: !Settings.isMobile && mainFlickable.contentHeight > mainFlickable.height ? Units.gridUnit : 0 | ||||
ahiemstra: We **really** should fix scrollview's scrollbars... | |||||
See https://phabricator.kde.org/T9126. I *really* dislike overlay scrollbars, both in terms of utility and also because of the horrible code hacks required to make them work properly. Material for another patch though. ngraham: See https://phabricator.kde.org/T9126.
I *really* dislike overlay scrollbars, both in terms of… | |||||
368 | Layout.minimumHeight: currentItem ? currentItem.implicitHeight : 0 | 371 | Layout.minimumHeight: currentItem ? currentItem.implicitHeight : 0 | ||
369 | Layout.maximumHeight: Layout.minimumHeight | 372 | Layout.maximumHeight: Layout.minimumHeight | ||
370 | property ActionsMenu openSubMenu | 373 | property ActionsMenu openSubMenu | ||
371 | initialItem: menuComponent | 374 | initialItem: menuComponent | ||
372 | //NOTE: it's important those are NumberAnimation and not XAnimators | 375 | //NOTE: it's important those are NumberAnimation and not XAnimators | ||
373 | // as while the animation is running the drawer may close, and | 376 | // as while the animation is running the drawer may close, and | ||
374 | //the animator would stop when not drawing see BUG 381576 | 377 | //the animator would stop when not drawing see BUG 381576 | ||
375 | popEnter: Transition { | 378 | popEnter: Transition { | ||
Show All 24 Lines | 402 | Item { | |||
400 | Layout.fillWidth: true | 403 | Layout.fillWidth: true | ||
401 | Layout.fillHeight: root.actions.length>0 | 404 | Layout.fillHeight: root.actions.length>0 | ||
402 | Layout.minimumHeight: Units.smallSpacing | 405 | Layout.minimumHeight: Units.smallSpacing | ||
403 | } | 406 | } | ||
404 | 407 | | |||
405 | ColumnLayout { | 408 | ColumnLayout { | ||
406 | id: mainContent | 409 | id: mainContent | ||
407 | Layout.alignment: Qt.AlignHCenter | 410 | Layout.alignment: Qt.AlignHCenter | ||
408 | Layout.leftMargin: root.leftPadding | 411 | Layout.rightMargin: !Settings.isMobile && mainFlickable.contentHeight > mainFlickable.height ? Units.gridUnit : 0 | ||
409 | Layout.rightMargin: root.rightPadding | 412 | | ||
410 | Layout.fillWidth: true | 413 | Layout.fillWidth: true | ||
411 | Layout.fillHeight: true | 414 | Layout.fillHeight: true | ||
412 | //NOTE: why this? just Layout.fillWidth: true doesn't seem sufficient | | |||
413 | //as items are added only after this column creation | | |||
414 | Layout.minimumWidth: parent.width - root.leftPadding - root.rightPadding | | |||
415 | visible: children.length > 0 && (opacity > 0 || mainContentAnimator.running) | 415 | visible: children.length > 0 && (opacity > 0 || mainContentAnimator.running) | ||
416 | opacity: !root.collapsed || showContentWhenCollapsed | 416 | opacity: !root.collapsed || showContentWhenCollapsed | ||
417 | Behavior on opacity { | 417 | Behavior on opacity { | ||
418 | OpacityAnimator { | 418 | OpacityAnimator { | ||
419 | id: mainContentAnimator | 419 | id: mainContentAnimator | ||
420 | duration: Units.longDuration | 420 | duration: Units.longDuration | ||
421 | easing.type: Easing.InOutQuad | 421 | easing.type: Easing.InOutQuad | ||
422 | } | 422 | } | ||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | 460 | Repeater { | |||
477 | } | 477 | } | ||
478 | } | 478 | } | ||
479 | } | 479 | } | ||
480 | } | 480 | } | ||
481 | } | 481 | } | ||
482 | } | 482 | } | ||
483 | } | 483 | } | ||
484 | } | 484 | } | ||
485 | } | ||||
485 | 486 | |
+1 for getting rid of these paddings.