diff --git a/libdap-qt-ui-qml.qrc b/libdap-qt-ui-qml.qrc index 4bf602f6c699d907b56276ad378cae6c203daa41..96a76e108ff4d1374b8f3f8d72748751567ed9ac 100644 --- a/libdap-qt-ui-qml.qrc +++ b/libdap-qt-ui-qml.qrc @@ -22,5 +22,6 @@ <file>widgets/DapRadioButtonForm.ui.qml</file> <file>widgets/DapScrollView.qml</file> <file>widgets/DapScrollViewForm.ui.qml</file> + <file>widgets/DapScrollViewHandling.qml</file> </qresource> </RCC> diff --git a/widgets/DapRightPanelForm.ui.qml b/widgets/DapRightPanelForm.ui.qml index ce372d745de5a601e0b4aa9b19eb83f3712677cd..689fbfaefa78980c67a8fa3755f413bb4a6f8aca 100644 --- a/widgets/DapRightPanelForm.ui.qml +++ b/widgets/DapRightPanelForm.ui.qml @@ -8,6 +8,15 @@ import QtQuick.Controls 2.0 Rectangle { id: frameRightPanel + + ///@detalis Signal initiating switching to the previous displayed form. + signal nextActivated (var parametrsRightPanel) + ///@detalis Signal initiating switching to the previous displayed form. + signal previousActivated (var parametrsRightPanel) + ///@detalis Next display right panel. + property string dapNextRightPanel + ///@detalis Previous display right panel. + property string dapPreviousRightPanel ///@detalis Right panel widget. property alias dapFrame: frameRightPanel ///@detalis Right pane title widget. @@ -20,8 +29,7 @@ Rectangle property Item dapContentItemData ///@detalis dapRightPanelWidth External property for possibility to hiding RightPanel property int dapRightPanelWidth - - anchors.fill: parent + width: dapRightPanelWidth // Install right panel title diff --git a/widgets/DapScrollView.qml b/widgets/DapScrollView.qml index a8e63d8fef72719c22b35b25fff2b5d288d9870d..0555f2ef53ac1b01b950976e3ce05dff6fc3c34e 100644 --- a/widgets/DapScrollView.qml +++ b/widgets/DapScrollView.qml @@ -2,120 +2,38 @@ import QtQuick 2.4 DapScrollViewForm { - // All the logic (including state names and vars) was taken from master branch + //Default + scrollButtonImage.source: scrollButtonArrowUp ? scrollUpButtonImageSource : scrollDownButtonImageSource + x: parent.width - width - scrollButtonRightMargin + y: scrollButtonArrowUp ? scrollButtonTopMargin : parent.height - height - scrollButtonBottomMargin - // 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; - } + //If mouse pointer go into scrollButton scrollButton.onEntered: { - if (scrollButton.state === "goUp") - { - scrollButtonImage.source = scrollDownButtonHoveredImageSource - } - else if (scrollButton.state === "goDown") - { - scrollButtonImage.source = scrollUpButtonHoveredImageSource - } + scrollButtonImage.source = scrollButtonArrowUp ? scrollUpButtonHoveredImageSource : + scrollDownButtonHoveredImageSource; + mouseAtArrow = true; } + //If mouse pointer go out scrollButton scrollButton.onExited: { - if (scrollButton.state === "goUp") - { - scrollButtonImage.source = scrollDownButtonImageSource - } - else if (scrollButton.state === "goDown") - { - scrollButtonImage.source = scrollUpButtonImageSource - } + scrollButtonImage.source = scrollButtonArrowUp ? scrollUpButtonImageSource : + scrollDownButtonImageSource; + mouseAtArrow = false; } + //Change listView visible position on scrollButton click scrollButton.onClicked: { - if(scrollButton.state === "goUp") - { - viewData.positionViewAtEnd(); - scrollButton.state = "goDown"; - } - else if(scrollButton.state === "goDown") - { - viewData.positionViewAtBeginning(); - scrollButton.state = "goUp"; - } + scrollButtonArrowUp ? viewData.positionViewAtBeginning() : viewData.positionViewAtEnd(); } - 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" + //Change arrow image then arrow direction is need to change + onScrollButtonArrowUpChanged: + { + scrollButtonImage.source = scrollButtonArrowUp ? scrollUpButtonImageSource : + scrollDownButtonImageSource; + } } diff --git a/widgets/DapScrollViewForm.ui.qml b/widgets/DapScrollViewForm.ui.qml index 04d77c7fd604f2894908075c4355f2dee6f3b420..820e48a88ebd4a2ec1847a5a99e295bc446967b9 100644 --- a/widgets/DapScrollViewForm.ui.qml +++ b/widgets/DapScrollViewForm.ui.qml @@ -2,45 +2,50 @@ import QtQuick 2.4 MouseArea { - id: dapScrollMouseArea - - // Icons for scroll button + ///@detalis scrollDownButtonImageSource Icons for non-focus scroll button with down arrow property string scrollDownButtonImageSource + ///@detalis scrollDownButtonHoveredImageSource Icons for focus scroll button with down arrow property string scrollDownButtonHoveredImageSource + ///@detalis scrollUpButtonImageSource Icons for non-focus scroll button with up arrow property string scrollUpButtonImageSource + ///@detalis scrollUpButtonHoveredImageSource Icons for focus scroll button with up arrow property string scrollUpButtonHoveredImageSource - - // ListView to attach the scroll button - property ListView viewData - - property alias scrollMouseArea: dapScrollMouseArea + ///@detalis viewData Flicable item to attach the scroll button + property Flickable viewData + ///@detalis scrollButton ScrollButton reference property alias scrollButton: dapScrollButton + ///@detalis scrollButtonImage ScrollButtonImage reference property alias scrollButtonImage: dapScrollButtonImage + ///@detalis scrollButtonTopMargin Top Margin from parent.top + property int scrollButtonTopMargin + ///@detalis scrollButtonBottomMargin Bottom Margin from parent.top + property int scrollButtonBottomMargin + ///@detalis scrollButtonLeftMargin Left Margin from parent.top + property int scrollButtonLeftMargin + ///@detalis scrollButtonRightMargin Right Margin from parent.top + property int scrollButtonRightMargin + ///@detalis scrollButtonArrowUp Sign of arrow direction on scrollButton + property bool scrollButtonArrowUp + ///@detalis scrollButtonVisible Sign of visibility of scrollButton + property bool scrollButtonVisible + ///@detalis mouseAtArrow Sign of mouse pointer position into scrollButton + property bool mouseAtArrow + + id: dapScrollButton + width: 36 * pt + height: width - anchors.fill: parent hoverEnabled: true + propagateComposedEvents: true + visible: scrollButtonVisible - MouseArea + Image { - 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 - } + id: dapScrollButtonImage + anchors.fill: parent + fillMode: Image.PreserveAspectFit + sourceSize.height: parent.height + sourceSize.width: parent.width + visible: parent.visible } } diff --git a/widgets/DapScrollViewHandling.qml b/widgets/DapScrollViewHandling.qml new file mode 100644 index 0000000000000000000000000000000000000000..5da84b5dcc54ab61aa103ad3025e192868ad1ba7 --- /dev/null +++ b/widgets/DapScrollViewHandling.qml @@ -0,0 +1,88 @@ +import QtQuick 2.0 + +MouseArea +{ + id: dapScrollMouseArea + + ///@detalis scrollDirectionUp Direction of arrow at scrollButton + property bool scrollDirectionUp: true + ///@detalis scrollVisible Is scrollButton need + property bool scrollVisible: false + ///@detalis scrollMouseAtArrow Is mouse above the scrollButton + property bool scrollMouseAtArrow: false + ///@detalis viewData Flickable to attach the scroll button + property Flickable viewData + + anchors.fill: parent + //To use entered and exited signals + hoverEnabled: true + + + //If mouse pointer go to parent area + onEntered: + { + //ScrollButton is needed to be visible only if list lenght more than its height + scrollVisible = viewData.contentHeight > viewData.height; + //If user see the first element + if(viewData.atYBeginning) + scrollDirectionUp = false; + //If user see the last element + if(viewData.atYEnd) + scrollDirectionUp = true; + } + + //If mouse pointer go out the parent area + onExited: + { + //Because mouse can be out the parent area but at scrollButton; in this case scrollButton vust be visible + scrollVisible = false || scrollMouseAtArrow; + } + + //If user use a wheel + //Most mouse types work in steps of 15 degrees, + //in which case the delta value is a multiple of 120; + //i.e., 120 units * 1/8 = 15 degrees. + onWheel: + { + //If wheel was rotated up/right + if(wheel.angleDelta.y > 0) + { + if(!viewData.atYBeginning) + { + scrollDirectionUp = true; + //Cause MouseArea get all mouse event this string is need to flick listView + viewData.flick(0, wheel.angleDelta.y * 3 * pt); + } + else + scrollDirectionUp = false; + } + //If wheel was rotated down/left + else if(wheel.angleDelta.y < 0) + { + if(!viewData.atYEnd) + { + scrollDirectionUp = false; + //Cause MouseArea get all mouse event this string is need to flick listView + viewData.flick(0, wheel.angleDelta.y * 3 * pt); + } + else + scrollDirectionUp = true; + } + } + + + //If mouse not at scrollButton it is need to chamge visibility + onScrollMouseAtArrowChanged: + { + if(!scrollMouseAtArrow) + scrollVisible = containsMouse; + } + + + //AutoUpdate on addind string to model + Component.onCompleted: + { + viewData.onContentHeightChanged.connect(onEntered); + } + +}