Warning, /sdk/licensedigger/autotests/testdata/LGPL-3.0-only_OR_GPL-2.0-or-later/ScrollView.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  * Copyright 2017 Marco Martin <mart@kde.org>
0003  * Copyright 2017 The Qt Company Ltd.
0004  *
0005  * GNU Lesser General Public License Usage
0006  * Alternatively, this file may be used under the terms of the GNU Lesser
0007  * General Public License version 3 as published by the Free Software
0008  * Foundation and appearing in the file LICENSE.LGPLv3 included in the
0009  * packaging of this file. Please review the following information to
0010  * ensure the GNU Lesser General Public License version 3 requirements
0011  * will be met: https://www.gnu.org/licenses/lgpl.html.
0012  *
0013  * GNU General Public License Usage
0014  * Alternatively, this file may be used under the terms of the GNU
0015  * General Public License version 2.0 or later as published by the Free
0016  * Software Foundation and appearing in the file LICENSE.GPL included in
0017  * the packaging of this file. Please review the following information to
0018  * ensure the GNU General Public License version 2.0 requirements will be
0019  * met: http://www.gnu.org/licenses/gpl-2.0.html.
0020  */
0021 
0022 
0023 import QtQuick 2.9
0024 import QtQuick.Controls @QQC2_VERSION@
0025 import QtQuick.Templates @QQC2_VERSION@ as T
0026 import org.kde.kirigami 2.9 as Kirigami
0027 import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate
0028 
0029 T.ScrollView {
0030     id: controlRoot
0031 
0032     clip: true
0033 
0034     @DISABLE_UNDER_QQC2_2_4@ palette: Kirigami.Theme.palette
0035     implicitWidth: Math.max(background ? background.implicitWidth : 0, contentWidth + leftPadding + rightPadding)
0036     implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + topPadding + bottomPadding)
0037 
0038     Kirigami.Theme.colorSet: Kirigami.Theme.View
0039     Kirigami.Theme.inherit: !background || !background.visible
0040 
0041     //size in pixel to accomodate the border drawn by qstyle
0042     leftPadding: background && background.visible && background.hasOwnProperty("leftPadding") ? background.leftPadding : 0
0043     topPadding: background && background.visible && background.hasOwnProperty("topPadding") ? background.topPadding : 0
0044     rightPadding: background && background.visible && background.hasOwnProperty("rightPadding") ? background.rightPadding : 0
0045     bottomPadding: background && background.visible && background.hasOwnProperty("bottomPadding") ? background.bottomPadding : 0
0046 
0047     //create a background only after Component.onCompleted, see on the component creation below for explanation
0048     Component.onCompleted: {
0049         if (!controlRoot.background) {
0050             controlRoot.background = backgroundComponent.createObject(controlRoot);
0051         }
0052     }
0053 
0054     data: [
0055         Kirigami.WheelHandler {
0056             target: controlRoot.contentItem
0057         },
0058         /*create a background only after Component.onCompleted because:
0059         * implementations can set their own background in a declarative way
0060         * ScrollView {background.visible: true} must *not* work, because all upstream styles don't have a background so applications using this would break with other styles
0061         * This is child of scrollHelper as it would break native scrollview finding of the flickable if it was a direct child
0062         */
0063         Component {
0064             id: backgroundComponent
0065             StylePrivate.StyleItem {
0066                 control: controlRoot.contentItem
0067                 elementType: "edit"
0068                 property int leftPadding: frame.leftPadding
0069                 property int topPadding: frame.topPadding
0070                 property int rightPadding: frame.rightPadding
0071                 property int bottomPadding: frame.bottomPadding
0072                 visible: false
0073                 sunken: true
0074                 raised: false
0075                 enabled: controlRoot.contentItem.enabled
0076                 hasFocus: controlRoot.activeFocus || controlRoot.contentItem.activeFocus
0077                 hover: controlRoot.hovered
0078                 //This is just for the proper margin metrics
0079                 StylePrivate.StyleItem {
0080                     id: frame
0081                     anchors.fill:parent
0082                     control: controlRoot
0083                     elementType: "frame"
0084                     visible: false
0085                     sunken: true
0086                     hasFocus: controlRoot.activeFocus || controlRoot.contentItem.activeFocus
0087                     hover: controlRoot.hovered
0088                 }
0089             }
0090         }
0091     ]
0092     ScrollBar.vertical: ScrollBar {
0093         id: verticalScrollBar
0094         parent: controlRoot
0095         enabled: controlRoot.contentItem.enabled
0096         x: controlRoot.mirrored ? 0 : controlRoot.width - width
0097         y: controlRoot.topPadding
0098         height: controlRoot.availableHeight
0099         active: controlRoot.ScrollBar.horizontal || controlRoot.ScrollBar.horizontal.active
0100     }
0101 
0102     ScrollBar.horizontal: ScrollBar {
0103         parent: controlRoot
0104         enabled: controlRoot.contentItem.enabled
0105         x: controlRoot.leftPadding
0106         y: controlRoot.height - height
0107         width: controlRoot.availableWidth
0108         active: controlRoot.ScrollBar.vertical || controlRoot.ScrollBar.vertical.active
0109     }
0110 }