Drawer.qml 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright (C) 2017 The Qt Company Ltd.
  2. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
  3. // Qt-Security score:significant reason:default
  4. import QtQuick
  5. import QtQuick.Templates as T
  6. import QtQuick.Controls.Imagine
  7. import QtQuick.Controls.Imagine.impl
  8. T.Drawer {
  9. id: control
  10. parent: T.Overlay.overlay
  11. implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
  12. implicitContentWidth + leftPadding + rightPadding)
  13. implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
  14. implicitContentHeight + topPadding + bottomPadding)
  15. topPadding: SafeArea.margins.top + (background ? background.topPadding : 0)
  16. leftPadding: SafeArea.margins.left + (background ? background.leftPadding : 0)
  17. rightPadding: SafeArea.margins.right + (background ? background.rightPadding : 0)
  18. bottomPadding: SafeArea.margins.bottom + (background ? background.bottomPadding : 0)
  19. topInset: background ? -background.topInset || 0 : 0
  20. leftInset: background ? -background.leftInset || 0 : 0
  21. rightInset: background ? -background.rightInset || 0 : 0
  22. bottomInset: background ? -background.bottomInset || 0 : 0
  23. enter: Transition { SmoothedAnimation { velocity: 5 } }
  24. exit: Transition { SmoothedAnimation { velocity: 5 } }
  25. background: NinePatchImage {
  26. source: Imagine.url + "drawer-background"
  27. NinePatchImageSelector on source {
  28. states: [
  29. {"modal": control.modal},
  30. {"dim": control.dim},
  31. {"top": control.edge === Qt.TopEdge},
  32. {"left": control.edge === Qt.LeftEdge},
  33. {"right": control.edge === Qt.RightEdge},
  34. {"bottom": control.edge === Qt.BottomEdge}
  35. ]
  36. }
  37. }
  38. T.Overlay.modal: NinePatchImage {
  39. source: Imagine.url + "drawer-overlay"
  40. NinePatchImageSelector on source {
  41. states: [
  42. {"modal": true}
  43. ]
  44. }
  45. }
  46. T.Overlay.modeless: NinePatchImage {
  47. source: Imagine.url + "drawer-overlay"
  48. NinePatchImageSelector on source {
  49. states: [
  50. {"modal": false}
  51. ]
  52. }
  53. }
  54. }