Skip to content
Snippets Groups Projects
Commit bca1afe6 authored by andrey.daragan's avatar andrey.daragan
Browse files

Merge branch 'features-2923' into 'develop'

Features 2923

See merge request !18
parents a4c2dcf4 39652dd0
No related branches found
No related tags found
1 merge request!18Features 2923
......@@ -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>
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"
}
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
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment