From 1bf0c1ff6752d3bbf4e70e8e7e5727d78ed9ee8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Wed, 31 May 2023 19:03:06 +0200 Subject: [PATCH] Fix InfoComicsView scroll bar in Qt6 --- YACReaderLibrary/qml/InfoComicsView.qml | 10 +- YACReaderLibrary/qml/InfoComicsView6.qml | 131 +++++++++++++++++++++++ YACReaderLibrary/qml6.qrc | 2 +- 3 files changed, 137 insertions(+), 6 deletions(-) create mode 100644 YACReaderLibrary/qml/InfoComicsView6.qml diff --git a/YACReaderLibrary/qml/InfoComicsView.qml b/YACReaderLibrary/qml/InfoComicsView.qml index df1b3c23..650a3bc1 100644 --- a/YACReaderLibrary/qml/InfoComicsView.qml +++ b/YACReaderLibrary/qml/InfoComicsView.qml @@ -69,6 +69,11 @@ Rectangle { contentWidth: infoView.width contentHeight: infoView.height + ComicInfoView { + id: infoView + width: info_container.width - 14 + } + WheelHandler { onWheel: { if (infoFlickable.contentHeight <= infoFlickable.height) { @@ -97,11 +102,6 @@ Rectangle { } } } - - ComicInfoView { - id: infoView - width: info_container.width - 14 - } } } diff --git a/YACReaderLibrary/qml/InfoComicsView6.qml b/YACReaderLibrary/qml/InfoComicsView6.qml new file mode 100644 index 00000000..e341f8c0 --- /dev/null +++ b/YACReaderLibrary/qml/InfoComicsView6.qml @@ -0,0 +1,131 @@ +import QtQuick 2.15 + +import QtQuick.Controls 2.15 + +import com.yacreader.ComicModel 1.0 + +import QtQuick.Controls.Basic + +Rectangle { + id: main + + color: infoBackgroundColor + + //width: parent.width + //height: parent.height + anchors.margins: 0 + + FlowView { + id: flow + objectName: "flow" + height: 256 //TODO dynamic size? + + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + + additionalBottomSpace: indicator.height + } + + Image { + id: top_shadow + source: topShadow + width: parent.width + fillMode: Image.TileHorizontally + } + + Rectangle { + id: indicator_container + width: parent.width + y: 250 + + Image { + id: indicator + source: infoIndicator + } + + Image { + id: bottom_shadow + x: indicator.width + width: parent.width - indicator.width + source: infoShadow + fillMode: Image.TileHorizontally + } + } + + Rectangle { + id: info_container + width: parent.width + y: flow.height + flow.additionalBottomSpace - 6 + height: parent.height - y + + clip: true + + color: infoBackgroundColor + + Flickable{ + id: infoFlickable + anchors.fill: parent + anchors.margins: 0 + + contentWidth: infoView.width + contentHeight: infoView.height + + ComicInfoView { + id: infoView + width: info_container.width - 14 + } + + WheelHandler { + onWheel: { + if (infoFlickable.contentHeight <= infoFlickable.height) { + return; + } + + var newValue = Math.min((infoFlickable.contentHeight - infoFlickable.height), (Math.max(infoFlickable.originY , infoFlickable.contentY - event.angleDelta.y))); + infoFlickable.contentY = newValue; + } + } + + ScrollBar.vertical: ScrollBar { + visible: infoFlickable.contentHeight > infoFlickable.height + + contentItem: Item { + implicitWidth: 12 + implicitHeight: 26 + Rectangle { + color: "#424246" + anchors.fill: parent + anchors.topMargin: 6 + anchors.leftMargin: 5 + anchors.rightMargin: 4 + anchors.bottomMargin: 6 + radius: 2 + } + } + } + } + } + + DropArea { + anchors.fill: parent + + onEntered: { + if(drag.hasUrls) + { + if(dropManager.canDropUrls(drag.urls, drag.action)) + { + drag.accepted = true; + }else + drag.accepted = false; + } + } + + onDropped: { + if(drop.hasUrls && dropManager.canDropUrls(drop.urls, drop.action)) + { + dropManager.droppedFiles(drop.urls, drop.action); + } + } + } +} diff --git a/YACReaderLibrary/qml6.qrc b/YACReaderLibrary/qml6.qrc index 3d995203..bf837e4a 100644 --- a/YACReaderLibrary/qml6.qrc +++ b/YACReaderLibrary/qml6.qrc @@ -6,7 +6,7 @@ qml/InfoTick6.qml qml/InfoFavorites6.qml qml/InfoRating6.qml - qml/InfoComicsView.qml + qml/InfoComicsView6.qml qml/tick.png qml/reading.png qml/star_menu.png