9import QtQuick.Controls as QQC2
10import QtQuick.Templates as T
11import org.kde.kirigami as Kirigami
39 Kirigami.OverlayZStacking.layer: Kirigami.OverlayZStacking.FullScreen
40 z: Kirigami.OverlayZStacking.z
42 Kirigami.Theme.colorSet: Kirigami.Theme.View
43 Kirigami.Theme.inherit: false
58 property bool showCloseButton: !Kirigami.Settings.isMobile
64 property Item header: Kirigami.Heading {
67 elide: Text.ElideRight
70 T.ToolTip.visible: truncated && titleHoverHandler.hovered
71 T.ToolTip.text: root.title
83 default property alias flickableContentData: scrollView.contentData
87 T.Overlay.modeless: Item {
90 x: sheetHandler.visualParent?.Kirigami.ScenePosition.x ?? 0
91 y: sheetHandler.visualParent?.Kirigami.ScenePosition.y ?? 0
92 width: sheetHandler.visualParent?.width ?? 0
93 height: sheetHandler.visualParent?.height ?? 0
94 color: Qt.rgba(0, 0, 0, 0.2)
99 easing.type: Easing.InOutQuad
100 duration: Kirigami.Units.longDuration
113 closePolicy: T.Popup.CloseOnEscape
114 x: parent ? Math.round(parent.width / 2 - width / 2) : 0
119 const visualParentAdjust = sheetHandler.visualParent?.y ?? 0;
120 const wantedPosition = parent.height / 2 - implicitHeight / 2;
121 return Math.round(Math.max(visualParentAdjust, wantedPosition, Kirigami.Units.gridUnit * 3));
125 let width = parent?.width ?? 0;
126 if (!scrollView.itemForSizeHints) {
128 }
else if (scrollView.itemForSizeHints.Layout.preferredWidth > 0) {
129 return Math.min(width, scrollView.itemForSizeHints.Layout.preferredWidth);
130 }
else if (scrollView.itemForSizeHints.implicitWidth > 0) {
131 return Math.min(width, scrollView.itemForSizeHints.implicitWidth);
137 let h = parent?.height ?? 0;
138 if (!scrollView.itemForSizeHints) {
140 }
else if (scrollView.itemForSizeHints.Layout.preferredHeight > 0) {
141 h = scrollView.itemForSizeHints.Layout.preferredHeight;
142 }
else if (scrollView.itemForSizeHints.implicitHeight > 0) {
143 h = scrollView.itemForSizeHints.implicitHeight + Kirigami.Units.largeSpacing * 2;
144 }
else if (scrollView.itemForSizeHints instanceof Flickable && scrollView.itemForSizeHints.contentHeight > 0) {
145 h = scrollView.itemForSizeHints.contentHeight + Kirigami.Units.largeSpacing * 2;
147 h = scrollView.itemForSizeHints.height;
149 h += headerItem.implicitHeight + footerParent.implicitHeight + topPadding + bottomPadding;
150 return Math.min(h, parent.height - y)
156 const flickable = scrollView.contentItem;
157 flickable.contentY = flickable.originY - flickable.topMargin;
160 Component.onCompleted: {
162 if (!root.parent && typeof applicationWindow !==
"undefined") {
163 root.parent = applicationWindow().overlay
170 function onVisibleChanged() {
171 if (!parent.visible) {
179 contentItem: MouseArea {
180 implicitWidth: mainLayout.implicitWidth
181 implicitHeight: mainLayout.implicitHeight
182 Kirigami.Theme.colorSet: root.Kirigami.Theme.colorSet
183 Kirigami.Theme.inherit:
false
185 property real scenePressY
187 property bool dragStarted
188 drag.filterChildren:
true
193 acceptedDevices: PointerDevice.Mouse
196 parent.dragStarted =
false;
201 onPressed: mouse => {
202 scenePressY = mapToItem(null, mouse.x, mouse.y).y;
206 onPositionChanged: mouse => {
207 if (mouseDragBlocker.active) {
210 const currentY = mapToItem(null, mouse.x, mouse.y).y;
212 if (dragStarted && currentY !== lastY) {
213 translation.y += currentY - lastY;
215 if (Math.abs(currentY - scenePressY) >
Qt.styleHints.startDragDistance) {
220 onCanceled: restoreAnim.restart();
221 onReleased: mouse => {
222 if (mouseDragBlocker.active) {
225 if (Math.abs(mapToItem(null, mouse.x, mouse.y).y - scenePressY) > Kirigami.Units.gridUnit * 5) {
228 restoreAnim.restart();
241 Kirigami.ShadowedRectangle {
243 Layout.fillWidth:
true
244 Layout.alignment:
Qt.AlignTop
246 visible: root.header || root.showCloseButton
247 implicitHeight: Math.max(headerParent.implicitHeight, closeIcon.height) + Kirigami.Units.smallSpacing * 2
249 corners.topLeftRadius: Kirigami.Units.smallSpacing
250 corners.topRightRadius: Kirigami.Units.smallSpacing
251 Kirigami.Theme.colorSet: Kirigami.Theme.Header
252 Kirigami.Theme.inherit:
false
253 color: Kirigami.Theme.backgroundColor
258 readonly
property real leadingPadding: Kirigami.Units.largeSpacing
259 readonly
property real trailingPadding: (root.showCloseButton ? closeIcon.width : 0) + Kirigami.Units.smallSpacing
262 verticalPadding: Kirigami.
Units.smallSpacing
263 leftPadding: root.mirrored ? trailingPadding : leadingPadding
264 rightPadding: root.mirrored ? leadingPadding : trailingPadding
266 contentItem: root.header
271 readonly property bool tallHeader: headerItem.height > (Kirigami.
Units.iconSizes.smallMedium + Kirigami.
Units.largeSpacing + Kirigami.
Units.largeSpacing)
275 rightMargin: Kirigami.
Units.largeSpacing
276 verticalCenter: headerItem.verticalCenter
277 margins: Kirigami.
Units.smallSpacing
282 onTallHeaderChanged: {
285 anchors.verticalCenter = undefined
286 anchors.topMargin = Kirigami.Units.largeSpacing
287 anchors.top = headerItem.top
290 anchors.top = undefined
291 anchors.topMargin = undefined
292 anchors.verticalCenter = headerItem.verticalCenter
295 Component.onCompleted: tallHeaderChanged()
298 visible: root.showCloseButton
299 width: Kirigami.
Units.iconSizes.smallMedium
301 source: closeMouseArea.containsMouse ? "window-close" : "window-close-symbolic"
302 active: closeMouseArea.containsMouse
307 onClicked: root.close();
322 Layout.fillWidth:
true
323 Layout.fillHeight:
true
325 T.ScrollBar.horizontal.policy: T.ScrollBar.AlwaysOff
327 property bool initialized:
false
328 property Item itemForSizeHints
331 contentWidth: initialized ? contentItem.
width : width
332 contentHeight: itemForSizeHints?.implicitHeight ?? 0
334 onContentItemChanged: {
336 const flickable = contentItem as Flickable;
337 flickable.boundsBehavior = Flickable.StopAtBounds;
338 if ((flickable instanceof ListView) || (flickable instanceof
GridView)) {
339 itemForSizeHints = flickable;
342 const content = flickable.contentItem;
343 content.childrenChanged.connect(() => {
344 for (
const item of content.children) {
345 item.anchors.margins = Kirigami.Units.largeSpacing;
346 item.anchors.top = content.top;
347 item.anchors.left = content.left;
348 item.anchors.right = content.right;
350 itemForSizeHints = content.children?.[0] ?? null;
357 Layout.fillWidth:
true
358 visible: footerParent.visible
362 Layout.fillWidth:
true
363 padding: Kirigami.Units.smallSpacing
364 contentItem: root.footer
365 visible: contentItem !== null
373 readonly
property Item visualParent: root.
parent?.contentItem ?? root.parent
377 width: visualParent?.width ?? 0
378 height: (visualParent?.height ?? 0) * 2
380 property var pressPos
381 onPressed: mouse => {
382 pressPos = mapToItem(null, mouse.x, mouse.y)
384 onReleased: mouse => {
387 let pos = mapToItem(null, mouse.x, mouse.y)
388 if (Math.abs(pos.x - pressPos.x) + Math.abs(pos.y - pressPos.y) <
Qt.styleHints.startDragDistance) {
399 easing.type: Easing.InOutQuad
400 duration: Kirigami.Units.longDuration
402 Component.onCompleted: {
403 root.contentItem.parent.transform = translation
404 root.contentItem.parent.clip =
false
417 easing.type: Easing.InOutQuad
418 duration: Kirigami.Units.longDuration
423 from: Kirigami.Units.gridUnit * 5
425 easing.type: Easing.InOutQuad
426 duration: Kirigami.Units.longDuration
437 easing.type: Easing.InOutQuad
438 duration: Kirigami.Units.longDuration
444 to: translation.y >= 0 ? translation.y + Kirigami.Units.gridUnit * 5 : translation.y - Kirigami.Units.gridUnit * 5
445 easing.type: Easing.InOutQuad
446 duration: Kirigami.Units.longDuration
QTextStream & left(QTextStream &stream)
QTextStream & right(QTextStream &stream)