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 verticalAlignment: Text.AlignVCenter
68 elide: Text.ElideRight
71 T.ToolTip.visible: truncated && titleHoverHandler.hovered
72 T.ToolTip.text: root.title
84 default property alias flickableContentData: scrollView.contentData
88 QQC2.Overlay.modal: Rectangle {
89 color: Qt.rgba(0, 0, 0, 0.3)
94 duration: Kirigami.Units.longDuration
95 easing.type: Easing.InOutQuad
108 closePolicy: T.Popup.CloseOnEscape
109 x: parent ? Math.round(parent.width / 2 - width / 2) : 0
114 const visualParentAdjust = sheetHandler.visualParent?.y ?? 0;
115 const wantedPosition = parent.height / 2 - implicitHeight / 2;
116 return Math.round(Math.max(visualParentAdjust, wantedPosition, Kirigami.Units.gridUnit * 3));
119 width: root.parent ? Math.min(root.parent.width, implicitWidth) : implicitWidth
121 let width = parent?.width ?? 0;
122 if (!scrollView.itemForSizeHints) {
124 }
else if (scrollView.itemForSizeHints.Layout.preferredWidth > 0) {
125 return Math.min(width, scrollView.itemForSizeHints.Layout.preferredWidth);
126 }
else if (scrollView.itemForSizeHints.implicitWidth > 0) {
127 return Math.min(width, scrollView.itemForSizeHints.implicitWidth);
133 let h = parent?.height ?? 0;
134 if (!scrollView.itemForSizeHints) {
136 }
else if (scrollView.itemForSizeHints.Layout.preferredHeight > 0) {
137 h = scrollView.itemForSizeHints.Layout.preferredHeight;
138 }
else if (scrollView.itemForSizeHints.implicitHeight > 0) {
139 h = scrollView.itemForSizeHints.implicitHeight + Kirigami.Units.largeSpacing * 2;
140 }
else if (scrollView.itemForSizeHints instanceof Flickable && scrollView.itemForSizeHints.contentHeight > 0) {
141 h = scrollView.itemForSizeHints.contentHeight + Kirigami.Units.largeSpacing * 2;
143 h = scrollView.itemForSizeHints.height;
145 h += headerItem.implicitHeight + footerParent.implicitHeight + topPadding + bottomPadding;
146 return parent ? Math.min(h, parent.height - y) : h
152 const flickable = scrollView.contentItem;
153 flickable.contentY = flickable.originY - flickable.topMargin;
156 Component.onCompleted: {
158 if (!root.parent && typeof applicationWindow !==
"undefined") {
159 root.parent = applicationWindow().overlay
166 function onVisibleChanged() {
167 if (!parent.visible) {
175 contentItem: MouseArea {
176 implicitWidth: mainLayout.implicitWidth
177 implicitHeight: mainLayout.implicitHeight
178 Kirigami.Theme.colorSet: root.Kirigami.Theme.colorSet
179 Kirigami.Theme.inherit:
false
181 property real scenePressY
183 property bool dragStarted
184 drag.filterChildren:
true
189 acceptedDevices: PointerDevice.Mouse
192 parent.dragStarted =
false;
197 onPressed: mouse => {
198 scenePressY = mapToItem(null, mouse.x, mouse.y).y;
202 onPositionChanged: mouse => {
203 if (mouseDragBlocker.active) {
206 const currentY = mapToItem(null, mouse.x, mouse.y).y;
208 if (dragStarted && currentY !== lastY) {
209 translation.y += currentY - lastY;
211 if (Math.abs(currentY - scenePressY) >
Qt.styleHints.startDragDistance) {
216 onCanceled: restoreAnim.restart();
217 onReleased: mouse => {
218 if (mouseDragBlocker.active) {
221 if (Math.abs(mapToItem(null, mouse.x, mouse.y).y - scenePressY) > Kirigami.Units.gridUnit * 5) {
224 restoreAnim.restart();
239 Layout.fillWidth:
true
240 Layout.alignment:
Qt.AlignTop
242 visible: root.header || root.showCloseButton
243 implicitHeight: Math.max(headerParent.implicitHeight, closeIcon.height)
249 horizontalCenter: parent.horizontalCenter
250 topMargin: Kirigami.Units.smallSpacing
252 width: Math.round(Kirigami.Units.gridUnit * 3)
253 height: Math.round(Kirigami.Units.gridUnit / 4)
255 color: Kirigami.Theme.textColor
257 visible: Kirigami.Settings.hasTransientTouchInput
262 readonly
property real leadingPadding: Kirigami.Units.largeSpacing
263 readonly
property real trailingPadding: (root.showCloseButton ? closeIcon.width : 0) + Kirigami.Units.smallSpacing
266 verticalPadding: Kirigami.
Units.largeSpacing
267 leftPadding: root.mirrored ? trailingPadding : leadingPadding
268 rightPadding: root.mirrored ? leadingPadding : trailingPadding
270 contentItem: root.header
278 readonly property bool tallHeader: parent.height > (Kirigami.
Units.iconSizes.smallMedium + Kirigami.
Units.largeSpacing * 2)
280 Layout.topMargin: tallHeader ? Kirigami.
Units.largeSpacing : 0
282 verticalCenter: !tallHeader ? undefined : parent.verticalCenter
284 margins: Kirigami.
Units.largeSpacing
288 visible: root.showCloseButton
289 icon.
name: closeIcon.hovered ?
"window-close" :
"window-close-symbolic"
290 text: qsTr(
"Close",
"@action:button close dialog")
291 onClicked: root.
close()
292 display: QQC2.AbstractButton.IconOnly
300 visible: scrollView.T.
ScrollBar.vertical.visible
307 Layout.fillWidth: true
308 Layout.fillHeight: true
312 property bool initialized: false
313 property
Item itemForSizeHints
316 contentWidth: initialized ? contentItem.width : width
317 contentHeight: itemForSizeHints?.implicitHeight ?? 0
319 onContentItemChanged: {
321 const flickable = contentItem as Flickable;
322 flickable.boundsBehavior = Flickable.StopAtBounds;
323 if ((flickable instanceof ListView) || (flickable instanceof
GridView)) {
324 itemForSizeHints = flickable;
327 const content = flickable.contentItem;
328 content.childrenChanged.
connect(() => {
329 for (
const item of content.children) {
330 item.anchors.margins = Kirigami.Units.largeSpacing;
331 item.anchors.top = content.top;
332 item.anchors.left = content.left;
333 item.anchors.right = content.right;
335 itemForSizeHints = content.children?.[0] ?? null;
342 Layout.fillWidth:
true
343 visible: footerParent.visible
347 Layout.fillWidth:
true
348 padding: Kirigami.Units.smallSpacing
349 contentItem: root.footer
350 visible: contentItem !== null
358 readonly
property Item visualParent: root.
parent?.contentItem ?? root.parent
362 width: visualParent?.width ?? 0
363 height: (visualParent?.height ?? 0) * 2
365 property var pressPos
366 onPressed: mouse => {
367 pressPos = mapToItem(null, mouse.x, mouse.y)
369 onReleased: mouse => {
372 let pos = mapToItem(null, mouse.x, mouse.y)
373 if (Math.abs(pos.x - pressPos.x) + Math.abs(pos.y - pressPos.y) <
Qt.styleHints.startDragDistance) {
384 easing.type: Easing.InOutQuad
385 duration: Kirigami.Units.longDuration
387 Component.onCompleted: {
388 root.contentItem.parent.transform = translation
389 root.contentItem.parent.clip =
false
402 easing.type: Easing.InOutQuad
403 duration: Kirigami.Units.longDuration
408 from: Kirigami.Units.gridUnit * 5
410 easing.type: Easing.InOutQuad
411 duration: Kirigami.Units.longDuration
422 easing.type: Easing.InOutQuad
423 duration: Kirigami.Units.longDuration
429 to: translation.y >= 0 ? translation.y + Kirigami.Units.gridUnit * 5 : translation.y - Kirigami.Units.gridUnit * 5
430 easing.type: Easing.InOutQuad
431 duration: Kirigami.Units.longDuration
QString name(StandardAction id)
const QList< QKeySequence > & close()
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QTextStream & left(QTextStream &stream)
QTextStream & right(QTextStream &stream)