diff --git a/resources/qml/WelcomePages/AddLocalPrinterScrollView.qml b/resources/qml/WelcomePages/AddLocalPrinterScrollView.qml index 50ceeff8a9..cf89d7a345 100644 --- a/resources/qml/WelcomePages/AddLocalPrinterScrollView.qml +++ b/resources/qml/WelcomePages/AddLocalPrinterScrollView.qml @@ -5,7 +5,7 @@ import QtQuick 2.10 import QtQuick.Controls 2.3 import UM 1.3 as UM -import Cura 1.0 as Cura +import Cura 1.1 as Cura // @@ -68,7 +68,7 @@ Item height: childrenRect.height // ScrollView + ListView for selecting a local printer to add - ScrollView + Cura.ScrollView { id: scrollView anchors.left: parent.left diff --git a/resources/qml/Widgets/ScrollView.qml b/resources/qml/Widgets/ScrollView.qml new file mode 100644 index 0000000000..43a80204f7 --- /dev/null +++ b/resources/qml/Widgets/ScrollView.qml @@ -0,0 +1,45 @@ +// Copyright (c) 2020 Ultimaker B.V. +// Toolbox is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.10 +import QtQuick.Controls 2.3 + +import UM 1.1 as UM + +ScrollView +{ + clip: true + // Setting this property to false hides the scrollbar both when the scrollbar is not needed (child height < height) + // and when the scrollbar is not actively being hovered or pressed + property bool scrollAlwaysVisible: true + + ScrollBar.vertical: ScrollBar + { + hoverEnabled: true + policy: parent.scrollAlwaysVisible ? ScrollBar.AlwaysOn : ScrollBar.AsNeeded + anchors.top: parent.top + anchors.right: parent.right + anchors.bottom: parent.bottom + + contentItem: Rectangle + { + implicitWidth: UM.Theme.getSize("scrollbar").width + opacity: (parent.active || parent.parent.scrollAlwaysVisible) ? 1.0 : 0.0 + radius: Math.round(width / 2) + color: + { + if (parent.pressed) + { + return UM.Theme.getColor("scrollbar_handle_down") + } + else if (parent.hovered) + { + return UM.Theme.getColor("scrollbar_handle_hover") + } + return UM.Theme.getColor("scrollbar_handle") + } + Behavior on color { ColorAnimation { duration: 100; } } + Behavior on opacity { NumberAnimation { duration: 100 } } + } + } +} \ No newline at end of file diff --git a/resources/qml/qmldir b/resources/qml/qmldir index dcc2e410c9..ab61101778 100644 --- a/resources/qml/qmldir +++ b/resources/qml/qmldir @@ -35,6 +35,7 @@ RadioButton 1.0 RadioButton.qml Scrollable 1.0 Scrollable.qml TabButton 1.0 TabButton.qml TextField 1.0 TextField.qml +ScrollView 1.0 ScrollView.qml # Cura/MachineSettings