diff --git a/src/declarativeimports/plasmacomponents3/ScrollView.qml b/src/declarativeimports/plasmacomponents3/ScrollView.qml new file mode 100644 index 000000000..688531e20 --- /dev/null +++ b/src/declarativeimports/plasmacomponents3/ScrollView.qml @@ -0,0 +1,72 @@ +/* + * Copyright 2017 Marco Martin + * Copyright 2017 The Qt Company Ltd. + * + * GNU Lesser General Public License Usage + * Alternatively, this file may be used under the terms of the GNU Lesser + * General Public License version 3 as published by the Free Software + * Foundation and appearing in the file LICENSE.LGPLv3 included in the + * packaging of this file. Please review the following information to + * ensure the GNU Lesser General Public License version 3 requirements + * will be met: https://www.gnu.org/licenses/lgpl.html. + * + * GNU General Public License Usage + * Alternatively, this file may be used under the terms of the GNU + * General Public License version 2.0 or later as published by the Free + * Software Foundation and appearing in the file LICENSE.GPL included in + * the packaging of this file. Please review the following information to + * ensure the GNU General Public License version 2.0 requirements will be + * met: http://www.gnu.org/licenses/gpl-2.0.html. + */ + + +import QtQuick 2.9 +import QtQuick.Controls @QQC2_VERSION@ +import QtQuick.Templates @QQC2_VERSION@ as T +import org.kde.plasma.core 2.0 as PlasmaCore + +T.ScrollView { + id: controlRoot + + clip: true + + implicitWidth: Math.max(background ? background.implicitWidth : 0, contentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + topPadding + bottomPadding) + + contentWidth: scrollHelper.flickableItem ? scrollHelper.flickableItem.contentWidth : 0 + contentHeight: scrollHelper.flickableItem ? scrollHelper.flickableItem.contentHeight : 0 + + //create a background only after Component.onCompleted, see on the component creation below for explanation + Component.onCompleted: { + if (!controlRoot.background) { + controlRoot.background = backgroundComponent.createObject(controlRoot); + } + } + + + data: [ Component { + id: backgroundComponent + Rectangle { + color: theme.viewBackgroundColor + visible: false + anchors.fill:parent + } + }] + + ScrollBar.vertical: ScrollBar { + id: verticalScrollBar + parent: controlRoot + x: controlRoot.mirrored ? 0 : controlRoot.width - width + y: controlRoot.topPadding + height: controlRoot.availableHeight + active: controlRoot.ScrollBar.horizontal || controlRoot.ScrollBar.horizontal.active + } + + ScrollBar.horizontal: ScrollBar { + parent: controlRoot + x: controlRoot.leftPadding + y: controlRoot.height - height + width: controlRoot.availableWidth + active: controlRoot.ScrollBar.vertical || controlRoot.ScrollBar.vertical.active + } +}