diff --git a/libdap-qt-ui-qml.qrc b/libdap-qt-ui-qml.qrc index 244e6b05d0f40c974f42efadada094a31d9806eb..4bf602f6c699d907b56276ad378cae6c203daa41 100644 --- a/libdap-qt-ui-qml.qrc +++ b/libdap-qt-ui-qml.qrc @@ -20,5 +20,7 @@ <file>Device.qml</file> <file>widgets/DapRadioButton.qml</file> <file>widgets/DapRadioButtonForm.ui.qml</file> + <file>widgets/DapScrollView.qml</file> + <file>widgets/DapScrollViewForm.ui.qml</file> </qresource> </RCC> diff --git a/widgets/DapComboBoxForm.ui.qml b/widgets/DapComboBoxForm.ui.qml index ae7a2feccab5753c00dc19628fd8a02f84a4fc29..829ec783aadbcec199399c89974d4f81776d9fee 100644 --- a/widgets/DapComboBoxForm.ui.qml +++ b/widgets/DapComboBoxForm.ui.qml @@ -86,7 +86,6 @@ ComboBox { anchors.fill: parent color: parent.popup.visible ? hilightTopColor : normalTopColor - radius: 2 * pt height: parent.height } @@ -129,7 +128,7 @@ ComboBox anchors.fill: parent } - DropShadow + DropShadow { anchors.fill: parent source: contentCorner @@ -143,18 +142,10 @@ ComboBox //Shadow effect for the top element. DropShadow { - anchors.fill: if (topEffect) - parent - source: if (topEffect) - background - verticalOffset: if (topEffect) - 9 * pt - else 0 - samples: if (topEffect) - 13 * pt - else 0 - color: if (topEffect) - dapComboBox.popup.visible ? colorDropShadow : colorTopNormalDropShadow - else "#000000" + anchors.fill: topEffect ? parent : null + source: topEffect ? background : null + verticalOffset: topEffect ? 9 * pt : 0 + samples: topEffect ? 13 * pt : 0 + color: topEffect ? (dapComboBox.popup.visible ? colorDropShadow : colorTopNormalDropShadow) : "#000000" } } diff --git a/widgets/DapScrollView.qml b/widgets/DapScrollView.qml new file mode 100644 index 0000000000000000000000000000000000000000..a8e63d8fef72719c22b35b25fff2b5d288d9870d --- /dev/null +++ b/widgets/DapScrollView.qml @@ -0,0 +1,121 @@ +import QtQuick 2.4 + +DapScrollViewForm +{ + // All the logic (including state names and vars) was taken from master branch + + // Var for current pos while scrolling (in function updateY()) + property var contentPos: 0.0 + + // Connect to new ListView if changed + onViewDataChanged: + { + viewData.contentYChanged.connect(updateY) + } + + // Changes position of arrows when scroll + function updateY() + { + if (viewData.atYBeginning) + { + scrollButton.state = "goUp" + } + else if (viewData.atYEnd) + { + scrollButton.state = "goDown" + } + else if (contentPos > viewData.contentItem.y) + { + scrollButton.state = "goUp" + } + else + { + scrollButton.state = "goDown" + } + contentPos = viewData.contentItem.y + } + + onEntered: + { + scrollButton.visible = true; + } + + onExited: + { + scrollButton.visible = false; + } + + scrollButton.onEntered: + { + if (scrollButton.state === "goUp") + { + scrollButtonImage.source = scrollDownButtonHoveredImageSource + } + else if (scrollButton.state === "goDown") + { + scrollButtonImage.source = scrollUpButtonHoveredImageSource + } + } + + scrollButton.onExited: + { + if (scrollButton.state === "goUp") + { + scrollButtonImage.source = scrollDownButtonImageSource + } + else if (scrollButton.state === "goDown") + { + scrollButtonImage.source = scrollUpButtonImageSource + } + } + + scrollButton.onClicked: + { + if(scrollButton.state === "goUp") + { + viewData.positionViewAtEnd(); + scrollButton.state = "goDown"; + } + else if(scrollButton.state === "goDown") + { + viewData.positionViewAtBeginning(); + scrollButton.state = "goUp"; + } + } + + scrollButton.states: + [ + State + { + name: "goDown" + PropertyChanges + { + target: scrollButton + onStateChanged: + { + scrollButton.anchors.top = undefined + scrollButton.anchors.bottom = parent.bottom + scrollButton.exited() + } + } + }, + + State + { + name: "goUp" + PropertyChanges + { + target: scrollButton + onStateChanged: + { + scrollButton.anchors.bottom = undefined + scrollButton.anchors.top = parent.top + scrollButton.exited() + } + } + } + + ] + + scrollButton.state: "goUp" +} diff --git a/widgets/DapScrollViewForm.ui.qml b/widgets/DapScrollViewForm.ui.qml new file mode 100644 index 0000000000000000000000000000000000000000..04d77c7fd604f2894908075c4355f2dee6f3b420 --- /dev/null +++ b/widgets/DapScrollViewForm.ui.qml @@ -0,0 +1,46 @@ +import QtQuick 2.4 + +MouseArea +{ + id: dapScrollMouseArea + + // Icons for scroll button + property string scrollDownButtonImageSource + property string scrollDownButtonHoveredImageSource + property string scrollUpButtonImageSource + property string scrollUpButtonHoveredImageSource + + // ListView to attach the scroll button + property ListView viewData + + property alias scrollMouseArea: dapScrollMouseArea + property alias scrollButton: dapScrollButton + property alias scrollButtonImage: dapScrollButtonImage + + anchors.fill: parent + hoverEnabled: true + + MouseArea + { + id: dapScrollButton + width: 36 * pt + height: width + anchors.right: parent.right + anchors.bottom: parent.bottom + anchors.bottomMargin: 10 * pt + anchors.topMargin: 10 * pt + anchors.rightMargin: 10 * pt + hoverEnabled: true + visible: false + + Image + { + id: dapScrollButtonImage + anchors.fill: parent + fillMode: Image.PreserveAspectFit + source: scrollDownButtonImageSource + sourceSize.height: parent.height + sourceSize.width: parent.width + } + } +}