Warning, /frameworks/kirigami/examples/wheelhandler/FlickableUsage.qml is written in an unsupported language. File is not indexed.
0001 /* SPDX-FileCopyrightText: 2021 Noah Davis <noahadvs@gmail.com> 0002 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0003 */ 0004 0005 import QtQuick 2.15 0006 import QtQuick.Controls 2.15 as QQC2 0007 import org.kde.kirigami 2.20 as Kirigami 0008 0009 QQC2.ApplicationWindow { 0010 id: root 0011 0012 width: flickable.implicitWidth 0013 height: flickable.implicitHeight 0014 0015 Flickable { 0016 id: flickable 0017 0018 anchors.fill: parent 0019 implicitWidth: wheelHandler.horizontalStepSize * 10 + leftMargin + rightMargin 0020 implicitHeight: wheelHandler.verticalStepSize * 10 + topMargin + bottomMargin 0021 0022 leftMargin: QQC2.ScrollBar.vertical.visible && QQC2.ScrollBar.vertical.mirrored ? QQC2.ScrollBar.vertical.width : 0 0023 rightMargin: QQC2.ScrollBar.vertical.visible && !QQC2.ScrollBar.vertical.mirrored ? QQC2.ScrollBar.vertical.width : 0 0024 bottomMargin: QQC2.ScrollBar.horizontal.visible ? QQC2.ScrollBar.horizontal.height : 0 0025 0026 contentWidth: contentItem.childrenRect.width 0027 contentHeight: contentItem.childrenRect.height 0028 0029 Kirigami.WheelHandler { 0030 id: wheelHandler 0031 target: flickable 0032 filterMouseEvents: true 0033 keyNavigationEnabled: true 0034 } 0035 0036 QQC2.ScrollBar.vertical: QQC2.ScrollBar { 0037 parent: flickable.parent 0038 height: flickable.height - flickable.topMargin - flickable.bottomMargin 0039 x: mirrored ? 0 : flickable.width - width 0040 y: flickable.topMargin 0041 active: flickable.QQC2.ScrollBar.horizontal.active 0042 stepSize: wheelHandler.verticalStepSize / flickable.contentHeight 0043 } 0044 0045 QQC2.ScrollBar.horizontal: QQC2.ScrollBar { 0046 parent: flickable.parent 0047 width: flickable.width - flickable.leftMargin - flickable.rightMargin 0048 x: flickable.leftMargin 0049 y: flickable.height - height 0050 active: flickable.QQC2.ScrollBar.vertical.active 0051 stepSize: wheelHandler.horizontalStepSize / flickable.contentWidth 0052 } 0053 0054 Grid { // Example content 0055 columns: Math.sqrt(visibleChildren.length) 0056 Repeater { 0057 model: 1000 0058 delegate: Rectangle { 0059 implicitWidth: wheelHandler.horizontalStepSize 0060 implicitHeight: wheelHandler.verticalStepSize 0061 gradient: Gradient { 0062 orientation: index % 2 ? Gradient.Vertical : Gradient.Horizontal 0063 GradientStop { position: 0; color: Qt.rgba(Math.random(), Math.random(), Math.random(), 1) } 0064 GradientStop { position: 1; color: Qt.rgba(Math.random(), Math.random(), Math.random(), 1) } 0065 } 0066 } 0067 } 0068 } 0069 } 0070 }