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
76 default property alias popupContentItem: scrollView.contentItem
83 property alias text: root.searchField.text
99 property alias delaySearch: root.searchField.delaySearch
112 property alias autoAccept: root.searchField.autoAccept
122 property bool spaceAvailableLeft: true
132 property bool spaceAvailableRight: true
137 property alias fieldFocus: root.searchField.focus
144 property alias popup: popup
146 property Kirigami.SearchField searchField: Kirigami.SearchField {}
149 implicitHeight: root.searchField ? root.searchField.implicitHeight : 0
150 implicitWidth: root.searchField ? root.searchField.implicitWidth : 0
153 children: [root.searchField]
156 when: root.searchField !== null
158 target: root.searchField
159 anchors.left: root.searchField && root.searchField.parent ? root.searchField.parent.left : undefined
160 anchors.right: root.searchField && root.searchField.parent ? root.searchField.parent.right : undefined
163 target: root.searchField ? root.searchField.KeyNavigation : null
164 tab: scrollView.contentItem
165 down: scrollView.contentItem
171 topPadding: undefined
172 leftPadding: undefined
173 rightPadding: undefined
174 bottomPadding: undefined
175 verticalPadding: undefined
176 horizontalPadding: undefined
178 focusPolicy: Qt.NoFocus
179 activeFocusOnTab: true
181 onActiveFocusChanged: {
182 if (searchField && activeFocus) {
183 searchField.forceActiveFocus();
193 onSearchFieldChanged: {
194 __openPopupIfSearchFieldHasActiveFocus();
197 function __handoverChild(child:
Item, oldParent:
Item, newParent:
Item) {
201 child.parent = newParent;
204 function __openPopupIfSearchFieldHasActiveFocus() {
205 if (searchField && searchField.activeFocus && !popup.opened) {
216 if (!popup.visible) {
217 if (typeof popup.Kirigami.OverlayZStacking !==
"undefined") {
218 popup.z =
Qt.binding(() => popup.Kirigami.OverlayZStacking.z);
226 function __searchFieldWasAccepted() {
228 if (searchField.text.length > 2) {
231 }
else if (searchField.text.length === 0) {
239 target: root.searchField
241 function onActiveFocusChanged() {
242 root.__openPopupIfSearchFieldHasActiveFocus();
245 function onAccepted() {
246 root.__searchFieldWasAccepted();
253 Component.onCompleted: {
255 if (typeof
Kirigami.OverlayZStacking !==
"undefined") {
257 z =
Qt.binding(() =>
Kirigami.OverlayZStacking.z);
261 readonly
property real collapsedHeight: (root.searchField ? root.searchField.implicitHeight : 0)
262 + topMargin + bottomMargin + topPadding + bottomPadding
266 readonly property real realisticHeight: {
267 const wantedHeight = (root.searchField ? root.searchField.implicitHeight : 0) +
Kirigami.Units.gridUnit * 20;
268 const overlay = root.QQC2.Overlay.overlay;
272 return Math.min(wantedHeight, overlay.height - topMargin - bottomMargin);
275 readonly
property real realisticContentHeight: realisticHeight - topPadding - bottomPadding
279 readonly
property real yOffset: {
280 const overlay = root.QQC2.Overlay.overlay;
284 return Math.max(-root.Kirigami.ScenePosition.y, Math.min(0, overlay.height - root.Kirigami.ScenePosition.y - realisticHeight));
293 leftPadding: dialogRoundedBackground.border.width
294 rightPadding: dialogRoundedBackground.border.width
295 bottomPadding: dialogRoundedBackground.border.width
299 implicitWidth: root.width + leftPadding + rightPadding
300 height: popup.collapsedHeight
303 root.searchField.QQC2.ToolTip.hide();
305 root.__handoverChild(root.searchField, root.contentItem, fieldContainer);
306 root.searchField.forceActiveFocus();
308 root.__handoverChild(root.searchField, fieldContainer, root.contentItem);
313 root.searchField.focus =
false;
317 SequentialAnimation {
321 target: root.searchField.background
324 easing.type: Easing.OutCubic
325 duration:
Kirigami.Units.shortDuration
328 target: dialogRoundedBackground
331 easing.type: Easing.OutCubic
332 duration:
Kirigami.Units.shortDuration
339 easing.type: Easing.OutCubic
340 duration:
Kirigami.Units.longDuration
345 easing.type: Easing.OutCubic
346 duration:
Kirigami.Units.longDuration
347 to: popup.realisticHeight
355 root.searchField.background.opacity = 0;
356 dialogRoundedBackground.opacity = 1;
358 popup.y =
Qt.binding(() => popup.yOffset);
359 popup.height =
Qt.binding(() => popup.realisticHeight);
363 SequentialAnimation {
368 easing.type: Easing.OutCubic
369 duration:
Kirigami.Units.longDuration
374 easing.type: Easing.OutCubic
375 duration:
Kirigami.Units.longDuration
376 to: popup.collapsedHeight
382 target: root.searchField.background
385 easing.type: Easing.OutCubic
386 duration:
Kirigami.Units.shortDuration
389 target: dialogRoundedBackground
392 easing.type: Easing.OutCubic
393 duration:
Kirigami.Units.shortDuration
401 root.searchField.background.opacity = 1;
402 dialogRoundedBackground.opacity = 0;
405 popup.height =
Qt.binding(() => popup.collapsedHeight);
409 id: dialogRoundedBackground
417 layer.enabled: popup.enter.running || popup.exit.running
418 layer.effect:
Kirigami.ShadowedTexture {
423 radius: dialogRoundedBackground.radius - popup.leftPadding - popup.bottomPadding
432 height: popup.realisticContentHeight
437 implicitWidth: root.searchField ? root.searchField.implicitWidth : 0
438 implicitHeight: root.searchField ? root.searchField.implicitHeight : 0
439 Layout.fillWidth:
true
443 Layout.fillWidth:
true
452 Layout.fillHeight:
true
453 Layout.fillWidth:
true
Stylish background for dialogs.
QTextStream & left(QTextStream &stream)
QTextStream & right(QTextStream &stream)