Skip to content

Commit

Permalink
Added basic fix for more options popup position
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidLazarescu committed Jan 2, 2024
1 parent 14f2cc4 commit abc013f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 8 additions & 2 deletions src/presentation/homePage/MBook.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 => {
Expand Down Expand Up @@ -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)
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/presentation/homePage/MHomePage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit abc013f

Please sign in to comment.