8import QtQuick.Controls as QQC2
9import QtQuick.Templates as T
10import org.kde.kirigami as Kirigami
19 property bool displayToolTip: true
25 property T.Drawer drawer
27 readonly property T.Overlay overlay: drawer.T.Overlay.overlay
31 parent: overlay?.parent ?? null
32 z: overlay ? overlay.z + (drawer?.modal && drawer?.drawerOpen ? 1 : - 1) : 0
35 hoverEnabled: handleAnchor?.visible ?? false
38 anchors.centerIn: parent
39 width: parent.height - Kirigami.Units.smallSpacing * 1.5
40 height: parent.height - Kirigami.Units.smallSpacing * 1.5
41 visible: !Kirigami.Settings.tabletMode && !Kirigami.Settings.hasTransientTouchInput
43 Accessible.name: root.drawer.drawerOpen ? root.drawer.handleOpenToolTip : root.drawer.handleClosedToolTip
46 root.displayToolTip = false;
48 root.drawer.drawerOpen = !root.drawer.drawerOpen;
51 Keys.onEscapePressed: {
52 if (root.drawer.closePolicy & T.Popup.CloseOnEscape) {
53 root.drawer.drawerOpen =
false;
58 QQC2.ToolTip.visible: displayToolTip && containsMouse
59 QQC2.ToolTip.text: drawer.drawerOpen ? handleOpenToolTip : handleClosedToolTip
60 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
62 property Item handleAnchor: {
63 if (typeof applicationWindow ===
"undefined") {
66 const window = applicationWindow();
67 const globalToolBar = window.pageStack?.globalToolBar;
71 return (drawer.edge ===
Qt.LeftEdge && !drawer.mirrored) || (drawer.edge ===
Qt.RightEdge && drawer.mirrored)
72 ? globalToolBar.leftHandleAnchor
73 : globalToolBar.rightHandleAnchor;
77 property int mappedStartX
79 enabled: drawer.handleVisible
82 drawer.peeking =
true;
84 mappedStartX = mapToItem(parent, startX, 0).x;
87 onPositionChanged: mouse => {
91 const pos = mapToItem(parent, mouse.x - startX, mouse.y);
92 switch (drawer.edge) {
94 drawer.position = pos.x / drawer.contentItem.width;
97 drawer.position = (drawer.parent.width - pos.x - width) / drawer.contentItem.width;
103 onReleased: mouse => {
104 drawer.peeking =
false;
105 if (Math.abs(mapToItem(parent, mouse.x, 0).x - mappedStartX) <
Qt.styleHints.startDragDistance) {
106 if (!drawer.drawerOpen) {
109 drawer.drawerOpen = !drawer.drawerOpen;
114 drawer.peeking =
false
118 switch (drawer.edge) {
120 return drawer.background.width * drawer.position + Kirigami.Units.smallSpacing;
122 return parent.width - (drawer.background.width * drawer.position) - width - Kirigami.Units.smallSpacing;
129 when: root.handleAnchor && root.anchors.bottom
132 value: root.handleAnchor ? root.handleAnchor.Kirigami.ScenePosition.y : 0
133 restoreMode: Binding.RestoreBinding
137 bottom: handleAnchor ? undefined : parent.bottom
139 if (typeof applicationWindow ===
"undefined") {
142 const window = applicationWindow();
144 let margin = Kirigami.Units.smallSpacing;
146 margin =
window.footer.
height + Kirigami.Units.smallSpacing;
149 if (drawer.parent && drawer.height < drawer.parent.height) {
150 margin = drawer.parent.height - drawer.height - drawer.y + Kirigami.Units.smallSpacing;
153 if (!window || !
window.pageStack ||
154 !
window.pageStack.contentItem ||
155 !
window.pageStack.contentItem.itemAt) {
160 if (
window.pageStack.layers.depth > 1) {
161 item =
window.pageStack.layers.currentItem;
163 item =
window.pageStack.contentItem.itemAt(
window.pageStack.contentItem.contentX + x, 0);
168 item =
window.pageStack.lastItem;
171 let pageFooter = item && item.page ? item.page.footer : (item ? item.footer : undefined);
172 if (pageFooter && drawer.parent) {
173 margin = drawer.height < drawer.parent.height ? margin : margin + pageFooter.height
179 Behavior on bottomMargin {
181 duration: Kirigami.Units.shortDuration
182 easing.type: Easing.InOutQuad
187 visible: drawer.enabled && (drawer.edge ===
Qt.LeftEdge || drawer.edge ===
Qt.RightEdge) && opacity > 0
188 width: handleAnchor?.visible ? handleAnchor.width : Kirigami.
Units.iconSizes.smallMedium + Kirigami.
Units.smallSpacing * 2
189 height: handleAnchor?.visible ? handleAnchor.height : width
190 opacity: drawer.handleVisible ? 1 : 0
192 Behavior on opacity {
194 duration: Kirigami.
Units.longDuration
195 easing.
type: Easing.InOutQuad
200 x: root.drawer.handleVisible ? 0 : (root.drawer.edge ===
Qt.
LeftEdge ? -root.width : root.width)
203 duration: Kirigami.
Units.longDuration
204 easing.
type: !root.drawer.handleVisible ? Easing.OutQuad : Easing.InQuad
Type type(const QSqlDatabase &db)
KGUIADDONS_EXPORT QWindow * window(QObject *job)