7pragma ComponentBehavior: Bound
10import QtQuick.Templates as T
11import QtQuick.Controls as QQC2
13import org.kde.kirigami as Kirigami
53Kirigami.OverlayDrawer {
56 edge:
Qt.application.layoutDirection ===
Qt.RightToLeft ?
Qt.RightEdge :
Qt.LeftEdge
58 handleClosedIcon.source: null
59 handleOpenIcon.source: null
63 if (!modal && drawerOpen) {
68 if (typeof applicationWindow ===
"function") {
69 const w = applicationWindow();
70 if (w && !w.controlsVisible) {
76 return !isMenu || Kirigami.Settings.isMobile;
79 enabled: !isMenu || Kirigami.Settings.isMobile
95 property var titleIcon
134 property list<T.Action> actions
144 property alias header: mainLayout.header
154 property alias footer: mainLayout.footer
177 property alias topContent: topContent.
data
201 default property alias content: mainContent.data
215 property bool showTopContentWhenCollapsed:
false
230 property bool showContentWhenCollapsed:
false
233 property bool showHeaderWhenCollapsed:
false
243 property bool resetMenuOnTriggered:
true
248 readonly
property T.Action currentSubMenu: stackView.currentItem?.current ?? null
257 property bool isMenu:
false
267 property bool collapseButtonVisible:
true
273 function resetMenu() {
274 stackView.pop(stackView.get(0, T.StackView.DontLoad));
276 root.drawerOpen =
false;
282 Kirigami.Theme.colorSet: modal ? Kirigami.Theme.Window : Kirigami.Theme.View
284 onIsMenuChanged: drawerOpen =
false
290 property alias model: actionsRepeater.model
291 property T.Action current
292 property int level: 0
295 Layout.maximumHeight: Layout.minimumHeight
302 icon.name: mirrored ?
"go-previous-symbolic-rtl" :
"go-previous-symbolic"
304 text: Kirigami.MnemonicData.richTextLabel
305 activeFocusOnTab:
true
307 Kirigami.MnemonicData.enabled: enabled && visible
308 Kirigami.MnemonicData.controlType: Kirigami.MnemonicData.MenuItem
309 Kirigami.MnemonicData.label: qsTr(
"Back")
311 onClicked: stackView.pop()
313 Keys.onEnterPressed: stackView.pop()
314 Keys.onReturnPressed: stackView.pop()
316 Keys.onDownPressed: nextItemInFocusChain().focus = true
317 Keys.onUpPressed: nextItemInFocusChain(false).focus = true
321 sequence: backItem.Kirigami.MnemonicData.sequence
322 onActivated: backItem.clicked()
328 readonly
property bool withSections: {
329 for (
const action of root.actions) {
330 if (action.hasOwnProperty(
"expandible") && action.expandible) {
339 delegate: ActionDelegate {
340 required
property T.Action modelData
343 withSections: actionsRepeater.withSections
349 component ActionDelegate : Column {
352 required
property int index
353 required
property T.Action tAction
354 required
property bool withSections
357 readonly
property Kirigami.Action kAction: tAction instanceof Kirigami.Action ? tAction : null
359 readonly
property bool isExpanded: {
360 return !root.collapsed
362 && kAction.expandible
363 && kAction.children.
length > 0;
366 visible: kAction?.visible ??
true
370 KP.GlobalDrawerActionItem {
371 Kirigami.Theme.colorSet: !root.modal && !root.collapsed && delegate.withSections
372 ? Kirigami.Theme.Window : parent.Kirigami.Theme.colorSet
374 visible: !delegate.isExpanded
377 tAction: delegate.tAction
381 if (checked && topContent.height + backItem.height + (delegate.index + 1) * height - mainFlickable.contentY > mainFlickable.height) {
382 mainFlickable.contentY += height
390 visible: delegate.isExpanded
394 Kirigami.ListSectionHeader {
398 Kirigami.Theme.colorSet: root.modal ? Kirigami.Theme.View : Kirigami.Theme.Window
400 contentItem: RowLayout {
401 spacing: sectionHeader.spacing
404 property int size: Kirigami.Units.iconSizes.smallMedium
405 Layout.minimumHeight: size
406 Layout.maximumHeight: size
407 Layout.minimumWidth: size
408 Layout.maximumWidth: size
409 source: delegate.tAction.icon.name || delegate.tAction.icon.source
414 text: delegate.tAction.text
415 elide: Text.ElideRight
416 Layout.fillWidth:
true
423 model: delegate.isExpanded ? (delegate.kAction?.children ?? null) : null
425 NestedActionDelegate {
426 required property T.
Action modelData
429 withSections: delegate.withSections
434 component NestedActionDelegate : KP.GlobalDrawerActionItem {
435 required property bool withSections
438 opacity: !root.collapsed
439 leftPadding: withSections && !root.collapsed && !root.modal ? padding * 2 : padding * 4
447 topMargin: root.collapsed && !showHeaderWhenCollapsed ? -contentItem.y : 0
450 Behavior on anchors.topMargin {
452 duration: Kirigami.
Units.longDuration
453 easing.
type: Easing.InOutQuad
458 visible: root.title.length > 0 ||
Boolean(root.titleIcon)
459 spacing: Kirigami.
Units.largeSpacing
462 source: root.titleIcon
468 visible: !root.collapsed
469 Layout.fillWidth: true
477 Kirigami.Theme.inherit: true
482 implicitWidth: Math.min(Kirigami.
Units.gridUnit * 20, root.parent.width * 0.8)
488 contentHeight: mainColumn.Layout.minimumHeight
490 clip: root.footer !== null
494 width: mainFlickable.width
496 height: Math.max(scrollView.height, Layout.minimumHeight)
504 Layout.leftMargin: root.leftPadding
505 Layout.rightMargin: root.rightPadding
506 Layout.bottomMargin: Kirigami.
Units.smallSpacing
507 Layout.topMargin: root.topPadding
508 Layout.fillWidth: true
509 Layout.fillHeight: true
510 Layout.preferredHeight: implicitHeight * opacity
513 Layout.minimumWidth: parent.width - root.leftPadding - root.rightPadding
515 visible: children.length > 0 && childrenRect.height > 0 && opacity > 0
516 opacity: !root.collapsed || showTopContentWhenCollapsed
518 Behavior on opacity {
521 duration: Kirigami.
Units.longDuration
522 easing.
type: Easing.InOutQuad
530 property KP.ActionsMenu openSubMenu
533 Layout.fillWidth: true
534 Layout.minimumHeight: currentItem ? currentItem.implicitHeight : 0
535 Layout.maximumHeight: Layout.minimumHeight
537 initialItem: menuComponent
542 popEnter: Transition {
543 NumberAnimation { property:
"x"; from: (stackView.mirrored ? -1 : 1) * -stackView.width; to: 0; duration: Kirigami.Units.veryLongDuration; easing.type: Easing.OutCubic }
546 popExit: Transition {
547 NumberAnimation { property:
"x"; from: 0; to: (stackView.mirrored ? -1 : 1) * stackView.width; duration: Kirigami.Units.veryLongDuration; easing.type: Easing.OutCubic }
550 pushEnter: Transition {
551 NumberAnimation { property:
"x"; from: (stackView.mirrored ? -1 : 1) * stackView.width; to: 0; duration: Kirigami.Units.veryLongDuration; easing.type: Easing.OutCubic }
554 pushExit: Transition {
555 NumberAnimation { property:
"x"; from: 0; to: (stackView.mirrored ? -1 : 1) * -stackView.width; duration: Kirigami.Units.veryLongDuration; easing.type: Easing.OutCubic }
558 replaceEnter: Transition {
559 NumberAnimation { property:
"x"; from: (stackView.mirrored ? -1 : 1) * stackView.width; to: 0; duration: Kirigami.Units.veryLongDuration; easing.type: Easing.OutCubic }
562 replaceExit: Transition {
563 NumberAnimation { property:
"x"; from: 0; to: (stackView.mirrored ? -1 : 1) * -stackView.width; duration: Kirigami.Units.veryLongDuration; easing.type: Easing.OutCubic }
568 Layout.fillWidth:
true
569 Layout.fillHeight: root.actions.length > 0
570 Layout.minimumHeight: Kirigami.Units.smallSpacing
575 Layout.alignment:
Qt.AlignHCenter
576 Layout.leftMargin: root.leftPadding
577 Layout.rightMargin: root.rightPadding
578 Layout.fillWidth:
true
579 Layout.fillHeight:
true
582 Layout.minimumWidth: parent.width - root.leftPadding - root.rightPadding
583 visible: children.length > 0 && (opacity > 0 || mainContentAnimator.running)
584 opacity: !root.collapsed || showContentWhenCollapsed
585 Behavior on opacity {
587 id: mainContentAnimator
588 duration: Kirigami.
Units.longDuration
589 easing.
type: Easing.InOutQuad
595 Layout.minimumWidth: Kirigami.
Units.smallSpacing
596 Layout.minimumHeight: root.bottomPadding
600 Layout.fillWidth: true
603 if (root.collapsible && root.collapseButtonVisible) {
606 const mirrored = root.edge ===
Qt.RightEdge;
608 if (root.collapsed) {
609 return mirrored ?
"sidebar-expand-right" :
"sidebar-expand-left";
611 return mirrored ?
"sidebar-collapse-right" :
"sidebar-collapse-left";
617 visible: root.collapsible && root.collapseButtonVisible
618 text: root.collapsed ?
"" : qsTr(
"Close Sidebar")
620 onClicked: root.collapsed = !root.collapsed
622 QQC2.
ToolTip.visible: root.collapsed && (Kirigami.Settings.tabletMode ? pressed : hovered)
623 QQC2.
ToolTip.text: qsTr("Open Sidebar")
An item that represents an abstract Action.
Type type(const QSqlDatabase &db)
QStringView level(QStringView ifopt)
QString name(StandardShortcut id)
qsizetype length() const const