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
174 property alias topContent: topContent.
data
198 default property alias content: mainContent.data
212 property bool showTopContentWhenCollapsed:
false
227 property bool showContentWhenCollapsed:
false
230 property bool showHeaderWhenCollapsed:
false
240 property bool resetMenuOnTriggered:
true
245 readonly
property T.Action currentSubMenu: stackView.currentItem?.current ?? null
254 property bool isMenu:
false
264 property bool collapseButtonVisible:
true
270 function resetMenu() {
271 stackView.pop(stackView.get(0, T.StackView.DontLoad));
273 root.drawerOpen =
false;
279 Kirigami.Theme.colorSet: modal ? Kirigami.Theme.Window : Kirigami.Theme.View
281 onIsMenuChanged: drawerOpen =
false
287 property alias model: actionsRepeater.model
288 property T.Action current
289 property int level: 0
292 Layout.maximumHeight: Layout.minimumHeight
299 icon.name: mirrored ?
"go-previous-symbolic-rtl" :
"go-previous-symbolic"
301 text: Kirigami.MnemonicData.richTextLabel
302 activeFocusOnTab:
true
304 Kirigami.MnemonicData.enabled: enabled && visible
305 Kirigami.MnemonicData.controlType: Kirigami.MnemonicData.MenuItem
306 Kirigami.MnemonicData.label: qsTr(
"Back")
308 onClicked: stackView.pop()
310 Keys.onEnterPressed: stackView.pop()
311 Keys.onReturnPressed: stackView.pop()
313 Keys.onDownPressed: nextItemInFocusChain().focus = true
314 Keys.onUpPressed: nextItemInFocusChain(false).focus = true
318 sequence: backItem.Kirigami.MnemonicData.sequence
319 onActivated: backItem.clicked()
325 readonly
property bool withSections: {
326 for (
const action of root.actions) {
327 if (action.hasOwnProperty(
"expandible") && action.expandible) {
336 delegate: ActionDelegate {
337 required
property T.Action modelData
340 withSections: actionsRepeater.withSections
346 component ActionDelegate : Column {
349 required
property int index
350 required
property T.Action tAction
351 required
property bool withSections
354 readonly
property Kirigami.Action kAction: tAction instanceof Kirigami.Action ? tAction : null
356 readonly
property bool isExpanded: {
357 return !root.collapsed
359 && kAction.expandible
360 && kAction.children.length > 0;
363 visible: kAction?.visible ??
true
367 KP.GlobalDrawerActionItem {
368 Kirigami.Theme.colorSet: !root.modal && !root.collapsed && delegate.withSections
369 ? Kirigami.Theme.Window : parent.Kirigami.Theme.colorSet
371 visible: !delegate.isExpanded
374 tAction: delegate.tAction
378 if (checked && topContent.height + backItem.height + (delegate.index + 1) * height - mainFlickable.contentY > mainFlickable.height) {
379 mainFlickable.contentY += height
387 visible: delegate.isExpanded
388 height: sectionHeader.implicitHeight
391 Kirigami.ListSectionHeader {
395 Kirigami.Theme.colorSet: root.modal ? Kirigami.Theme.View : Kirigami.Theme.Window
397 contentItem: RowLayout {
398 spacing: sectionHeader.spacing
401 property int size: Kirigami.Units.iconSizes.smallMedium
402 Layout.minimumHeight: size
403 Layout.maximumHeight: size
404 Layout.minimumWidth: size
405 Layout.maximumWidth: size
406 source: delegate.tAction.icon.name || delegate.tAction.icon.source
411 text: delegate.tAction.text
412 elide: Text.ElideRight
413 Layout.fillWidth:
true
420 model: delegate.isExpanded ? (delegate.kAction?.children ?? null) : null
422 NestedActionDelegate {
423 required property T.
Action modelData
426 withSections: delegate.withSections
431 component NestedActionDelegate : KP.GlobalDrawerActionItem {
432 required property bool withSections
435 opacity: !root.collapsed
436 leftPadding: withSections && !root.collapsed && !root.modal ? padding * 2 : padding * 4
444 topMargin: root.collapsed && !showHeaderWhenCollapsed ? -contentItem.y : 0
447 Behavior on anchors.topMargin {
449 duration: Kirigami.
Units.longDuration
450 easing.
type: Easing.InOutQuad
455 visible: root.title.length > 0 ||
Boolean(root.titleIcon)
456 spacing: Kirigami.
Units.largeSpacing
459 source: root.titleIcon
465 visible: !root.collapsed
466 Layout.fillWidth: true
474 Kirigami.Theme.inherit: true
479 implicitWidth: Math.min(Kirigami.
Units.gridUnit * 20, root.parent.width * 0.8)
485 contentHeight: mainColumn.Layout.minimumHeight
487 clip: (mainLayout.header?.visible ?? false) || (mainLayout.footer?.visible ?? false)
491 width: mainFlickable.width
493 height: Math.max(scrollView.height, Layout.minimumHeight)
501 Layout.leftMargin: root.leftPadding
502 Layout.rightMargin: root.rightPadding
503 Layout.bottomMargin: Kirigami.
Units.smallSpacing
504 Layout.topMargin: root.topPadding
505 Layout.fillWidth: true
506 Layout.fillHeight: true
507 Layout.preferredHeight: implicitHeight * opacity
510 Layout.minimumWidth: parent.width - root.leftPadding - root.rightPadding
512 visible: children.length > 0 && childrenRect.height > 0 && opacity > 0
513 opacity: !root.collapsed || showTopContentWhenCollapsed
515 Behavior on opacity {
518 duration: Kirigami.
Units.longDuration
519 easing.
type: Easing.InOutQuad
527 property KP.ActionsMenu openSubMenu
530 Layout.fillWidth: true
531 Layout.minimumHeight: currentItem ? currentItem.implicitHeight : 0
532 Layout.maximumHeight: Layout.minimumHeight
534 initialItem: menuComponent
539 popEnter: Transition {
540 NumberAnimation { property:
"x"; from: (stackView.mirrored ? -1 : 1) * -stackView.width; to: 0; duration: Kirigami.Units.veryLongDuration; easing.type: Easing.OutCubic }
543 popExit: Transition {
544 NumberAnimation { property:
"x"; from: 0; to: (stackView.mirrored ? -1 : 1) * stackView.width; duration: Kirigami.Units.veryLongDuration; easing.type: Easing.OutCubic }
547 pushEnter: Transition {
548 NumberAnimation { property:
"x"; from: (stackView.mirrored ? -1 : 1) * stackView.width; to: 0; duration: Kirigami.Units.veryLongDuration; easing.type: Easing.OutCubic }
551 pushExit: Transition {
552 NumberAnimation { property:
"x"; from: 0; to: (stackView.mirrored ? -1 : 1) * -stackView.width; duration: Kirigami.Units.veryLongDuration; easing.type: Easing.OutCubic }
555 replaceEnter: Transition {
556 NumberAnimation { property:
"x"; from: (stackView.mirrored ? -1 : 1) * stackView.width; to: 0; duration: Kirigami.Units.veryLongDuration; easing.type: Easing.OutCubic }
559 replaceExit: Transition {
560 NumberAnimation { property:
"x"; from: 0; to: (stackView.mirrored ? -1 : 1) * -stackView.width; duration: Kirigami.Units.veryLongDuration; easing.type: Easing.OutCubic }
565 Layout.fillWidth:
true
566 Layout.fillHeight: root.actions.length > 0
567 Layout.minimumHeight: Kirigami.Units.smallSpacing
572 Layout.alignment:
Qt.AlignHCenter
573 Layout.leftMargin: root.leftPadding
574 Layout.rightMargin: root.rightPadding
575 Layout.fillWidth:
true
576 Layout.fillHeight:
true
579 Layout.minimumWidth: parent.width - root.leftPadding - root.rightPadding
580 visible: children.length > 0 && (opacity > 0 || mainContentAnimator.running)
581 opacity: !root.collapsed || showContentWhenCollapsed
582 Behavior on opacity {
584 id: mainContentAnimator
585 duration: Kirigami.
Units.longDuration
586 easing.
type: Easing.InOutQuad
592 Layout.minimumWidth: Kirigami.
Units.smallSpacing
593 Layout.minimumHeight: root.bottomPadding
597 Layout.fillWidth: true
600 if (root.collapsible && root.collapseButtonVisible) {
603 const mirrored = root.edge ===
Qt.RightEdge;
605 if (root.collapsed) {
606 return mirrored ?
"sidebar-expand-right" :
"sidebar-expand-left";
608 return mirrored ?
"sidebar-collapse-right" :
"sidebar-collapse-left";
614 visible: root.collapsible && root.collapseButtonVisible
615 text: root.collapsed ?
"" : qsTr(
"Close Sidebar")
617 onClicked: root.collapsed = !root.collapsed
619 QQC2.ToolTip.visible: root.collapsed && (Kirigami.Settings.tabletMode ? pressed : hovered)
620 QQC2.ToolTip.text: qsTr("Open Sidebar")
621 QQC2.ToolTip.delay: Kirigami.
Units.toolTipDelay
An item that represents an abstract Action.
A heading label used for subsections of texts.
Class for rendering an icon in UI.
Type type(const QSqlDatabase &db)
QStringView level(QStringView ifopt)
QString name(StandardAction id)