From 2944b70267fcb6af41e70886b75593309c0d5945 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 20 Jun 2025 16:20:57 +0200 Subject: [PATCH] use viewport margins to calculate size and position --- client/ayon_core/style/style.css | 2 ++ .../tools/launcher/ui/actions_widget.py | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/client/ayon_core/style/style.css b/client/ayon_core/style/style.css index 6f47a34956..9a86bef960 100644 --- a/client/ayon_core/style/style.css +++ b/client/ayon_core/style/style.css @@ -855,9 +855,11 @@ ActionMenuPopup #Wrapper { border-radius: 0.3em; background: #353B46; } + ActionMenuPopup ActionsView { background: transparent; border: none; + margin: 4px; } #IconView[mode="icon"] { diff --git a/client/ayon_core/tools/launcher/ui/actions_widget.py b/client/ayon_core/tools/launcher/ui/actions_widget.py index 28c741c93a..6a16dd9f8e 100644 --- a/client/ayon_core/tools/launcher/ui/actions_widget.py +++ b/client/ayon_core/tools/launcher/ui/actions_widget.py @@ -396,7 +396,6 @@ class ActionMenuPopup(QtWidgets.QWidget): view = ActionsView(self) view.setGridSize(QtCore.QSize(75, 80)) view.setIconSize(QtCore.QSize(32, 32)) - view.move(QtCore.QPoint(3, 3)) # Background draw wrapper = QtWidgets.QFrame(self) @@ -485,8 +484,9 @@ class ActionMenuPopup(QtWidgets.QWidget): or pos.y() + target_size.height() > window_geo.bottom() ) - pos_x = pos.x() - 5 - pos_y = pos.y() - 4 + viewport_offset = self._view.viewport().geometry().topLeft() + pos_x = pos.x() - (viewport_offset.x() + 2) + pos_y = pos.y() - (viewport_offset.y() + 1) wrap_x = wrap_y = 0 sort_order = QtCore.Qt.DescendingOrder @@ -576,16 +576,19 @@ class ActionMenuPopup(QtWidgets.QWidget): if rows == 1: cols = row_count - m_l, m_t, m_r, m_b = (3, 3, 1, 1) - # QUESTION how to get the margins from Qt? - border = 2 * 1 + viewport_geo = self._view.viewport().geometry() + viewport_offset = viewport_geo.topLeft() + # QUESTION how to get the bottom and right margins from Qt? + vp_lr = viewport_offset.x() + vp_tb = viewport_offset.y() + m_l, m_t, m_r, m_b = (vp_lr, vp_tb, vp_lr, vp_tb) single_width = ( grid_size.width() - + self._view.horizontalOffset() + border + m_l + m_r + 1 + + self._view.horizontalOffset() + m_l + m_r + 1 ) single_height = ( grid_size.height() - + self._view.verticalOffset() + border + m_b + m_t + 1 + + self._view.verticalOffset() + m_b + m_t + 1 ) total_width = single_width total_height = single_height