mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
Updated YACReaderScrollView to the latest SrollView version
This commit is contained in:
parent
d3528bf7fa
commit
7a43ec131c
@ -44,6 +44,7 @@ import QtQuick.Controls.Styles 1.1
|
|||||||
\inqmlmodule QtQuick.Controls
|
\inqmlmodule QtQuick.Controls
|
||||||
\since 5.1
|
\since 5.1
|
||||||
\ingroup views
|
\ingroup views
|
||||||
|
\ingroup controls
|
||||||
\brief Provides a scrolling view within another Item.
|
\brief Provides a scrolling view within another Item.
|
||||||
|
|
||||||
\image scrollview.png
|
\image scrollview.png
|
||||||
@ -163,7 +164,9 @@ FocusScope {
|
|||||||
default property Item contentItem
|
default property Item contentItem
|
||||||
|
|
||||||
/*! \internal */
|
/*! \internal */
|
||||||
property Item __scroller: scroller
|
property alias __scroller: scroller
|
||||||
|
/*! \internal */
|
||||||
|
property alias __verticalScrollbarOffset: scroller.verticalScrollbarOffset
|
||||||
/*! \internal */
|
/*! \internal */
|
||||||
property alias __wheelAreaScrollSpeed: wheelArea.scrollSpeed
|
property alias __wheelAreaScrollSpeed: wheelArea.scrollSpeed
|
||||||
/*! \internal */
|
/*! \internal */
|
||||||
@ -237,13 +240,13 @@ FocusScope {
|
|||||||
|
|
||||||
onContentYChanged: {
|
onContentYChanged: {
|
||||||
scroller.blockUpdates = true
|
scroller.blockUpdates = true
|
||||||
scroller.verticalScrollBar.value = flickableItem.contentY
|
scroller.verticalScrollBar.value = flickableItem.contentY - flickableItem.originY
|
||||||
scroller.blockUpdates = false
|
scroller.blockUpdates = false
|
||||||
}
|
}
|
||||||
|
|
||||||
onContentXChanged: {
|
onContentXChanged: {
|
||||||
scroller.blockUpdates = true
|
scroller.blockUpdates = true
|
||||||
scroller.horizontalScrollBar.value = flickableItem.contentX
|
scroller.horizontalScrollBar.value = flickableItem.contentX - flickableItem.originX
|
||||||
scroller.blockUpdates = false
|
scroller.blockUpdates = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,42 +276,43 @@ FocusScope {
|
|||||||
property bool horizontalRecursionGuard: false
|
property bool horizontalRecursionGuard: false
|
||||||
property bool verticalRecursionGuard: false
|
property bool verticalRecursionGuard: false
|
||||||
|
|
||||||
horizontalMinimumValue: flickableItem ? flickableItem.originX : 0
|
horizontalMinimumValue: 0
|
||||||
horizontalMaximumValue: flickableItem ? flickableItem.originX + flickableItem.contentWidth - viewport.width : 0
|
horizontalMaximumValue: flickableItem ? flickableItem.contentWidth - viewport.width : 0
|
||||||
|
|
||||||
verticalMinimumValue: flickableItem ? flickableItem.originY : 0
|
verticalMinimumValue: 0
|
||||||
verticalMaximumValue: flickableItem ? flickableItem.originY + flickableItem.contentHeight - viewport.height + __viewTopMargin : 0
|
verticalMaximumValue: flickableItem ? flickableItem.contentHeight - viewport.height + __viewTopMargin : 0
|
||||||
|
|
||||||
// The default scroll speed for typical angle-based mouse wheels. The value
|
// The default scroll speed for typical angle-based mouse wheels. The value
|
||||||
// comes originally from QTextEdit, which sets 20px steps by default, as well as
|
// comes originally from QTextEdit, which sets 20px steps by default, as well as
|
||||||
// QQuickWheelArea.
|
// QQuickWheelArea.
|
||||||
// TODO: centralize somewhere, QPlatformTheme?
|
// TODO: centralize somewhere, QPlatformTheme?
|
||||||
scrollSpeed: 20 * (__style.__wheelScrollLines || 1)
|
scrollSpeed: 20 * (__style && __style.__wheelScrollLines || 1)
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: flickableItem
|
target: flickableItem
|
||||||
|
|
||||||
onContentYChanged: {
|
onContentYChanged: {
|
||||||
wheelArea.verticalRecursionGuard = true
|
wheelArea.verticalRecursionGuard = true
|
||||||
wheelArea.verticalValue = flickableItem.contentY
|
wheelArea.verticalValue = flickableItem.contentY - flickableItem.originY
|
||||||
wheelArea.verticalRecursionGuard = false
|
wheelArea.verticalRecursionGuard = false
|
||||||
}
|
}
|
||||||
onContentXChanged: {
|
onContentXChanged: {
|
||||||
wheelArea.horizontalRecursionGuard = true
|
wheelArea.horizontalRecursionGuard = true
|
||||||
wheelArea.horizontalValue = flickableItem.contentX
|
wheelArea.horizontalValue = flickableItem.contentX - flickableItem.originX
|
||||||
wheelArea.horizontalRecursionGuard = false
|
wheelArea.horizontalRecursionGuard = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onVerticalValueChanged: {
|
onVerticalValueChanged: {
|
||||||
if (!verticalRecursionGuard) {
|
if (!verticalRecursionGuard) {
|
||||||
if (flickableItem.contentY < flickThreshold && verticalDelta > speedThreshold) {
|
var effectiveContentY = flickableItem.contentY - flickableItem.originY
|
||||||
|
if (effectiveContentY < flickThreshold && verticalDelta > speedThreshold) {
|
||||||
flickableItem.flick(ignored, Math.min(maxFlick, acceleration * verticalDelta))
|
flickableItem.flick(ignored, Math.min(maxFlick, acceleration * verticalDelta))
|
||||||
} else if (flickableItem.contentY > flickableItem.contentHeight
|
} else if (effectiveContentY > flickableItem.contentHeight - flickThreshold - viewport.height
|
||||||
- flickThreshold - viewport.height && verticalDelta < -speedThreshold) {
|
&& verticalDelta < -speedThreshold) {
|
||||||
flickableItem.flick(ignored, Math.max(-maxFlick, acceleration * verticalDelta))
|
flickableItem.flick(ignored, Math.max(-maxFlick, acceleration * verticalDelta))
|
||||||
} else {
|
} else {
|
||||||
flickableItem.contentY = verticalValue
|
flickableItem.contentY = verticalValue + flickableItem.originY
|
||||||
}
|
}
|
||||||
flickableItem.contentY = Math.min(verticalMaximumValue, Math.max(0, flickableItem.contentY));
|
flickableItem.contentY = Math.min(verticalMaximumValue, Math.max(0, flickableItem.contentY));
|
||||||
}
|
}
|
||||||
@ -316,7 +320,7 @@ FocusScope {
|
|||||||
|
|
||||||
onHorizontalValueChanged: {
|
onHorizontalValueChanged: {
|
||||||
if (!horizontalRecursionGuard)
|
if (!horizontalRecursionGuard)
|
||||||
flickableItem.contentX = horizontalValue
|
flickableItem.contentX = horizontalValue + flickableItem.originX
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,9 +331,9 @@ FocusScope {
|
|||||||
property bool outerFrame: !frameVisible || !(__style ? __style.__externalScrollBars : 0)
|
property bool outerFrame: !frameVisible || !(__style ? __style.__externalScrollBars : 0)
|
||||||
property int scrollBarSpacing: outerFrame ? 0 : (__style ? __style.__scrollBarSpacing : 0)
|
property int scrollBarSpacing: outerFrame ? 0 : (__style ? __style.__scrollBarSpacing : 0)
|
||||||
property int verticalScrollbarOffset: verticalScrollBar.visible && !verticalScrollBar.isTransient ?
|
property int verticalScrollbarOffset: verticalScrollBar.visible && !verticalScrollBar.isTransient ?
|
||||||
verticalScrollBar.width + scrollBarSpacing : 0
|
verticalScrollBar.width + scrollBarSpacing : 0
|
||||||
property int horizontalScrollbarOffset: horizontalScrollBar.visible && !horizontalScrollBar.isTransient ?
|
property int horizontalScrollbarOffset: horizontalScrollBar.visible && !horizontalScrollBar.isTransient ?
|
||||||
horizontalScrollBar.height + scrollBarSpacing : 0
|
horizontalScrollBar.height + scrollBarSpacing : 0
|
||||||
Loader {
|
Loader {
|
||||||
id: frameLoader
|
id: frameLoader
|
||||||
sourceComponent: __style ? __style.frame : null
|
sourceComponent: __style ? __style.frame : null
|
||||||
|
Loading…
x
Reference in New Issue
Block a user