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));
120 let width = parent?.width ?? 0;
121 if (!scrollView.itemForSizeHints) {
123 }
else if (scrollView.itemForSizeHints.Layout.preferredWidth > 0) {
124 return Math.min(width, scrollView.itemForSizeHints.Layout.preferredWidth);
125 }
else if (scrollView.itemForSizeHints.implicitWidth > 0) {
126 return Math.min(width, scrollView.itemForSizeHints.implicitWidth);
132 let h = parent?.height ?? 0;
133 if (!scrollView.itemForSizeHints) {
135 }
else if (scrollView.itemForSizeHints.Layout.preferredHeight > 0) {
136 h = scrollView.itemForSizeHints.Layout.preferredHeight;
137 }
else if (scrollView.itemForSizeHints.implicitHeight > 0) {
138 h = scrollView.itemForSizeHints.implicitHeight + Kirigami.Units.largeSpacing * 2;
139 }
else if (scrollView.itemForSizeHints instanceof Flickable && scrollView.itemForSizeHints.contentHeight > 0) {
140 h = scrollView.itemForSizeHints.contentHeight + Kirigami.Units.largeSpacing * 2;
142 h = scrollView.itemForSizeHints.height;
144 h += headerItem.implicitHeight + footerParent.implicitHeight + topPadding + bottomPadding;
145 return parent ? Math.min(h, parent.height - y) : h
151 const flickable = scrollView.contentItem;
152 flickable.contentY = flickable.originY - flickable.topMargin;
155 Component.onCompleted: {
157 if (!root.parent && typeof applicationWindow !==
"undefined") {
158 root.parent = applicationWindow().overlay
165 function onVisibleChanged() {
166 if (!parent.visible) {
174 contentItem: MouseArea {
175 implicitWidth: mainLayout.implicitWidth
176 implicitHeight: mainLayout.implicitHeight
177 Kirigami.Theme.colorSet: root.Kirigami.Theme.colorSet
178 Kirigami.Theme.inherit:
false
180 property real scenePressY
182 property bool dragStarted
183 drag.filterChildren:
true
188 acceptedDevices: PointerDevice.Mouse
191 parent.dragStarted =
false;
196 onPressed: mouse => {
197 scenePressY = mapToItem(null, mouse.x, mouse.y).y;
201 onPositionChanged: mouse => {
202 if (mouseDragBlocker.active) {
205 const currentY = mapToItem(null, mouse.x, mouse.y).y;
207 if (dragStarted && currentY !== lastY) {
208 translation.y += currentY - lastY;
210 if (Math.abs(currentY - scenePressY) >
Qt.styleHints.startDragDistance) {
215 onCanceled: restoreAnim.restart();
216 onReleased: mouse => {
217 if (mouseDragBlocker.active) {
220 if (Math.abs(mapToItem(null, mouse.x, mouse.y).y - scenePressY) > Kirigami.Units.gridUnit * 5) {
223 restoreAnim.restart();
238 Layout.fillWidth:
true
239 Layout.alignment:
Qt.AlignTop
241 visible: root.header || root.showCloseButton
242 implicitHeight: Math.max(headerParent.implicitHeight, closeIcon.height)
248 horizontalCenter: parent.horizontalCenter
249 topMargin: Kirigami.Units.smallSpacing
251 width: Math.round(Kirigami.Units.gridUnit * 3)
252 height: Math.round(Kirigami.Units.gridUnit / 4)
254 color: Kirigami.Theme.textColor
256 visible: Kirigami.Settings.hasTransientTouchInput
261 readonly
property real leadingPadding: Kirigami.Units.largeSpacing
262 readonly
property real trailingPadding: (root.showCloseButton ? closeIcon.width : 0) + Kirigami.Units.smallSpacing
265 verticalPadding: Kirigami.
Units.largeSpacing
266 leftPadding: root.mirrored ? trailingPadding : leadingPadding
267 rightPadding: root.mirrored ? leadingPadding : trailingPadding
269 contentItem: root.header
277 readonly property bool tallHeader: parent.height > (Kirigami.
Units.iconSizes.smallMedium + Kirigami.
Units.largeSpacing * 2)
279 Layout.topMargin: tallHeader ? Kirigami.
Units.largeSpacing : 0
281 verticalCenter: !tallHeader ? undefined : parent.verticalCenter
283 margins: Kirigami.
Units.largeSpacing
287 visible: root.showCloseButton
288 icon.
name: closeIcon.hovered ?
"window-close" :
"window-close-symbolic"
289 text: qsTr(
"Close",
"@action:button close dialog")
290 onClicked: root.
close()
291 display: QQC2.AbstractButton.IconOnly
299 visible: scrollView.T.
ScrollBar.vertical.visible
306 Layout.fillWidth: true
307 Layout.fillHeight: true
311 property bool initialized: false
312 property
Item itemForSizeHints
315 contentWidth: initialized ? contentItem.width : width
316 contentHeight: itemForSizeHints?.implicitHeight ?? 0
318 onContentItemChanged: {
320 const flickable = contentItem as Flickable;
321 flickable.boundsBehavior = Flickable.StopAtBounds;
322 if ((flickable instanceof ListView) || (flickable instanceof
GridView)) {
323 itemForSizeHints = flickable;
326 const content = flickable.contentItem;
327 content.childrenChanged.
connect(() => {
328 for (
const item of content.children) {
329 item.anchors.margins = Kirigami.Units.largeSpacing;
330 item.anchors.top = content.top;
331 item.anchors.left = content.left;
332 item.anchors.right = content.right;
334 itemForSizeHints = content.children?.[0] ?? null;
341 Layout.fillWidth:
true
342 visible: footerParent.visible
346 Layout.fillWidth:
true
347 padding: Kirigami.Units.smallSpacing
348 contentItem: root.footer
349 visible: contentItem !== null
357 readonly
property Item visualParent: root.
parent?.contentItem ?? root.parent
361 width: visualParent?.width ?? 0
362 height: (visualParent?.height ?? 0) * 2
364 property var pressPos
365 onPressed: mouse => {
366 pressPos = mapToItem(null, mouse.x, mouse.y)
368 onReleased: mouse => {
371 let pos = mapToItem(null, mouse.x, mouse.y)
372 if (Math.abs(pos.x - pressPos.x) + Math.abs(pos.y - pressPos.y) <
Qt.styleHints.startDragDistance) {
383 easing.type: Easing.InOutQuad
384 duration: Kirigami.Units.longDuration
386 Component.onCompleted: {
387 root.contentItem.parent.transform = translation
388 root.contentItem.parent.clip =
false
401 easing.type: Easing.InOutQuad
402 duration: Kirigami.Units.longDuration
407 from: Kirigami.Units.gridUnit * 5
409 easing.type: Easing.InOutQuad
410 duration: Kirigami.Units.longDuration
421 easing.type: Easing.InOutQuad
422 duration: Kirigami.Units.longDuration
428 to: translation.y >= 0 ? translation.y + Kirigami.Units.gridUnit * 5 : translation.y - Kirigami.Units.gridUnit * 5
429 easing.type: Easing.InOutQuad
430 duration: Kirigami.Units.longDuration
QString name(GameStandardAction id)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QTextStream & left(QTextStream &stream)
QTextStream & right(QTextStream &stream)