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 Accessible.name: Kirigami.MnemonicData.plainTextLabel
342 activeFocusOnTab:
true
344 Kirigami.MnemonicData.enabled: enabled && visible
345 Kirigami.MnemonicData.controlType: Kirigami.MnemonicData.MenuItem
346 Kirigami.MnemonicData.label: qsTr(
"Back")
348 onClicked: stackView.pop()
350 Keys.onEnterPressed: stackView.pop()
351 Keys.onReturnPressed: stackView.pop()
353 Keys.onDownPressed: nextItemInFocusChain().focus = true
354 Keys.onUpPressed: nextItemInFocusChain(false).focus = true
358 sequence: backItem.Kirigami.MnemonicData.sequence
359 onActivated: backItem.clicked()
365 readonly
property bool withSections: {
366 for (
const action of root.actions) {
367 if (action.hasOwnProperty(
"expandible") && action.expandible) {
376 delegate: ActionDelegate {
377 required
property T.Action modelData
380 withSections: actionsRepeater.withSections
386 component ActionDelegate : Column {
389 required
property int index
390 required
property T.Action tAction
391 required
property bool withSections
394 readonly
property Kirigami.Action kAction: tAction instanceof Kirigami.Action ? tAction : null
396 readonly
property bool isExpanded: {
397 return !root.collapsed
399 && kAction.expandible
400 && kAction.children.length > 0;
403 visible: kAction?.visible ??
true
407 KP.GlobalDrawerActionItem {
408 Kirigami.Theme.colorSet: !root.modal && !root.collapsed && delegate.withSections
409 ? Kirigami.Theme.Window : parent.Kirigami.Theme.colorSet
411 visible: !delegate.isExpanded
414 tAction: delegate.tAction
418 if (checked && topContent.height + backItem.height + (delegate.index + 1) * height - mainFlickable.contentY > mainFlickable.height) {
419 mainFlickable.contentY += height
425 root.ensureVisible (delegate, topContent.height + (backItem.visible ? backItem.height : 0))
433 visible: delegate.isExpanded
434 height: sectionHeader.implicitHeight
437 Kirigami.ListSectionHeader {
441 Kirigami.Theme.colorSet: root.modal ? Kirigami.Theme.View : Kirigami.Theme.Window
443 contentItem: RowLayout {
444 spacing: sectionHeader.spacing
447 property int size: Kirigami.Units.iconSizes.smallMedium
448 Layout.minimumHeight: size
449 Layout.maximumHeight: size
450 Layout.minimumWidth: size
451 Layout.maximumWidth: size
452 source: delegate.tAction.icon.name || delegate.tAction.icon.source
457 text: delegate.tAction.text
458 elide: Text.ElideRight
459 Layout.fillWidth:
true
466 model: delegate.isExpanded ? (delegate.kAction?.children ?? null) : null
468 NestedActionDelegate {
469 required property T.
Action modelData
472 withSections: delegate.withSections
477 component NestedActionDelegate : KP.GlobalDrawerActionItem {
478 required property bool withSections
481 opacity: !root.collapsed
482 leftPadding: withSections && !root.collapsed && !root.modal ? padding * 2 : padding * 4
490 topMargin: root.collapsed && !showHeaderWhenCollapsed ? -contentItem.y : 0
493 Behavior on anchors.topMargin {
495 duration: Kirigami.
Units.longDuration
496 easing.
type: Easing.InOutQuad
501 visible: root.title.length > 0 ||
Boolean(root.titleIcon)
502 spacing: Kirigami.
Units.largeSpacing
505 source: root.titleIcon
511 visible: !root.collapsed
512 Layout.fillWidth: true
520 Kirigami.Theme.inherit: true
525 implicitWidth: Math.min(Kirigami.
Units.gridUnit * 20, root.parent.width * 0.8)
531 contentHeight: mainColumn.Layout.minimumHeight
533 clip: (mainLayout.header?.visible ?? false) || (mainLayout.footer?.visible ?? false)
537 width: mainFlickable.width
539 height: Math.max(scrollView.height, Layout.minimumHeight)
547 Layout.leftMargin: root.leftPadding
548 Layout.rightMargin: root.rightPadding
549 Layout.bottomMargin: Kirigami.
Units.smallSpacing
550 Layout.topMargin: root.topPadding
551 Layout.fillWidth: true
552 Layout.fillHeight: true
553 Layout.preferredHeight: implicitHeight * opacity
556 Layout.minimumWidth: parent.width - root.leftPadding - root.rightPadding
558 visible: children.length > 0 && childrenRect.height > 0 && opacity > 0
559 opacity: !root.collapsed || showTopContentWhenCollapsed
561 Behavior on opacity {
564 duration: Kirigami.
Units.longDuration
565 easing.
type: Easing.InOutQuad
573 property KP.ActionsMenu openSubMenu
576 Layout.fillWidth: true
577 Layout.minimumHeight: currentItem ? currentItem.implicitHeight : 0
578 Layout.maximumHeight: Layout.minimumHeight
580 initialItem: menuComponent
585 popEnter: Transition {
586 NumberAnimation { property:
"x"; from: (stackView.mirrored ? -1 : 1) * -stackView.width; to: 0; duration: Kirigami.Units.veryLongDuration; easing.type: Easing.OutCubic }
589 popExit: Transition {
590 NumberAnimation { property:
"x"; from: 0; to: (stackView.mirrored ? -1 : 1) * stackView.width; duration: Kirigami.Units.veryLongDuration; easing.type: Easing.OutCubic }
593 pushEnter: Transition {
594 NumberAnimation { property:
"x"; from: (stackView.mirrored ? -1 : 1) * stackView.width; to: 0; duration: Kirigami.Units.veryLongDuration; easing.type: Easing.OutCubic }
597 pushExit: Transition {
598 NumberAnimation { property:
"x"; from: 0; to: (stackView.mirrored ? -1 : 1) * -stackView.width; duration: Kirigami.Units.veryLongDuration; easing.type: Easing.OutCubic }
601 replaceEnter: Transition {
602 NumberAnimation { property:
"x"; from: (stackView.mirrored ? -1 : 1) * stackView.width; to: 0; duration: Kirigami.Units.veryLongDuration; easing.type: Easing.OutCubic }
605 replaceExit: Transition {
606 NumberAnimation { property:
"x"; from: 0; to: (stackView.mirrored ? -1 : 1) * -stackView.width; duration: Kirigami.Units.veryLongDuration; easing.type: Easing.OutCubic }
611 Layout.fillWidth:
true
612 Layout.fillHeight: root.actions.length > 0
613 Layout.minimumHeight: Kirigami.Units.smallSpacing
618 Layout.alignment:
Qt.AlignHCenter
619 Layout.leftMargin: root.leftPadding
620 Layout.rightMargin: root.rightPadding
621 Layout.fillWidth:
true
622 Layout.fillHeight:
true
625 Layout.minimumWidth: parent.width - root.leftPadding - root.rightPadding
626 visible: children.length > 0 && (opacity > 0 || mainContentAnimator.running)
627 opacity: !root.collapsed || showContentWhenCollapsed
628 Behavior on opacity {
630 id: mainContentAnimator
631 duration: Kirigami.
Units.longDuration
632 easing.
type: Easing.InOutQuad
638 Layout.minimumWidth: Kirigami.
Units.smallSpacing
639 Layout.minimumHeight: root.bottomPadding
643 Layout.fillWidth: true
646 if (root.collapsible && root.collapseButtonVisible) {
649 const mirrored = root.edge ===
Qt.RightEdge;
651 if (root.collapsed) {
652 return mirrored ?
"sidebar-expand-right" :
"sidebar-expand-left";
654 return mirrored ?
"sidebar-collapse-right" :
"sidebar-collapse-left";
660 visible: root.collapsible && root.collapseButtonVisible
661 text: root.collapsed ?
"" : qsTr(
"Close Sidebar")
663 onClicked: root.collapsed = !root.collapsed
665 QQC2.ToolTip.visible: root.collapsed && (Kirigami.Settings.tabletMode ? pressed : hovered)
666 QQC2.ToolTip.text: qsTr(
"Open Sidebar")
667 QQC2.ToolTip.delay: Kirigami.
Units.toolTipDelay
An item that represents an abstract Action.
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.
A heading label used for subsections of texts.
Class for rendering an icon in UI.
Type type(const QSqlDatabase &db)
QString name(const QVariant &location)
QStringView level(QStringView ifopt)