Skip to content
Snippets Groups Projects
Commit dd0a34eb authored by Kirill Anisimov's avatar Kirill Anisimov
Browse files

Added DapScrollView element.

parent 7eac2dad
No related branches found
No related tags found
2 merge requests!18Features 2923,!17Added DapScrollView element.
This commit is part of merge request !18. Comments created here will be created in the context of that merge request.
......@@ -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
{
property var contentPos: 0.0
viewData.onContentYChanged:
{
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"
}
}
onEntered:
{
scrollButton.visible = true;
}
onExited:
{
scrollButton.visible = false;
}
scrollButton.onEntered:
{
if (scrollButton.state === "goUp")
{
scrollButton.imageSource = "qrc:/res/icons/ic_scroll-down_hover.png"
}
else if (scrollButton.state === "goDown")
{
scrollButton.imageSource = "qrc:/res/icons/ic_scroll-up_hover.png"
}
}
scrollButton.onExited:
{
if (scrollButton.state === "goUp")
{
scrollButton.imageSource = "qrc:/res/icons/ic_scroll-down.png"
}
else if (scrollButton.state === "goDown")
{
scrollButton.imageSource = "qrc:/res/icons/ic_scroll-up.png"
}
}
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
////@ ListView to attach the ScrollButton
property ListView viewData: ListView {}
property alias scrollMouseArea: dapScrollMouseArea
property alias scrollButton: dapScrollButton
anchors.fill: parent
hoverEnabled: true
MouseArea
{
id: dapScrollButton
property string imageSource: "qrc:/res/icons/ic_scroll-down.png"
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
{
anchors.fill: parent
fillMode: Image.PreserveAspectFit
source: dapScrollButton.imageSource
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