9import QtQuick.Controls 2.15 as QQC2
10import QtQuick.Templates 2.15 as T
11import QtQuick.Layouts 1.15
12import Qt.labs.qmlmodels 1.0
13import org.kde.kirigami 2.20 as Kirigami
49 default property alias popupContentItem: scrollView.contentItem
56 property alias text: root.searchField.text
72 property alias delaySearch: root.searchField.delaySearch
85 property alias autoAccept: root.searchField.autoAccept
95 property bool spaceAvailableLeft: true
105 property bool spaceAvailableRight: true
110 property alias fieldFocus: root.searchField.focus
117 property alias popup: popup
119 property Kirigami.SearchField searchField: Kirigami.SearchField {}
122 implicitHeight: root.searchField ? root.searchField.implicitHeight : 0
123 implicitWidth: root.searchField ? root.searchField.implicitWidth : 0
126 children: [root.searchField]
129 when: root.searchField !== null
131 target: root.searchField
132 anchors.left: root.searchField && root.searchField.parent ? root.searchField.parent.left : undefined
133 anchors.right: root.searchField && root.searchField.parent ? root.searchField.parent.right : undefined
136 target: root.searchField ? root.searchField.KeyNavigation : null
137 tab: scrollView.contentItem
138 down: scrollView.contentItem
144 topPadding: undefined
145 leftPadding: undefined
146 rightPadding: undefined
147 bottomPadding: undefined
148 verticalPadding: undefined
149 horizontalPadding: undefined
151 focusPolicy: Qt.NoFocus
152 activeFocusOnTab: true
154 onActiveFocusChanged: {
155 if (searchField && activeFocus) {
156 searchField.forceActiveFocus();
166 onSearchFieldChanged: {
167 __openPopupIfSearchFieldHasActiveFocus();
170 function __handoverChild(child:
Item, oldParent:
Item, newParent:
Item) {
174 child.parent = newParent;
177 function __openPopupIfSearchFieldHasActiveFocus() {
178 if (searchField && searchField.activeFocus && !popup.opened) {
189 if (!popup.visible) {
190 if (typeof popup.Kirigami.OverlayZStacking !==
"undefined") {
191 popup.z = Qt.binding(() => popup.Kirigami.OverlayZStacking.z);
199 function __searchFieldWasAccepted() {
201 if (searchField.text.length > 2) {
204 }
else if (searchField.text.length === 0) {
212 target: root.searchField
214 function onActiveFocusChanged() {
215 root.__openPopupIfSearchFieldHasActiveFocus();
218 function onAccepted() {
219 root.__searchFieldWasAccepted();
226 Component.onCompleted: {
228 if (typeof
Kirigami.OverlayZStacking !==
"undefined") {
230 z =
Qt.binding(() =>
Kirigami.OverlayZStacking.z);
234 readonly
property real collapsedHeight: (root.searchField ? root.searchField.implicitHeight : 0)
235 + topMargin + bottomMargin + topPadding + bottomPadding
239 readonly property real realisticHeight: {
240 const wantedHeight = (root.searchField ? root.searchField.implicitHeight : 0) +
Kirigami.Units.gridUnit * 20;
241 const overlay = root.QQC2.Overlay.overlay;
245 return Math.min(wantedHeight, overlay.height - topMargin - bottomMargin);
248 readonly
property real realisticContentHeight: realisticHeight - topPadding - bottomPadding
252 readonly
property real yOffset: {
253 const overlay = root.QQC2.Overlay.overlay;
257 return Math.max(-root.Kirigami.ScenePosition.y, Math.min(0, overlay.height - root.Kirigami.ScenePosition.y - realisticHeight));
266 leftPadding: dialogRoundedBackground.border.width
267 rightPadding: dialogRoundedBackground.border.width
268 bottomPadding: dialogRoundedBackground.border.width
272 implicitWidth: root.width + leftPadding + rightPadding
273 height: popup.collapsedHeight
276 root.searchField.QQC2.ToolTip.hide();
278 root.__handoverChild(root.searchField, root.contentItem, fieldContainer);
279 root.searchField.forceActiveFocus();
281 root.__handoverChild(root.searchField, fieldContainer, root.contentItem);
286 root.searchField.focus =
false;
290 SequentialAnimation {
294 target: root.searchField.background
297 easing.type: Easing.OutCubic
298 duration:
Kirigami.Units.shortDuration
301 target: dialogRoundedBackground
304 easing.type: Easing.OutCubic
305 duration:
Kirigami.Units.shortDuration
312 easing.type: Easing.OutCubic
313 duration:
Kirigami.Units.longDuration
318 easing.type: Easing.OutCubic
319 duration:
Kirigami.Units.longDuration
320 to: popup.realisticHeight
328 root.searchField.background.opacity = 0;
329 dialogRoundedBackground.opacity = 1;
331 popup.y =
Qt.binding(() => popup.yOffset);
332 popup.height =
Qt.binding(() => popup.realisticHeight);
336 SequentialAnimation {
341 easing.type: Easing.OutCubic
342 duration:
Kirigami.Units.longDuration
347 easing.type: Easing.OutCubic
348 duration:
Kirigami.Units.longDuration
349 to: popup.collapsedHeight
355 target: root.searchField.background
358 easing.type: Easing.OutCubic
359 duration:
Kirigami.Units.shortDuration
362 target: dialogRoundedBackground
365 easing.type: Easing.OutCubic
366 duration:
Kirigami.Units.shortDuration
374 root.searchField.background.opacity = 1;
375 dialogRoundedBackground.opacity = 0;
378 popup.height =
Qt.binding(() => popup.collapsedHeight);
382 id: dialogRoundedBackground
390 layer.
enabled: popup.enter.running || popup.exit.running
391 layer.effect:
Kirigami.ShadowedTexture {
396 radius: dialogRoundedBackground.radius - popup.leftPadding - popup.bottomPadding
405 height: popup.realisticContentHeight
410 implicitWidth: root.searchField ? root.searchField.
implicitWidth : 0
411 implicitHeight: root.searchField ? root.searchField.implicitHeight : 0
412 Layout.fillWidth:
true
416 Layout.fillWidth:
true
425 Layout.fillHeight:
true
426 Layout.fillWidth:
true
Stylish background for dialogs.
QTextStream & left(QTextStream &stream)
QTextStream & right(QTextStream &stream)