9import QtQuick.Controls as QQC2
10import org.kde.kirigami as Kirigami
11import org.kde.kirigami.templates as KT
82 property bool refreshing:
false
89 property bool supportsRefreshing:
false
95 property Flickable flickable: Flickable {}
96 onFlickableChanged: scrollView.contentItem = flickable;
102 property int verticalScrollBarPolicy
108 property bool verticalScrollBarInteractive:
true
114 property int horizontalScrollBarPolicy: QQC2.ScrollBar.AlwaysOff
120 property bool horizontalScrollBarInteractive:
true
122 default property alias scrollablePageData: itemsParent.data
123 property alias scrollablePageChildren: itemsParent.children
128 property QtObject mainItem
130 print(
"Warning: the mainItem property is deprecated");
131 scrollablePageData.push(mainItem);
143 property bool keyboardNavigationEnabled:
true
146 implicitWidth: flickable?.contentItem?.implicitWidth
147 ?? Math.max(implicitBackgroundWidth + leftInset + rightInset,
148 contentWidth + leftPadding + rightPadding,
152 implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
153 contentHeight + topPadding + bottomPadding
154 + (implicitHeaderHeight > 0 ? implicitHeaderHeight + spacing : 0)
155 + (implicitFooterHeight > 0 ? implicitFooterHeight + spacing : 0))
157 contentHeight: flickable?.contentHeight ?? 0
159 Kirigami.Theme.inherit:
false
160 Kirigami.Theme.colorSet: flickable?.hasOwnProperty(
"model") ? Kirigami.Theme.View : Kirigami.Theme.Window
163 if (root.keyboardNavigationEnabled && root.flickable) {
164 if ((
"currentItem" in root.flickable) && root.flickable.currentItem) {
165 return [ root.flickable.currentItem, root.flickable ];
167 return [ root.flickable ];
174 contentItem: QQC2.ScrollView {
177 top: root.header?.visible
180 bottom: root.footer?.visible ? root.footer.top : parent.bottom
185 QQC2.ScrollBar.horizontal.policy: root.horizontalScrollBarPolicy
186 QQC2.ScrollBar.horizontal.interactive: root.horizontalScrollBarInteractive
187 QQC2.ScrollBar.vertical.policy: root.verticalScrollBarPolicy
188 QQC2.ScrollBar.vertical.interactive: root.verticalScrollBarInteractive
195 width: root.horizontalScrollBarPolicy === QQC2.ScrollBar.AlwaysOff ? root.flickable.width : Math.max(root.flickable.width, implicitWidth)
196 height: Math.max(root.flickable.height, implicitHeight)
199 for (
const child of itemsParent.visibleChildren) {
200 if (child.implicitWidth <= 0) {
201 implicit = Math.max(implicit, child.width);
203 implicit = Math.max(implicit, child.implicitWidth);
206 return implicit + itemsParent.anchors.leftMargin + itemsParent.anchors.rightMargin;
210 for (
const child of itemsParent.visibleChildren) {
211 if (child.implicitHeight <= 0) {
212 implicit = Math.max(implicit, child.height);
214 implicit = Math.max(implicit, child.implicitHeight);
217 return implicit + itemsParent.anchors.topMargin + itemsParent.anchors.bottomMargin;
221 property Flickable flickable
224 topMargin: root.topPadding
225 leftMargin: root.leftPadding
226 rightMargin: root.rightPadding
227 bottomMargin: root.bottomPadding
230 const child = children[children.length - 1];
231 if (child instanceof QQC2.ScrollView) {
232 print(
"Warning: it's not supported to have ScrollViews inside a ScrollablePage")
237 target: root.flickable
238 property:
"bottomMargin"
239 value: root.bottomPadding
240 restoreMode: Binding.RestoreBinding
245 id: busyIndicatorLoader
246 active: root.supportsRefreshing
249 active: root.refreshing
250 onTriggered: root.refreshing =
true
255 Component.onCompleted: {
256 let flickableFound =
false;
257 for (
const child of itemsParent.data) {
258 if (child instanceof Flickable) {
261 child.activeFocusOnTab =
true;
262 root.flickable = child;
263 flickableFound =
true;
264 if (child instanceof ListView) {
265 child.keyNavigationEnabled =
true;
266 child.keyNavigationWraps =
false;
268 }
else if (child instanceof
Item) {
269 child.anchors.left = itemsParent.left;
270 child.anchors.right = itemsParent.right;
271 }
else if (child instanceof KT.OverlaySheet) {
273 if (child.parent === itemsParent || child.parent === null) {
279 if (flickableFound) {
280 scrollView.contentItem = root.flickable;
281 root.flickable.parent = scrollView;
284 if (root.activeFocus) {
285 root.flickable.forceActiveFocus();
289 root.flickable.anchors.fill = undefined;
290 root.flickable.anchors.top = undefined;
291 root.flickable.anchors.left = undefined;
292 root.flickable.anchors.right = undefined;
293 root.flickable.anchors.bottom = undefined;
294 scrollingArea.visible =
false;
296 scrollView.contentItem = root.flickable;
297 scrollingArea.parent = root.flickable.contentItem;
298 scrollingArea.visible =
true;
299 root.flickable.contentHeight =
Qt.binding(() => scrollingArea.implicitHeight - root.flickable.topMargin - root.flickable.bottomMargin);
300 root.flickable.contentWidth =
Qt.binding(() => scrollingArea.implicitWidth);
301 scrollView.forceActiveFocus(
Qt.TabFocusReason);
303 root.flickable.flickableDirection = Flickable.VerticalFlick;
306 root.flickable.flickDeceleration = 1500;
307 root.flickable.maximumFlickVelocity = 5000;
A pull-down to refresh indicator that can be added to any Flickable or ScrollablePage.
QAction * print(const QObject *recvr, const char *slot, QObject *parent)