use the new Kirigami.WheelHandler

This commit is contained in:
Marco Martin 2019-04-23 10:33:38 +02:00
parent b5ec56091e
commit bdb2783b0d

View File

@ -24,6 +24,7 @@ import QtQuick 2.9
import QtQuick.Controls @QQC2_VERSION@ import QtQuick.Controls @QQC2_VERSION@
import QtQuick.Templates @QQC2_VERSION@ as T import QtQuick.Templates @QQC2_VERSION@ as T
import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.kirigami 2.9 as Kirigami
T.ScrollView { T.ScrollView {
id: controlRoot id: controlRoot
@ -33,8 +34,6 @@ T.ScrollView {
implicitWidth: Math.max(background ? background.implicitWidth : 0, contentWidth + leftPadding + rightPadding) implicitWidth: Math.max(background ? background.implicitWidth : 0, contentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + topPadding + bottomPadding) implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + topPadding + bottomPadding)
contentWidth: verticalScrollBar.flickableItem ? verticalScrollBar.flickableItem.contentWidth : 0
contentHeight: verticalScrollBar.flickableItem ? verticalScrollBar.flickableItem.contentHeight : 0
//create a background only after Component.onCompleted, see on the component creation below for explanation //create a background only after Component.onCompleted, see on the component creation below for explanation
Component.onCompleted: { Component.onCompleted: {
@ -44,14 +43,19 @@ T.ScrollView {
} }
data: [ Component { data: [
id: backgroundComponent Kirigami.WheelHandler {
Rectangle { target: controlRoot.contentItem
color: theme.viewBackgroundColor },
visible: false Component {
anchors.fill:parent id: backgroundComponent
} Rectangle {
}] color: theme.viewBackgroundColor
visible: false
anchors.fill:parent
}
}
]
ScrollBar.vertical: ScrollBar { ScrollBar.vertical: ScrollBar {
id: verticalScrollBar id: verticalScrollBar