Libplasma

ScrollView.qml
1/*
2 SPDX-FileCopyrightText: 2017 Marco Martin <mart@kde.org>
3 SPDX-FileCopyrightText: 2017 The Qt Company Ltd.
4
5 SPDX-License-Identifier: LGPL-3.0-only OR GPL-2.0-or-later
6*/
7
8
9import QtQuick
10import QtQuick.Templates as T
11import QtQml
12
13import org.kde.kirigami as Kirigami
14import org.kde.plasma.components as PlasmaComponents3
16T.ScrollView {
17 id: controlRoot
18
19 clip: true
20
21 implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
22 contentWidth + leftPadding + rightPadding)
23 implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
24 contentHeight + topPadding + bottomPadding)
25
26 leftPadding: mirrored && T.ScrollBar.vertical.visible && !Kirigami.Settings.isMobile ? T.ScrollBar.vertical.width : 0
27 rightPadding: !mirrored && T.ScrollBar.vertical.visible && !Kirigami.Settings.isMobile ? T.ScrollBar.vertical.width : 0
28 bottomPadding: T.ScrollBar.horizontal.visible && !Kirigami.Settings.isMobile ? T.ScrollBar.horizontal.height : 0
29
30 data: [
31 Kirigami.WheelHandler {
32 target: controlRoot.contentItem
33 // `Qt.styleHints.wheelScrollLines * 20` is the default scroll speed.
34 horizontalStepSize: Qt.styleHints.wheelScrollLines * 20
35 verticalStepSize: Qt.styleHints.wheelScrollLines * 20
36 },
37 Binding { // TODO KF6: remove, Qt6 has this behavior by default
38 target: controlRoot.contentItem // always instanceof Flickable
39 property: 'clip'
40 value: true
41 restoreMode: Binding.RestoreBindingOrValue
42 }
43 ]
44
45 T.ScrollBar.vertical: PlasmaComponents3.ScrollBar {
46 parent: controlRoot
47 x: controlRoot.mirrored ? 0 : controlRoot.width - width
48 y: controlRoot.topPadding
49 height: controlRoot.availableHeight
50 active: controlRoot.T.ScrollBar.horizontal.active
51 }
52
53 T.ScrollBar.horizontal: PlasmaComponents3.ScrollBar {
54 parent: controlRoot
55 x: controlRoot.leftPadding
56 y: controlRoot.height - height
57 width: controlRoot.availableWidth
58 active: controlRoot.T.ScrollBar.vertical.active
59 }
60}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:35 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.