7pragma ComponentBehavior: Bound
10import QtQuick.Controls as QQC2
12import QtQuick.Templates as T
13import org.kde.kirigami as Kirigami
50Kirigami.OverlayDrawer {
53 edge:
Qt.application.layoutDirection ===
Qt.RightToLeft ?
Qt.RightEdge :
Qt.LeftEdge
55 handleClosedIcon.source: null
56 handleOpenIcon.source: null
60 if (!modal && drawerOpen) {
65 if (typeof applicationWindow ===
"function") {
66 const w = applicationWindow();
67 if (w && !w.controlsVisible) {
73 return !isMenu || Kirigami.Settings.isMobile;
76 enabled: !isMenu || Kirigami.Settings.isMobile
92 property var titleIcon
131 property list<T.Action>
actions
141 property alias
header: mainLayout.header
151 property alias
footer: mainLayout.footer
198 default property alias
content: mainContent.data
230 property bool showHeaderWhenCollapsed:
false
245 readonly
property T.Action
currentSubMenu: stackView.currentItem?.current ?? null
254 property bool isMenu:
false
271 stackView.pop(stackView.get(0, T.StackView.DontLoad));
273 root.drawerOpen =
false;
303 function ensureVisible(item:
Item, yOffset:
int) {
304 var actualItemY = item.y + (yOffset ?? 0)
305 var viewYPosition = (item.height <= mainFlickable.height)
306 ? Math.round(actualItemY + item.height / 2 - mainFlickable.height / 2)
308 if (actualItemY < mainFlickable.contentY) {
309 mainFlickable.contentY = Math.max(0, viewYPosition)
310 }
else if ((actualItemY + item.height) > (mainFlickable.contentY + mainFlickable.height)) {
311 mainFlickable.contentY = Math.min(mainFlickable.contentHeight - mainFlickable.height, viewYPosition)
313 mainFlickable.returnToBounds()
318 Kirigami.Theme.colorSet: modal ? Kirigami.Theme.Window : Kirigami.Theme.View
320 onIsMenuChanged: drawerOpen =
false
326 property alias model: actionsRepeater.model
327 property T.Action current
328 property int level: 0
331 Layout.maximumHeight: Layout.minimumHeight
338 icon.name: mirrored ?
"go-previous-symbolic-rtl" :
"go-previous-symbolic"
340 text: Kirigami.MnemonicData.richTextLabel
341 activeFocusOnTab:
true
343 Kirigami.MnemonicData.enabled: enabled && visible
344 Kirigami.MnemonicData.controlType: Kirigami.MnemonicData.MenuItem
345 Kirigami.MnemonicData.label: qsTr(
"Back")
347 onClicked: stackView.pop()
349 Keys.onEnterPressed: stackView.pop()
350 Keys.onReturnPressed: stackView.pop()
352 Keys.onDownPressed: nextItemInFocusChain().focus = true
353 Keys.onUpPressed: nextItemInFocusChain(false).focus = true
357 sequence: backItem.Kirigami.MnemonicData.sequence
358 onActivated: backItem.clicked()
364 readonly
property bool withSections: {
365 for (
const action of root.actions) {
366 if (action.hasOwnProperty(
"expandible") && action.expandible) {
375 delegate: ActionDelegate {
376 required
property T.Action modelData
379 withSections: actionsRepeater.withSections
385 component ActionDelegate : Column {
388 required
property int index
389 required
property T.Action tAction
390 required
property bool withSections
393 readonly
property Kirigami.Action kAction: tAction instanceof Kirigami.Action ? tAction : null
395 readonly
property bool isExpanded: {
396 return !root.collapsed
398 && kAction.expandible
399 && kAction.children.length > 0;
402 visible: kAction?.visible ??
true
406 KP.GlobalDrawerActionItem {
407 Kirigami.Theme.colorSet: !root.modal && !root.collapsed && delegate.withSections
408 ? Kirigami.Theme.Window : parent.Kirigami.Theme.colorSet
410 visible: !delegate.isExpanded
413 tAction: delegate.tAction
417 if (checked && topContent.height + backItem.height + (delegate.index + 1) * height - mainFlickable.contentY > mainFlickable.height) {
418 mainFlickable.contentY += height
424 root.ensureVisible (delegate, topContent.height + (backItem.visible ? backItem.height : 0))
432 visible: delegate.isExpanded
433 height: sectionHeader.implicitHeight
436 Kirigami.ListSectionHeader {
440 Kirigami.Theme.colorSet: root.modal ? Kirigami.Theme.View : Kirigami.Theme.Window
442 contentItem: RowLayout {
443 spacing: sectionHeader.spacing
446 property int size: Kirigami.Units.iconSizes.smallMedium
447 Layout.minimumHeight: size
448 Layout.maximumHeight: size
449 Layout.minimumWidth: size
450 Layout.maximumWidth: size
451 source: delegate.tAction.icon.name || delegate.tAction.icon.source
456 text: delegate.tAction.text
457 elide: Text.ElideRight
458 Layout.fillWidth:
true
465 model: delegate.isExpanded ? (delegate.kAction?.children ?? null) : null
467 NestedActionDelegate {
468 required property T.
Action modelData
471 withSections: delegate.withSections
476 component NestedActionDelegate : KP.GlobalDrawerActionItem {
477 required property bool withSections
480 opacity: !root.collapsed
481 leftPadding: withSections && !root.collapsed && !root.modal ? padding * 2 : padding * 4
489 topMargin: root.collapsed && !showHeaderWhenCollapsed ? -contentItem.y : 0
492 Behavior on anchors.topMargin {
494 duration: Kirigami.
Units.longDuration
495 easing.
type: Easing.InOutQuad
500 visible: root.title.length > 0 ||
Boolean(root.titleIcon)
501 spacing: Kirigami.
Units.largeSpacing
504 source: root.titleIcon
510 visible: !root.collapsed
511 Layout.fillWidth: true
519 Kirigami.Theme.inherit: true
524 implicitWidth: Math.min(Kirigami.
Units.gridUnit * 20, root.parent.width * 0.8)
530 contentHeight: mainColumn.Layout.minimumHeight
532 clip: (mainLayout.header?.visible ?? false) || (mainLayout.footer?.visible ?? false)
536 width: mainFlickable.width
538 height: Math.max(scrollView.height, Layout.minimumHeight)
546 Layout.leftMargin: root.leftPadding
547 Layout.rightMargin: root.rightPadding
548 Layout.bottomMargin: Kirigami.
Units.smallSpacing
549 Layout.topMargin: root.topPadding
550 Layout.fillWidth: true
551 Layout.fillHeight: true
552 Layout.preferredHeight: implicitHeight * opacity
555 Layout.minimumWidth: parent.width - root.leftPadding - root.rightPadding
557 visible: children.length > 0 && childrenRect.height > 0 && opacity > 0
558 opacity: !root.collapsed || showTopContentWhenCollapsed
560 Behavior on opacity {
563 duration: Kirigami.
Units.longDuration
564 easing.
type: Easing.InOutQuad
572 property KP.ActionsMenu openSubMenu
575 Layout.fillWidth: true
576 Layout.minimumHeight: currentItem ? currentItem.implicitHeight : 0
577 Layout.maximumHeight: Layout.minimumHeight
579 initialItem: menuComponent
584 popEnter: Transition {
585 NumberAnimation { property:
"x"; from: (stackView.mirrored ? -1 : 1) * -stackView.width; to: 0; duration: Kirigami.Units.veryLongDuration; easing.type: Easing.OutCubic }
588 popExit: Transition {
589 NumberAnimation { property:
"x"; from: 0; to: (stackView.mirrored ? -1 : 1) * stackView.width; duration: Kirigami.Units.veryLongDuration; easing.type: Easing.OutCubic }
592 pushEnter: Transition {
593 NumberAnimation { property:
"x"; from: (stackView.mirrored ? -1 : 1) * stackView.width; to: 0; duration: Kirigami.Units.veryLongDuration; easing.type: Easing.OutCubic }
596 pushExit: Transition {
597 NumberAnimation { property:
"x"; from: 0; to: (stackView.mirrored ? -1 : 1) * -stackView.width; duration: Kirigami.Units.veryLongDuration; easing.type: Easing.OutCubic }
600 replaceEnter: Transition {
601 NumberAnimation { property:
"x"; from: (stackView.mirrored ? -1 : 1) * stackView.width; to: 0; duration: Kirigami.Units.veryLongDuration; easing.type: Easing.OutCubic }
604 replaceExit: Transition {
605 NumberAnimation { property:
"x"; from: 0; to: (stackView.mirrored ? -1 : 1) * -stackView.width; duration: Kirigami.Units.veryLongDuration; easing.type: Easing.OutCubic }
610 Layout.fillWidth:
true
611 Layout.fillHeight: root.actions.length > 0
612 Layout.minimumHeight: Kirigami.Units.smallSpacing
617 Layout.alignment:
Qt.AlignHCenter
618 Layout.leftMargin: root.leftPadding
619 Layout.rightMargin: root.rightPadding
620 Layout.fillWidth:
true
621 Layout.fillHeight:
true
624 Layout.minimumWidth: parent.width - root.leftPadding - root.rightPadding
625 visible: children.length > 0 && (opacity > 0 || mainContentAnimator.running)
626 opacity: !root.collapsed || showContentWhenCollapsed
627 Behavior on opacity {
629 id: mainContentAnimator
630 duration: Kirigami.
Units.longDuration
631 easing.
type: Easing.InOutQuad
637 Layout.minimumWidth: Kirigami.
Units.smallSpacing
638 Layout.minimumHeight: root.bottomPadding
642 Layout.fillWidth: true
645 if (root.collapsible && root.collapseButtonVisible) {
648 const mirrored = root.edge ===
Qt.RightEdge;
650 if (root.collapsed) {
651 return mirrored ?
"sidebar-expand-right" :
"sidebar-expand-left";
653 return mirrored ?
"sidebar-collapse-right" :
"sidebar-collapse-left";
659 visible: root.collapsible && root.collapseButtonVisible
660 text: root.collapsed ?
"" : qsTr(
"Close Sidebar")
662 onClicked: root.collapsed = !root.collapsed
664 QQC2.ToolTip.visible: root.collapsed && (Kirigami.Settings.tabletMode ? pressed : hovered)
665 QQC2.ToolTip.text: qsTr(
"Open Sidebar")
666 QQC2.ToolTip.delay: Kirigami.
Units.toolTipDelay
listTAction actions
This property holds the actions displayed in the drawer.
alias header
This property holds an item that will always be displayed at the top of the drawer.
bool collapseButtonVisible
This property sets the visibility of the collapse button when the drawer collapsible.
alias footer
This property holds an item that will always be displayed at the bottom of the drawer.
alias topContent
This property holds items that are displayed above the actions.
bool showContentWhenCollapsed
This property sets whether content items at the bottom should be shown.
bool showTopContentWhenCollapsed
This property sets whether content items at the top should be shown.
bool resetMenuOnTriggered
This property sets whether activating a leaf action resets the menu to show leaf's parent actions.
TAction currentSubMenu
This property points to the action acting as a submenu.
void resetMenu()
This function reverts the menu back to its initial state.
bool isMenu
This property sets whether the drawer becomes a menu on the desktop.
alias content
This property holds items that are displayed under the actions.
Class for rendering an icon in UI.
QStringView level(QStringView ifopt)
VehicleSection::Type type(QStringView coachNumber, QStringView coachClassification)
QString name(StandardAction id)