From abc013f5a4116da1b61f9df02a0c1e806ff497f0 Mon Sep 17 00:00:00 2001 From: DavidLazarescu Date: Tue, 2 Jan 2024 23:22:00 +0100 Subject: [PATCH] Added basic fix for more options popup position --- src/presentation/homePage/MBook.qml | 10 ++++++++-- src/presentation/homePage/MHomePage.qml | 5 ++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/presentation/homePage/MBook.qml b/src/presentation/homePage/MBook.qml index 1f227f23e..916baff56 100644 --- a/src/presentation/homePage/MBook.qml +++ b/src/presentation/homePage/MBook.qml @@ -12,7 +12,7 @@ Item { property bool downloading: false signal leftButtonClicked(int index) signal rightButtonClicked(int index, var mouse) - signal moreOptionClicked(int index, var mouse) + signal moreOptionClicked(int index, var point) implicitWidth: 190 implicitHeight: 322 @@ -222,8 +222,10 @@ Item { } MouseArea { + id: bookArea anchors.fill: parent acceptedButtons: Qt.AllButtons + cursorShape: Qt.PointingHandCursor // Delegate mouse clicks events to parent onClicked: mouse => { @@ -283,10 +285,14 @@ Item { id: moreOptionsArea anchors.fill: parent hoverEnabled: true + cursorShape: Qt.PointingHandCursor onClicked: mouse => { if (mouse.button === Qt.LeftButton) { - root.moreOptionClicked(root.index, mouse) + let point = mapToItem(bookArea, + Qt.point(mouse.x, + mouse.y)) + root.moreOptionClicked(root.index, point) } } } diff --git a/src/presentation/homePage/MHomePage.qml b/src/presentation/homePage/MHomePage.qml index 3cea52732..b44c93caa 100644 --- a/src/presentation/homePage/MHomePage.qml +++ b/src/presentation/homePage/MHomePage.qml @@ -232,11 +232,10 @@ Page { /* When clicking more options, open the bookOptions popup */ - onMoreOptionClicked: (index, mouse) => { + onMoreOptionClicked: (index, point) => { // Calculate where to spawn the bookOptions popup and set its position let currentMousePosition = mapToItem( - bookGridContainer, - mouse.x, mouse.y) + bookGridContainer, point) bookOptionsPopup.x = currentMousePosition.x - bookOptionsPopup.implicitWidth / 2