From 6effd688914e55f9dd1b82d507b3213189f96490 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 20 Jun 2025 10:56:45 +0200 Subject: [PATCH 01/22] show settings icon only on hover --- client/ayon_core/tools/launcher/ui/actions_widget.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/tools/launcher/ui/actions_widget.py b/client/ayon_core/tools/launcher/ui/actions_widget.py index 0459999958..3f292bd358 100644 --- a/client/ayon_core/tools/launcher/ui/actions_widget.py +++ b/client/ayon_core/tools/launcher/ui/actions_widget.py @@ -77,14 +77,22 @@ class ActionOverlayWidget(QtWidgets.QFrame): settings_icon = LauncherSettingsLabel(self) settings_icon.setToolTip("Right click for options") + settings_icon.setVisible(False) main_layout = QtWidgets.QGridLayout(self) main_layout.setContentsMargins(5, 5, 0, 0) main_layout.addWidget(settings_icon, 0, 0) main_layout.setColumnStretch(1, 1) main_layout.setRowStretch(1, 1) + self.setAttribute(QtCore.Qt.WA_TranslucentBackground, True) - self.setAttribute(QtCore.Qt.WA_TranslucentBackground) + def enterEvent(self, event): + super().enterEvent(event) + self._settings_icon.setVisible(True) + + def leaveEvent(self, event): + super().leaveEvent(event) + self._settings_icon.setVisible(False) class ActionsQtModel(QtGui.QStandardItemModel): From 057bdd1fbaebc91bcecee29f2b4a82f01e08bab5 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 20 Jun 2025 10:58:37 +0200 Subject: [PATCH 02/22] settings icon has width of 1/6 of parent --- .../tools/launcher/ui/actions_widget.py | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/client/ayon_core/tools/launcher/ui/actions_widget.py b/client/ayon_core/tools/launcher/ui/actions_widget.py index 3f292bd358..32069ee807 100644 --- a/client/ayon_core/tools/launcher/ui/actions_widget.py +++ b/client/ayon_core/tools/launcher/ui/actions_widget.py @@ -51,12 +51,13 @@ def _variant_label_sort_getter(action_item): # --- Replacement for QAction for action variants --- -class LauncherSettingsLabel(PixmapLabel): +class LauncherSettingsLabel(QtWidgets.QWidget): _settings_icon = None def __init__(self, parent): + super().__init__(parent) icon = self._get_settings_icon() - super().__init__(icon.pixmap(64, 64), parent) + self._pixmap = icon.pixmap(64, 64) @classmethod def _get_settings_icon(cls): @@ -67,6 +68,34 @@ class LauncherSettingsLabel(PixmapLabel): }) return cls._settings_icon + def paintEvent(self, event): + painter = QtGui.QPainter() + painter.begin(self) + + render_hints = ( + QtGui.QPainter.Antialiasing + | QtGui.QPainter.SmoothPixmapTransform + ) + if hasattr(QtGui.QPainter, "HighQualityAntialiasing"): + render_hints |= QtGui.QPainter.HighQualityAntialiasing + + rect = event.rect() + size = min(rect.height(), rect.width()) + pix_rect = QtCore.QRect( + rect.x(), rect.y(), + size, size + ) + pixmap = self._pixmap.scaled( + pix_rect.size(), + QtCore.Qt.KeepAspectRatio, + QtCore.Qt.SmoothTransformation + + ) + painter.setRenderHints(render_hints) + painter.drawPixmap(0, 0, pixmap) + + painter.end() + class ActionOverlayWidget(QtWidgets.QFrame): config_requested = QtCore.Signal(str) @@ -82,8 +111,9 @@ class ActionOverlayWidget(QtWidgets.QFrame): main_layout = QtWidgets.QGridLayout(self) main_layout.setContentsMargins(5, 5, 0, 0) main_layout.addWidget(settings_icon, 0, 0) - main_layout.setColumnStretch(1, 1) - main_layout.setRowStretch(1, 1) + main_layout.setColumnStretch(0, 1) + main_layout.setColumnStretch(1, 5) + self.setAttribute(QtCore.Qt.WA_TranslucentBackground, True) def enterEvent(self, event): From a52c02581608651bbe6b36779dfef39e5ed7770c Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 20 Jun 2025 11:00:19 +0200 Subject: [PATCH 03/22] store settings variable --- client/ayon_core/tools/launcher/ui/actions_widget.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/ayon_core/tools/launcher/ui/actions_widget.py b/client/ayon_core/tools/launcher/ui/actions_widget.py index 32069ee807..4e3a604d44 100644 --- a/client/ayon_core/tools/launcher/ui/actions_widget.py +++ b/client/ayon_core/tools/launcher/ui/actions_widget.py @@ -116,6 +116,8 @@ class ActionOverlayWidget(QtWidgets.QFrame): self.setAttribute(QtCore.Qt.WA_TranslucentBackground, True) + self._settings_icon = settings_icon + def enterEvent(self, event): super().enterEvent(event) self._settings_icon.setVisible(True) From 5c515096af9a232dbd8e8183ac814fac024e4220 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 20 Jun 2025 11:31:48 +0200 Subject: [PATCH 04/22] better scaling method --- .../tools/launcher/ui/actions_widget.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/client/ayon_core/tools/launcher/ui/actions_widget.py b/client/ayon_core/tools/launcher/ui/actions_widget.py index 4e3a604d44..64d77e5b33 100644 --- a/client/ayon_core/tools/launcher/ui/actions_widget.py +++ b/client/ayon_core/tools/launcher/ui/actions_widget.py @@ -69,15 +69,12 @@ class LauncherSettingsLabel(QtWidgets.QWidget): return cls._settings_icon def paintEvent(self, event): - painter = QtGui.QPainter() - painter.begin(self) + painter = QtGui.QPainter(self) - render_hints = ( + painter.setRenderHints( QtGui.QPainter.Antialiasing | QtGui.QPainter.SmoothPixmapTransform ) - if hasattr(QtGui.QPainter, "HighQualityAntialiasing"): - render_hints |= QtGui.QPainter.HighQualityAntialiasing rect = event.rect() size = min(rect.height(), rect.width()) @@ -85,14 +82,11 @@ class LauncherSettingsLabel(QtWidgets.QWidget): rect.x(), rect.y(), size, size ) - pixmap = self._pixmap.scaled( - pix_rect.size(), - QtCore.Qt.KeepAspectRatio, - QtCore.Qt.SmoothTransformation - + src_rect = QtCore.QRect( + 0, 0, + self._pixmap.width(), self._pixmap.height() ) - painter.setRenderHints(render_hints) - painter.drawPixmap(0, 0, pixmap) + painter.drawPixmap(pix_rect, self._pixmap, src_rect) painter.end() From 92fc2caaf4cc504ef03b15ad1ab45e4603f9eaab Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 20 Jun 2025 11:44:16 +0200 Subject: [PATCH 05/22] fix icons resizing --- .../tools/launcher/ui/actions_widget.py | 57 +++++-------------- 1 file changed, 14 insertions(+), 43 deletions(-) diff --git a/client/ayon_core/tools/launcher/ui/actions_widget.py b/client/ayon_core/tools/launcher/ui/actions_widget.py index 64d77e5b33..9a872941d3 100644 --- a/client/ayon_core/tools/launcher/ui/actions_widget.py +++ b/client/ayon_core/tools/launcher/ui/actions_widget.py @@ -16,7 +16,6 @@ from ayon_core.lib.attribute_definitions import ( from ayon_core.tools.flickcharm import FlickCharm from ayon_core.tools.utils import ( get_qt_icon, - PixmapLabel, ) from ayon_core.tools.attribute_defs import AttributeDefinitionsDialog from ayon_core.tools.launcher.abstract import WebactionContext @@ -54,11 +53,6 @@ def _variant_label_sort_getter(action_item): class LauncherSettingsLabel(QtWidgets.QWidget): _settings_icon = None - def __init__(self, parent): - super().__init__(parent) - icon = self._get_settings_icon() - self._pixmap = icon.pixmap(64, 64) - @classmethod def _get_settings_icon(cls): if cls._settings_icon is None: @@ -82,11 +76,8 @@ class LauncherSettingsLabel(QtWidgets.QWidget): rect.x(), rect.y(), size, size ) - src_rect = QtCore.QRect( - 0, 0, - self._pixmap.width(), self._pixmap.height() - ) - painter.drawPixmap(pix_rect, self._pixmap, src_rect) + pix = self._get_settings_icon().pixmap(size, size) + painter.drawPixmap(pix_rect, pix) painter.end() @@ -626,8 +617,7 @@ class ActionMenuPopup(QtWidgets.QWidget): class ActionDelegate(QtWidgets.QStyledItemDelegate): - _cached_extender = {} - _cached_extender_base_pix = None + _extender_icon = None def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -687,27 +677,13 @@ class ActionDelegate(QtWidgets.QStyledItemDelegate): painter.restore() @classmethod - def _get_extender_pixmap(cls, size): - pix = cls._cached_extender.get(size) - if pix is not None: - return pix - - base_pix = cls._cached_extender_base_pix - if base_pix is None: - icon = get_qt_icon({ + def _get_extender_pixmap(cls): + if cls._extender_icon is None: + cls._extender_icon = get_qt_icon({ "type": "material-symbols", "name": "more_horiz", }) - base_pix = icon.pixmap(64, 64) - cls._cached_extender_base_pix = base_pix - - pix = base_pix.scaled( - size, size, - QtCore.Qt.KeepAspectRatio, - QtCore.Qt.SmoothTransformation - ) - cls._cached_extender[size] = pix - return pix + return cls._extender_icon def paint(self, painter, option, index): painter.setRenderHints( @@ -724,20 +700,15 @@ class ActionDelegate(QtWidgets.QStyledItemDelegate): return grid_size = option.widget.gridSize() - x_offset = int( - (grid_size.width() / 2) - - (option.rect.width() / 2) - ) - item_x = option.rect.x() - x_offset - tenth_size = int(grid_size.width() / 10) - extender_size = int(tenth_size * 2.4) + extender_rect = option.rect.adjusted(5, 5, 0, 0) + extender_size = grid_size.width() // 6 + extender_rect.setWidth(extender_size) + extender_rect.setHeight(extender_size) - extender_x = item_x + tenth_size - extender_y = option.rect.y() + tenth_size - - pix = self._get_extender_pixmap(extender_size) - painter.drawPixmap(extender_x, extender_y, pix) + icon = self._get_extender_pixmap() + pix = icon.pixmap(extender_size, extender_size) + painter.drawPixmap(extender_rect, pix) class ActionsProxyModel(QtCore.QSortFilterProxyModel): From 3f8f0b17c827e062c8d77dfef8427c7867ec7f18 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 20 Jun 2025 13:25:23 +0200 Subject: [PATCH 06/22] show popup on click --- .../tools/launcher/ui/actions_widget.py | 70 +++++++------------ 1 file changed, 26 insertions(+), 44 deletions(-) diff --git a/client/ayon_core/tools/launcher/ui/actions_widget.py b/client/ayon_core/tools/launcher/ui/actions_widget.py index 9a872941d3..ae9ef05730 100644 --- a/client/ayon_core/tools/launcher/ui/actions_widget.py +++ b/client/ayon_core/tools/launcher/ui/actions_widget.py @@ -744,7 +744,6 @@ class ActionsProxyModel(QtCore.QSortFilterProxyModel): class ActionsView(QtWidgets.QListView): - action_triggered = QtCore.Signal(str) config_requested = QtCore.Signal(str) def __init__(self, parent): @@ -778,18 +777,6 @@ class ActionsView(QtWidgets.QListView): self._overlay_widgets = [] self._flick = flick self._delegate = delegate - self._popup_widget = None - - def mouseMoveEvent(self, event): - """Handle mouse move event.""" - super().mouseMoveEvent(event) - # Update hover state for the item under mouse - index = self.indexAt(event.pos()) - if index.isValid() and index.data(ACTION_IS_GROUP_ROLE): - self._show_group_popup(index) - - elif self._popup_widget is not None: - self._popup_widget.close() def _on_context_menu(self, point): """Creates menu to force skip opening last workfile.""" @@ -799,33 +786,6 @@ class ActionsView(QtWidgets.QListView): action_id = index.data(ACTION_ID_ROLE) self.config_requested.emit(action_id) - def _get_popup_widget(self): - if self._popup_widget is None: - popup_widget = ActionMenuPopup(self) - - popup_widget.action_triggered.connect(self.action_triggered) - popup_widget.config_requested.connect(self.config_requested) - self._popup_widget = popup_widget - return self._popup_widget - - def _show_group_popup(self, index): - action_id = index.data(ACTION_ID_ROLE) - model = self.model() - while hasattr(model, "sourceModel"): - model = model.sourceModel() - - if not hasattr(model, "get_group_items"): - return - - action_items = model.get_group_items(action_id) - rect = self.visualRect(index) - pos = self.mapToGlobal(rect.topLeft()) - - popup_widget = self._get_popup_widget() - popup_widget.show_items( - action_id, action_items, pos - ) - def update_on_refresh(self): viewport = self.viewport() viewport.update() @@ -882,7 +842,6 @@ class ActionsWidget(QtWidgets.QWidget): animation_timer.timeout.connect(self._on_animation) view.clicked.connect(self._on_clicked) - view.action_triggered.connect(self._trigger_action) view.config_requested.connect(self._on_config_request) model.refreshed.connect(self._on_model_refresh) @@ -893,6 +852,8 @@ class ActionsWidget(QtWidgets.QWidget): self._model = model self._proxy_model = proxy_model + self._popup_widget = None + self._set_row_height(1) def refresh(self): @@ -979,10 +940,31 @@ class ActionsWidget(QtWidgets.QWidget): return is_group = index.data(ACTION_IS_GROUP_ROLE) - if is_group: - return action_id = index.data(ACTION_ID_ROLE) - self._trigger_action(action_id, index) + if is_group: + self._show_group_popup(index) + else: + self._trigger_action(action_id, index) + + def _get_popup_widget(self): + if self._popup_widget is None: + popup_widget = ActionMenuPopup(self) + + popup_widget.action_triggered.connect(self._trigger_action) + popup_widget.config_requested.connect(self._on_config_request) + self._popup_widget = popup_widget + return self._popup_widget + + def _show_group_popup(self, index): + action_id = index.data(ACTION_ID_ROLE) + action_items = self._model.get_group_items(action_id) + rect = self._view.visualRect(index) + pos = self.mapToGlobal(rect.topLeft()) + + popup_widget = self._get_popup_widget() + popup_widget.show_items( + action_id, action_items, pos + ) def _trigger_action(self, action_id, index=None): project_name = self._model.get_selected_project_name() From e417a2a335e0d8d496b38742942f8990a93515e1 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 20 Jun 2025 13:42:43 +0200 Subject: [PATCH 07/22] get rid of mode property --- client/ayon_core/style/style.css | 10 +++++----- client/ayon_core/tools/launcher/ui/actions_widget.py | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/client/ayon_core/style/style.css b/client/ayon_core/style/style.css index 4ef903540e..375545e90b 100644 --- a/client/ayon_core/style/style.css +++ b/client/ayon_core/style/style.css @@ -829,7 +829,7 @@ HintedLineEditButton { } /* Launcher specific stylesheets */ -ActionsView[mode="icon"] { +ActionsView { /* font size can't be set on items */ font-size: 9pt; border: 0px; @@ -837,25 +837,25 @@ ActionsView[mode="icon"] { margin: 0px; } -ActionsView[mode="icon"]::item { +ActionsView::item { padding-top: 8px; padding-bottom: 4px; border: 0px; border-radius: 0.3em; } -ActionsView[mode="icon"]::item:hover { +ActionsView::item:hover { color: {color:font-hover}; background: #424A57; } -ActionsView[mode="icon"]::icon {} +ActionsView::icon {} ActionMenuPopup #Wrapper { border-radius: 0.3em; background: #353B46; } -ActionMenuPopup ActionsView[mode="icon"] { +ActionMenuPopup ActionsView { background: transparent; border: none; } diff --git a/client/ayon_core/tools/launcher/ui/actions_widget.py b/client/ayon_core/tools/launcher/ui/actions_widget.py index ae9ef05730..f90fa1ec4a 100644 --- a/client/ayon_core/tools/launcher/ui/actions_widget.py +++ b/client/ayon_core/tools/launcher/ui/actions_widget.py @@ -748,7 +748,6 @@ class ActionsView(QtWidgets.QListView): def __init__(self, parent): super().__init__(parent) - self.setProperty("mode", "icon") self.setViewMode(QtWidgets.QListView.IconMode) self.setResizeMode(QtWidgets.QListView.Adjust) self.setSelectionMode(QtWidgets.QListView.NoSelection) From 03748aeb3bc11c0de9ded42ae25fe6733bbc6e79 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 20 Jun 2025 14:39:26 +0200 Subject: [PATCH 08/22] show config fields dialog under mouse --- .../tools/launcher/ui/actions_widget.py | 54 +++++++++++++------ 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/client/ayon_core/tools/launcher/ui/actions_widget.py b/client/ayon_core/tools/launcher/ui/actions_widget.py index f90fa1ec4a..28c741c93a 100644 --- a/client/ayon_core/tools/launcher/ui/actions_widget.py +++ b/client/ayon_core/tools/launcher/ui/actions_widget.py @@ -83,8 +83,6 @@ class LauncherSettingsLabel(QtWidgets.QWidget): class ActionOverlayWidget(QtWidgets.QFrame): - config_requested = QtCore.Signal(str) - def __init__(self, item_id, parent): super().__init__(parent) self._item_id = item_id @@ -163,6 +161,12 @@ class ActionsQtModel(QtGui.QStandardItemModel): def get_item_by_id(self, action_id): return self._items_by_id.get(action_id) + def get_index_by_id(self, action_id): + item = self.get_item_by_id(action_id) + if item is not None: + return self.indexFromItem(item) + return QtCore.QModelIndex() + def get_group_item_by_action_id(self, action_id): item = self._items_by_id.get(action_id) if item is not None: @@ -370,7 +374,7 @@ class ActionMenuPopupModel(QtGui.QStandardItemModel): class ActionMenuPopup(QtWidgets.QWidget): action_triggered = QtCore.Signal(str) - config_requested = QtCore.Signal(str) + config_requested = QtCore.Signal(str, QtCore.QPoint) def __init__(self, parent): super().__init__(parent) @@ -412,7 +416,7 @@ class ActionMenuPopup(QtWidgets.QWidget): expand_anim.finished.connect(self._on_expand_finish) view.clicked.connect(self._on_clicked) - view.config_requested.connect(self.config_requested) + view.config_requested.connect(self._on_configs_trigger) self._view = view self._wrapper = wrapper @@ -611,8 +615,8 @@ class ActionMenuPopup(QtWidgets.QWidget): self.action_triggered.emit(action_id) self.close() - def _on_configs_trigger(self, action_id): - self.config_requested.emit(action_id) + def _on_configs_trigger(self, action_id, center_pos): + self.config_requested.emit(action_id, center_pos) self.close() @@ -744,7 +748,7 @@ class ActionsProxyModel(QtCore.QSortFilterProxyModel): class ActionsView(QtWidgets.QListView): - config_requested = QtCore.Signal(str) + config_requested = QtCore.Signal(str, QtCore.QPoint) def __init__(self, parent): super().__init__(parent) @@ -783,7 +787,9 @@ class ActionsView(QtWidgets.QListView): if not index.isValid(): return action_id = index.data(ACTION_ID_ROLE) - self.config_requested.emit(action_id) + rect = self.visualRect(index) + global_center = self.mapToGlobal(rect.center()) + self.config_requested.emit(action_id, global_center) def update_on_refresh(self): viewport = self.viewport() @@ -801,9 +807,6 @@ class ActionsView(QtWidgets.QListView): if has_configs: item_id = index.data(ACTION_ID_ROLE) widget = ActionOverlayWidget(item_id, viewport) - widget.config_requested.connect( - self.config_requested - ) overlay_widgets.append(widget) self.setIndexWidget(index, widget) @@ -841,7 +844,7 @@ class ActionsWidget(QtWidgets.QWidget): animation_timer.timeout.connect(self._on_animation) view.clicked.connect(self._on_clicked) - view.config_requested.connect(self._on_config_request) + view.config_requested.connect(self._show_config_dialog) model.refreshed.connect(self._on_model_refresh) self._animated_items = set() @@ -950,7 +953,7 @@ class ActionsWidget(QtWidgets.QWidget): popup_widget = ActionMenuPopup(self) popup_widget.action_triggered.connect(self._trigger_action) - popup_widget.config_requested.connect(self._on_config_request) + popup_widget.config_requested.connect(self._show_config_dialog) self._popup_widget = popup_widget return self._popup_widget @@ -997,10 +1000,7 @@ class ActionsWidget(QtWidgets.QWidget): if index is not None: self._start_animation(index) - def _on_config_request(self, action_id): - self._show_config_dialog(action_id) - - def _show_config_dialog(self, action_id): + def _show_config_dialog(self, action_id, center_point): action_item = self._model.get_action_item_by_id(action_id) config_fields = self._model.get_action_config_fields(action_id) if not config_fields: @@ -1026,11 +1026,31 @@ class ActionsWidget(QtWidgets.QWidget): "Cancel", ) dialog.set_values(values) + dialog.show() + self._center_dialog(dialog, center_point) result = dialog.exec_() if result == QtWidgets.QDialog.Accepted: new_values = dialog.get_values() self._controller.set_action_config_values(context, new_values) + @staticmethod + def _center_dialog(dialog, target_center_pos): + dialog_geo = dialog.geometry() + dialog_geo.moveCenter(target_center_pos) + + screen = dialog.screen() + screen_geo = screen.availableGeometry() + if screen_geo.left() > dialog_geo.left(): + dialog_geo.moveLeft(screen_geo.left()) + elif screen_geo.right() < dialog_geo.right(): + dialog_geo.moveRight(screen_geo.right()) + + if screen_geo.top() > dialog_geo.top(): + dialog_geo.moveTop(screen_geo.top()) + elif screen_geo.bottom() < dialog_geo.bottom(): + dialog_geo.moveBottom(screen_geo.bottom()) + dialog.move(dialog_geo.topLeft()) + def _create_attrs_dialog( self, config_fields, From 5bc3529434e15b62bd8e08a16e7891b6e4c99f27 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 20 Jun 2025 15:07:25 +0200 Subject: [PATCH 09/22] make font smaller --- client/ayon_core/style/style.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/style/style.css b/client/ayon_core/style/style.css index 375545e90b..6f47a34956 100644 --- a/client/ayon_core/style/style.css +++ b/client/ayon_core/style/style.css @@ -831,7 +831,7 @@ HintedLineEditButton { /* Launcher specific stylesheets */ ActionsView { /* font size can't be set on items */ - font-size: 9pt; + font-size: 8pt; border: 0px; padding: 0px; margin: 0px; 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 10/22] 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 From 0f32e26c7590185b81f95b42c035a52a1ed2833a Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 20 Jun 2025 16:21:20 +0200 Subject: [PATCH 11/22] added shadow frame --- client/ayon_core/style/style.css | 9 +++- .../tools/launcher/ui/actions_widget.py | 54 +++++++++++++------ 2 files changed, 44 insertions(+), 19 deletions(-) diff --git a/client/ayon_core/style/style.css b/client/ayon_core/style/style.css index 9a86bef960..5f661274af 100644 --- a/client/ayon_core/style/style.css +++ b/client/ayon_core/style/style.css @@ -841,7 +841,7 @@ ActionsView::item { padding-top: 8px; padding-bottom: 4px; border: 0px; - border-radius: 0.3em; + border-radius: 5px; } ActionsView::item:hover { @@ -851,8 +851,13 @@ ActionsView::item:hover { ActionsView::icon {} +ActionMenuPopup #ShadowFrame { + border-radius: 5px; + background: rgba(0, 0, 0, 0.3); +} + ActionMenuPopup #Wrapper { - border-radius: 0.3em; + border-radius: 5px; background: #353B46; } diff --git a/client/ayon_core/tools/launcher/ui/actions_widget.py b/client/ayon_core/tools/launcher/ui/actions_widget.py index 6a16dd9f8e..0e2a56babf 100644 --- a/client/ayon_core/tools/launcher/ui/actions_widget.py +++ b/client/ayon_core/tools/launcher/ui/actions_widget.py @@ -21,6 +21,7 @@ from ayon_core.tools.attribute_defs import AttributeDefinitionsDialog from ayon_core.tools.launcher.abstract import WebactionContext ANIMATION_LEN = 7 +SHADOW_FRAME_MARGINS = (2, 2, 2, 2) ACTION_ID_ROLE = QtCore.Qt.UserRole + 1 ACTION_TYPE_ROLE = QtCore.Qt.UserRole + 2 @@ -392,15 +393,25 @@ class ActionMenuPopup(QtWidgets.QWidget): expand_anim.setDuration(60) expand_anim.setEasingCurve(QtCore.QEasingCurve.InOutQuad) + sh_l, sh_t, sh_r, sh_b = SHADOW_FRAME_MARGINS + # View with actions view = ActionsView(self) view.setGridSize(QtCore.QSize(75, 80)) view.setIconSize(QtCore.QSize(32, 32)) + view.move(QtCore.QPoint(sh_l, sh_t)) # Background draw + bg_frame = QtWidgets.QFrame(self) + bg_frame.setObjectName("ShadowFrame") + bg_frame.stackUnder(view) + wrapper = QtWidgets.QFrame(self) wrapper.setObjectName("Wrapper") - wrapper.stackUnder(view) + + bg_layout = QtWidgets.QVBoxLayout(bg_frame) + bg_layout.setContentsMargins(sh_l, sh_t, sh_r, sh_b) + bg_layout.addWidget(wrapper) model = ActionMenuPopupModel() proxy_model = ActionsProxyModel() @@ -418,7 +429,7 @@ class ActionMenuPopup(QtWidgets.QWidget): view.config_requested.connect(self._on_configs_trigger) self._view = view - self._wrapper = wrapper + self._bg_frame = bg_frame self._model = model self._proxy_model = proxy_model @@ -484,22 +495,23 @@ class ActionMenuPopup(QtWidgets.QWidget): or pos.y() + target_size.height() > window_geo.bottom() ) + sh_l, sh_t, sh_r, sh_b = SHADOW_FRAME_MARGINS viewport_offset = self._view.viewport().geometry().topLeft() - pos_x = pos.x() - (viewport_offset.x() + 2) - pos_y = pos.y() - (viewport_offset.y() + 1) + pos_x = pos.x() - (sh_l + viewport_offset.x() + 2) + pos_y = pos.y() - (sh_t + viewport_offset.y() + 1) - wrap_x = wrap_y = 0 + bg_x = bg_y = 0 sort_order = QtCore.Qt.DescendingOrder if right_to_left: sort_order = QtCore.Qt.AscendingOrder size_diff = target_size - size pos_x -= size_diff.width() pos_y -= size_diff.height() - wrap_x = size_diff.width() - wrap_y = size_diff.height() + bg_x = size_diff.width() + bg_y = size_diff.height() - wrap_geo = QtCore.QRect( - wrap_x, wrap_y, size.width(), size.height() + bg_geo = QtCore.QRect( + bg_x, bg_y, size.width(), size.height() ) if self._expand_anim.state() == QtCore.QAbstractAnimation.Running: self._expand_anim.stop() @@ -508,10 +520,10 @@ class ActionMenuPopup(QtWidgets.QWidget): self._proxy_model.sort(0, sort_order) self.setUpdatesEnabled(False) - self._view.setMask(wrap_geo) + self._view.setMask(bg_geo.adjusted(sh_l, sh_t, -sh_r, -sh_b)) self._view.setMinimumWidth(target_size.width()) self._view.setMaximumWidth(target_size.width()) - self._wrapper.setGeometry(wrap_geo) + self._bg_frame.setGeometry(bg_geo) self.setGeometry( pos_x, pos_y, target_size.width(), target_size.height() @@ -540,9 +552,9 @@ class ActionMenuPopup(QtWidgets.QWidget): self._expand_anim.stop() return - wrapper_geo = self._wrapper.geometry() - wrapper_geo.setWidth(value.width()) - wrapper_geo.setHeight(value.height()) + bg_geo = self._bg_frame.geometry() + bg_geo.setWidth(value.width()) + bg_geo.setHeight(value.height()) if self._right_to_left: geo = self.geometry() @@ -550,10 +562,11 @@ class ActionMenuPopup(QtWidgets.QWidget): geo.width() - value.width(), geo.height() - value.height(), ) - wrapper_geo.setTopLeft(pos) + bg_geo.setTopLeft(pos) - self._view.setMask(wrapper_geo) - self._wrapper.setGeometry(wrapper_geo) + sh_l, sh_t, sh_r, sh_b = SHADOW_FRAME_MARGINS + self._view.setMask(bg_geo.adjusted(sh_l, sh_t, -sh_r, -sh_b)) + self._bg_frame.setGeometry(bg_geo) def _on_expand_finish(self): # Make sure that size is recalculated if src and targe size is same @@ -582,6 +595,13 @@ class ActionMenuPopup(QtWidgets.QWidget): 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) + m_l, m_t, m_r, m_b = ( + s_m + vp_m + for s_m, vp_m in zip( + SHADOW_FRAME_MARGINS, + (vp_lr, vp_tb, vp_lr, vp_tb) + ) + ) single_width = ( grid_size.width() + self._view.horizontalOffset() + m_l + m_r + 1 From 56fd29f20a58dc73c313789f750d84b1944fb099 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 20 Jun 2025 16:21:54 +0200 Subject: [PATCH 12/22] remove unnecessary line --- client/ayon_core/tools/launcher/ui/actions_widget.py | 1 - 1 file changed, 1 deletion(-) diff --git a/client/ayon_core/tools/launcher/ui/actions_widget.py b/client/ayon_core/tools/launcher/ui/actions_widget.py index 0e2a56babf..334107680b 100644 --- a/client/ayon_core/tools/launcher/ui/actions_widget.py +++ b/client/ayon_core/tools/launcher/ui/actions_widget.py @@ -594,7 +594,6 @@ class ActionMenuPopup(QtWidgets.QWidget): # 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) m_l, m_t, m_r, m_b = ( s_m + vp_m for s_m, vp_m in zip( From 0df7ff3338487c9e1d3b73f0c0f1fb5b95d6ecfa Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 20 Jun 2025 16:29:38 +0200 Subject: [PATCH 13/22] added TextAntialiasing hint --- client/ayon_core/tools/launcher/ui/actions_widget.py | 1 + 1 file changed, 1 insertion(+) diff --git a/client/ayon_core/tools/launcher/ui/actions_widget.py b/client/ayon_core/tools/launcher/ui/actions_widget.py index 334107680b..20e9903f97 100644 --- a/client/ayon_core/tools/launcher/ui/actions_widget.py +++ b/client/ayon_core/tools/launcher/ui/actions_widget.py @@ -714,6 +714,7 @@ class ActionDelegate(QtWidgets.QStyledItemDelegate): def paint(self, painter, option, index): painter.setRenderHints( QtGui.QPainter.Antialiasing + | QtGui.QPainter.TextAntialiasing | QtGui.QPainter.SmoothPixmapTransform ) From bf6ac48a66e5dcdf5f06af42007250eccc9a7423 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 23 Jun 2025 14:06:26 +0200 Subject: [PATCH 14/22] better shadow --- client/ayon_core/style/style.css | 2 +- client/ayon_core/tools/launcher/ui/actions_widget.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/style/style.css b/client/ayon_core/style/style.css index 5f661274af..2e3bf3954f 100644 --- a/client/ayon_core/style/style.css +++ b/client/ayon_core/style/style.css @@ -853,7 +853,7 @@ ActionsView::icon {} ActionMenuPopup #ShadowFrame { border-radius: 5px; - background: rgba(0, 0, 0, 0.3); + background: rgba(12, 13, 24, 0.5); } ActionMenuPopup #Wrapper { diff --git a/client/ayon_core/tools/launcher/ui/actions_widget.py b/client/ayon_core/tools/launcher/ui/actions_widget.py index 20e9903f97..8c5c7c7062 100644 --- a/client/ayon_core/tools/launcher/ui/actions_widget.py +++ b/client/ayon_core/tools/launcher/ui/actions_widget.py @@ -21,7 +21,7 @@ from ayon_core.tools.attribute_defs import AttributeDefinitionsDialog from ayon_core.tools.launcher.abstract import WebactionContext ANIMATION_LEN = 7 -SHADOW_FRAME_MARGINS = (2, 2, 2, 2) +SHADOW_FRAME_MARGINS = (1, 1, 1, 1) ACTION_ID_ROLE = QtCore.Qt.UserRole + 1 ACTION_TYPE_ROLE = QtCore.Qt.UserRole + 2 @@ -409,6 +409,10 @@ class ActionMenuPopup(QtWidgets.QWidget): wrapper = QtWidgets.QFrame(self) wrapper.setObjectName("Wrapper") + effect = QtWidgets.QGraphicsBlurEffect(wrapper) + effect.setBlurRadius(3.0) + wrapper.setGraphicsEffect(effect) + bg_layout = QtWidgets.QVBoxLayout(bg_frame) bg_layout.setContentsMargins(sh_l, sh_t, sh_r, sh_b) bg_layout.addWidget(wrapper) @@ -430,6 +434,7 @@ class ActionMenuPopup(QtWidgets.QWidget): self._view = view self._bg_frame = bg_frame + self._effect = effect self._model = model self._proxy_model = proxy_model From b47496e47e9300f5e8f23de0cd884dfe428dbc3b Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 23 Jun 2025 14:12:25 +0200 Subject: [PATCH 15/22] define minimum view height --- client/ayon_core/tools/launcher/ui/actions_widget.py | 1 + 1 file changed, 1 insertion(+) diff --git a/client/ayon_core/tools/launcher/ui/actions_widget.py b/client/ayon_core/tools/launcher/ui/actions_widget.py index 8c5c7c7062..953821d778 100644 --- a/client/ayon_core/tools/launcher/ui/actions_widget.py +++ b/client/ayon_core/tools/launcher/ui/actions_widget.py @@ -528,6 +528,7 @@ class ActionMenuPopup(QtWidgets.QWidget): self._view.setMask(bg_geo.adjusted(sh_l, sh_t, -sh_r, -sh_b)) self._view.setMinimumWidth(target_size.width()) self._view.setMaximumWidth(target_size.width()) + self._view.setMinimumHeight(target_size.height()) self._bg_frame.setGeometry(bg_geo) self.setGeometry( pos_x, pos_y, From 953c584381610b6be3e12ea68faf9294a72a8e7b Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 23 Jun 2025 15:05:44 +0200 Subject: [PATCH 16/22] show tooltips for actions --- client/ayon_core/tools/launcher/ui/actions_widget.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/tools/launcher/ui/actions_widget.py b/client/ayon_core/tools/launcher/ui/actions_widget.py index 953821d778..118debe123 100644 --- a/client/ayon_core/tools/launcher/ui/actions_widget.py +++ b/client/ayon_core/tools/launcher/ui/actions_widget.py @@ -252,7 +252,7 @@ class ActionsQtModel(QtGui.QStandardItemModel): item.setFlags(QtCore.Qt.ItemIsEnabled) item.setData(label, QtCore.Qt.DisplayRole) - # item.setData(label, QtCore.Qt.ToolTipRole) + item.setData(label, QtCore.Qt.ToolTipRole) item.setData(icon, QtCore.Qt.DecorationRole) item.setData(is_group, ACTION_IS_GROUP_ROLE) item.setData(has_configs, ACTION_HAS_CONFIGS_ROLE) @@ -325,8 +325,8 @@ class ActionMenuPopupModel(QtGui.QStandardItemModel): item = QtGui.QStandardItem() item.setFlags(QtCore.Qt.ItemIsEnabled) - # item.setData(action_item.full_label, QtCore.Qt.ToolTipRole) item.setData(action_item.full_label, QtCore.Qt.DisplayRole) + item.setData(action_item.full_label, QtCore.Qt.ToolTipRole) item.setData(icon, QtCore.Qt.DecorationRole) item.setData(action_item.identifier, ACTION_ID_ROLE) item.setData( From 0f4718beb545e54d16c1db02093a76026a04ce46 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 24 Jun 2025 17:40:21 +0200 Subject: [PATCH 17/22] always update positions and set default geometry --- client/ayon_core/tools/launcher/ui/actions_widget.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/client/ayon_core/tools/launcher/ui/actions_widget.py b/client/ayon_core/tools/launcher/ui/actions_widget.py index 118debe123..c5f66aa5f7 100644 --- a/client/ayon_core/tools/launcher/ui/actions_widget.py +++ b/client/ayon_core/tools/launcher/ui/actions_widget.py @@ -470,21 +470,15 @@ class ActionMenuPopup(QtWidgets.QWidget): self._close_timer.stop() - update_position = False if action_id != self._current_id: - update_position = True + self.setGeometry(pos.x(), pos.y(), 1, 1) self._current_id = action_id self._update_items(action_items) # Make sure is visible if not self._showed: - update_position = True self.show() - if not update_position: - self.raise_() - return - # Set geometry to position # - first make sure widget changes from '_update_items' # are recalculated From bdbbb218f8213db38e407e2fc7bf03cb9066f206 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 24 Jun 2025 17:40:32 +0200 Subject: [PATCH 18/22] use variant label --- client/ayon_core/tools/launcher/ui/actions_widget.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/tools/launcher/ui/actions_widget.py b/client/ayon_core/tools/launcher/ui/actions_widget.py index c5f66aa5f7..ac00e7fe85 100644 --- a/client/ayon_core/tools/launcher/ui/actions_widget.py +++ b/client/ayon_core/tools/launcher/ui/actions_widget.py @@ -325,7 +325,7 @@ class ActionMenuPopupModel(QtGui.QStandardItemModel): item = QtGui.QStandardItem() item.setFlags(QtCore.Qt.ItemIsEnabled) - item.setData(action_item.full_label, QtCore.Qt.DisplayRole) + item.setData(action_item.variant_label, QtCore.Qt.DisplayRole) item.setData(action_item.full_label, QtCore.Qt.ToolTipRole) item.setData(icon, QtCore.Qt.DecorationRole) item.setData(action_item.identifier, ACTION_ID_ROLE) From 5eba658bd15e32fc24b0d694252543fdb8dcc8c5 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 24 Jun 2025 17:42:05 +0200 Subject: [PATCH 19/22] adde group label showed on top of popup --- client/ayon_core/style/style.css | 6 ++ .../tools/launcher/ui/actions_widget.py | 90 ++++++++++++++----- 2 files changed, 72 insertions(+), 24 deletions(-) diff --git a/client/ayon_core/style/style.css b/client/ayon_core/style/style.css index 2e3bf3954f..97aef4ff91 100644 --- a/client/ayon_core/style/style.css +++ b/client/ayon_core/style/style.css @@ -851,6 +851,12 @@ ActionsView::item:hover { ActionsView::icon {} +ActionMenuPopup #GroupLabel { + padding: 5px; + border-radius: 3px; + background: #1C2C40; + color: #ffffff; +} ActionMenuPopup #ShadowFrame { border-radius: 5px; background: rgba(12, 13, 24, 0.5); diff --git a/client/ayon_core/tools/launcher/ui/actions_widget.py b/client/ayon_core/tools/launcher/ui/actions_widget.py index ac00e7fe85..5ad539ffca 100644 --- a/client/ayon_core/tools/launcher/ui/actions_widget.py +++ b/client/ayon_core/tools/launcher/ui/actions_widget.py @@ -395,12 +395,17 @@ class ActionMenuPopup(QtWidgets.QWidget): sh_l, sh_t, sh_r, sh_b = SHADOW_FRAME_MARGINS + group_label = QtWidgets.QLabel("|", self) + group_label.setObjectName("GroupLabel") + # View with actions view = ActionsView(self) view.setGridSize(QtCore.QSize(75, 80)) view.setIconSize(QtCore.QSize(32, 32)) view.move(QtCore.QPoint(sh_l, sh_t)) + view.stackUnder(group_label) + # Background draw bg_frame = QtWidgets.QFrame(self) bg_frame.setObjectName("ShadowFrame") @@ -432,6 +437,7 @@ class ActionMenuPopup(QtWidgets.QWidget): view.clicked.connect(self._on_clicked) view.config_requested.connect(self._on_configs_trigger) + self._group_label = group_label self._view = view self._bg_frame = bg_frame self._effect = effect @@ -461,7 +467,8 @@ class ActionMenuPopup(QtWidgets.QWidget): super().leaveEvent(event) self._close_timer.start() - def show_items(self, action_id, action_items, pos): + def show_items(self, group_label, action_id, action_items, pos): + self._group_label.setText(group_label) if not action_items: if self._showed: self._close_timer.start() @@ -484,53 +491,62 @@ class ActionMenuPopup(QtWidgets.QWidget): # are recalculated app = QtWidgets.QApplication.instance() app.processEvents() - items_count, size, target_size = self._get_size_hint() + items_count, start_size, target_size = self._get_size_hint() self._model.fill_to_count(items_count) + label_y_offset = self._get_label_y_offset() window = self.screen() window_geo = window.geometry() + _target_x = pos.x() + target_size.width() + _target_y = pos.y() + target_size.height() + label_y_offset right_to_left = ( - pos.x() + target_size.width() > window_geo.right() - or pos.y() + target_size.height() > window_geo.bottom() + _target_x > window_geo.right() + or _target_y > window_geo.bottom() ) sh_l, sh_t, sh_r, sh_b = SHADOW_FRAME_MARGINS viewport_offset = self._view.viewport().geometry().topLeft() pos_x = pos.x() - (sh_l + viewport_offset.x() + 2) pos_y = pos.y() - (sh_t + viewport_offset.y() + 1) - - bg_x = bg_y = 0 + bg_x = 0 + bg_y = label_y_offset sort_order = QtCore.Qt.DescendingOrder if right_to_left: sort_order = QtCore.Qt.AscendingOrder - size_diff = target_size - size + size_diff = target_size - start_size pos_x -= size_diff.width() pos_y -= size_diff.height() bg_x = size_diff.width() - bg_y = size_diff.height() bg_geo = QtCore.QRect( - bg_x, bg_y, size.width(), size.height() + bg_x, bg_y, start_size.width(), start_size.height() ) if self._expand_anim.state() == QtCore.QAbstractAnimation.Running: self._expand_anim.stop() - self._first_anim_frame = True + self._right_to_left = right_to_left self._proxy_model.sort(0, sort_order) self.setUpdatesEnabled(False) - self._view.setMask(bg_geo.adjusted(sh_l, sh_t, -sh_r, -sh_b)) + self._view.setMask( + bg_geo.adjusted( + sh_l, sh_t - label_y_offset, + -sh_r, -(sh_b + label_y_offset) + ) + ) self._view.setMinimumWidth(target_size.width()) self._view.setMaximumWidth(target_size.width()) self._view.setMinimumHeight(target_size.height()) - self._bg_frame.setGeometry(bg_geo) + self._view.move(0, label_y_offset) self.setGeometry( - pos_x, pos_y, - target_size.width(), target_size.height() + pos_x, pos_y - label_y_offset, + target_size.width(), target_size.height() + label_y_offset ) + self._bg_frame.setGeometry(bg_geo) self.setUpdatesEnabled(True) + self._expand_anim.updateCurrentTime(0) - self._expand_anim.setStartValue(size) + self._expand_anim.setStartValue(start_size) self._expand_anim.setEndValue(target_size) self._expand_anim.start() @@ -546,6 +562,11 @@ class ActionMenuPopup(QtWidgets.QWidget): action_id = index.data(ACTION_ID_ROLE) self.action_triggered.emit(action_id) + def _get_label_y_offset(self): + height = self._group_label.sizeHint().height() + # Is over view but does not cover the settings icon + return height - 5 + def _on_expand_anim(self, value): if not self._showed: if self._expand_anim.state() == QtCore.QAbstractAnimation.Running: @@ -553,20 +574,40 @@ class ActionMenuPopup(QtWidgets.QWidget): return bg_geo = self._bg_frame.geometry() + + label_y_offset = self._get_label_y_offset() + if self._right_to_left: + popup_geo = self.geometry() + diff_size = popup_geo.size() - value + pos = QtCore.QPoint( + diff_size.width(), diff_size.height() + ) + + bg_geo.moveTopLeft(pos) + bg_geo.setWidth(value.width()) bg_geo.setHeight(value.height()) - if self._right_to_left: - geo = self.geometry() - pos = QtCore.QPoint( - geo.width() - value.width(), - geo.height() - value.height(), - ) - bg_geo.setTopLeft(pos) + label_width = self._group_label.sizeHint().width() + label_pos_x = 0 + bgeo_tl = bg_geo.topLeft() + label_pos_y = bgeo_tl.y() - label_y_offset + if label_width < value.width(): + label_pos_x = bgeo_tl.x() + (value.width() - label_width) // 2 + + label_pos = QtCore.QPoint(label_pos_x, label_pos_y) sh_l, sh_t, sh_r, sh_b = SHADOW_FRAME_MARGINS - self._view.setMask(bg_geo.adjusted(sh_l, sh_t, -sh_r, -sh_b)) + self.setUpdatesEnabled(False) + self._view.setMask( + bg_geo.adjusted( + sh_l, sh_t - label_y_offset, + -sh_r, -(sh_b + label_y_offset) + ) + ) + self._group_label.move(label_pos) self._bg_frame.setGeometry(bg_geo) + self.setUpdatesEnabled(True) def _on_expand_finish(self): # Make sure that size is recalculated if src and targe size is same @@ -982,13 +1023,14 @@ class ActionsWidget(QtWidgets.QWidget): def _show_group_popup(self, index): action_id = index.data(ACTION_ID_ROLE) + group_label = index.data(QtCore.Qt.DisplayRole) action_items = self._model.get_group_items(action_id) rect = self._view.visualRect(index) pos = self.mapToGlobal(rect.topLeft()) popup_widget = self._get_popup_widget() popup_widget.show_items( - action_id, action_items, pos + group_label, action_id, action_items, pos ) def _trigger_action(self, action_id, index=None): From 231958c21c3ebffb1a76efd7888491f3ed9eeb7a Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 24 Jun 2025 18:10:08 +0200 Subject: [PATCH 20/22] the label is painted over background --- client/ayon_core/style/style.css | 3 +- .../tools/launcher/ui/actions_widget.py | 57 +++++++++---------- 2 files changed, 28 insertions(+), 32 deletions(-) diff --git a/client/ayon_core/style/style.css b/client/ayon_core/style/style.css index 97aef4ff91..0179d10697 100644 --- a/client/ayon_core/style/style.css +++ b/client/ayon_core/style/style.css @@ -853,10 +853,9 @@ ActionsView::icon {} ActionMenuPopup #GroupLabel { padding: 5px; - border-radius: 3px; - background: #1C2C40; color: #ffffff; } + ActionMenuPopup #ShadowFrame { border-radius: 5px; background: rgba(12, 13, 24, 0.5); diff --git a/client/ayon_core/tools/launcher/ui/actions_widget.py b/client/ayon_core/tools/launcher/ui/actions_widget.py index 5ad539ffca..ddb1c20221 100644 --- a/client/ayon_core/tools/launcher/ui/actions_widget.py +++ b/client/ayon_core/tools/launcher/ui/actions_widget.py @@ -494,11 +494,12 @@ class ActionMenuPopup(QtWidgets.QWidget): items_count, start_size, target_size = self._get_size_hint() self._model.fill_to_count(items_count) - label_y_offset = self._get_label_y_offset() + label_sh = self._group_label.sizeHint() + label_width, label_height = label_sh.width(), label_sh.height() window = self.screen() window_geo = window.geometry() _target_x = pos.x() + target_size.width() - _target_y = pos.y() + target_size.height() + label_y_offset + _target_y = pos.y() + target_size.height() + label_height right_to_left = ( _target_x > window_geo.right() or _target_y > window_geo.bottom() @@ -508,8 +509,7 @@ class ActionMenuPopup(QtWidgets.QWidget): viewport_offset = self._view.viewport().geometry().topLeft() pos_x = pos.x() - (sh_l + viewport_offset.x() + 2) pos_y = pos.y() - (sh_t + viewport_offset.y() + 1) - bg_x = 0 - bg_y = label_y_offset + bg_x = bg_y = 0 sort_order = QtCore.Qt.DescendingOrder if right_to_left: sort_order = QtCore.Qt.AscendingOrder @@ -517,10 +517,18 @@ class ActionMenuPopup(QtWidgets.QWidget): pos_x -= size_diff.width() pos_y -= size_diff.height() bg_x = size_diff.width() + bg_y = size_diff.height() - label_height bg_geo = QtCore.QRect( - bg_x, bg_y, start_size.width(), start_size.height() + bg_x, bg_y, + start_size.width(), start_size.height() + label_height ) + + label_pos_x = sh_l + label_pos_y = bg_y + sh_t + if label_width < start_size.width(): + label_pos_x = bg_x + (start_size.width() - label_width) // 2 + if self._expand_anim.state() == QtCore.QAbstractAnimation.Running: self._expand_anim.stop() @@ -529,20 +537,18 @@ class ActionMenuPopup(QtWidgets.QWidget): self._proxy_model.sort(0, sort_order) self.setUpdatesEnabled(False) self._view.setMask( - bg_geo.adjusted( - sh_l, sh_t - label_y_offset, - -sh_r, -(sh_b + label_y_offset) - ) + bg_geo.adjusted(sh_l, sh_t, -sh_r, -sh_b) ) self._view.setMinimumWidth(target_size.width()) self._view.setMaximumWidth(target_size.width()) self._view.setMinimumHeight(target_size.height()) - self._view.move(0, label_y_offset) + self._view.move(0, label_height) self.setGeometry( - pos_x, pos_y - label_y_offset, - target_size.width(), target_size.height() + label_y_offset + pos_x, pos_y - label_height, + target_size.width(), target_size.height() + label_height ) self._bg_frame.setGeometry(bg_geo) + self._group_label.move(label_pos_x, label_pos_y) self.setUpdatesEnabled(True) self._expand_anim.updateCurrentTime(0) @@ -562,11 +568,6 @@ class ActionMenuPopup(QtWidgets.QWidget): action_id = index.data(ACTION_ID_ROLE) self.action_triggered.emit(action_id) - def _get_label_y_offset(self): - height = self._group_label.sizeHint().height() - # Is over view but does not cover the settings icon - return height - 5 - def _on_expand_anim(self, value): if not self._showed: if self._expand_anim.state() == QtCore.QAbstractAnimation.Running: @@ -575,37 +576,33 @@ class ActionMenuPopup(QtWidgets.QWidget): bg_geo = self._bg_frame.geometry() - label_y_offset = self._get_label_y_offset() + label_sh = self._group_label.sizeHint() + label_width, label_height = label_sh.width(), label_sh.height() if self._right_to_left: popup_geo = self.geometry() diff_size = popup_geo.size() - value pos = QtCore.QPoint( - diff_size.width(), diff_size.height() + diff_size.width(), diff_size.height() - label_height ) bg_geo.moveTopLeft(pos) bg_geo.setWidth(value.width()) - bg_geo.setHeight(value.height()) + bg_geo.setHeight(value.height() + label_height) label_width = self._group_label.sizeHint().width() - label_pos_x = 0 bgeo_tl = bg_geo.topLeft() - label_pos_y = bgeo_tl.y() - label_y_offset + sh_l, sh_t, sh_r, sh_b = SHADOW_FRAME_MARGINS + + label_pos_x = sh_l if label_width < value.width(): label_pos_x = bgeo_tl.x() + (value.width() - label_width) // 2 - label_pos = QtCore.QPoint(label_pos_x, label_pos_y) - - sh_l, sh_t, sh_r, sh_b = SHADOW_FRAME_MARGINS self.setUpdatesEnabled(False) self._view.setMask( - bg_geo.adjusted( - sh_l, sh_t - label_y_offset, - -sh_r, -(sh_b + label_y_offset) - ) + bg_geo.adjusted(sh_l, sh_t, -sh_r, -sh_b) ) - self._group_label.move(label_pos) + self._group_label.move(label_pos_x, sh_t) self._bg_frame.setGeometry(bg_geo) self.setUpdatesEnabled(True) From 7bd8578cd28c613fa876a06cd1b7c3aac03b4480 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 24 Jun 2025 18:16:41 +0200 Subject: [PATCH 21/22] fix view position --- client/ayon_core/tools/launcher/ui/actions_widget.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/tools/launcher/ui/actions_widget.py b/client/ayon_core/tools/launcher/ui/actions_widget.py index ddb1c20221..fddf88bed6 100644 --- a/client/ayon_core/tools/launcher/ui/actions_widget.py +++ b/client/ayon_core/tools/launcher/ui/actions_widget.py @@ -402,7 +402,7 @@ class ActionMenuPopup(QtWidgets.QWidget): view = ActionsView(self) view.setGridSize(QtCore.QSize(75, 80)) view.setIconSize(QtCore.QSize(32, 32)) - view.move(QtCore.QPoint(sh_l, sh_t)) + view.move(sh_l, sh_t) view.stackUnder(group_label) @@ -542,7 +542,7 @@ class ActionMenuPopup(QtWidgets.QWidget): self._view.setMinimumWidth(target_size.width()) self._view.setMaximumWidth(target_size.width()) self._view.setMinimumHeight(target_size.height()) - self._view.move(0, label_height) + self._view.move(sh_l, sh_t + label_height) self.setGeometry( pos_x, pos_y - label_height, target_size.width(), target_size.height() + label_height From 9a40f533038b968a553b6cb3059f3a64743b1077 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 24 Jun 2025 18:23:01 +0200 Subject: [PATCH 22/22] added some docstring --- .../tools/launcher/ui/actions_widget.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/client/ayon_core/tools/launcher/ui/actions_widget.py b/client/ayon_core/tools/launcher/ui/actions_widget.py index fddf88bed6..51cb8e73bc 100644 --- a/client/ayon_core/tools/launcher/ui/actions_widget.py +++ b/client/ayon_core/tools/launcher/ui/actions_widget.py @@ -374,6 +374,22 @@ class ActionMenuPopupModel(QtGui.QStandardItemModel): class ActionMenuPopup(QtWidgets.QWidget): + """Popup widget for group varaints. + + The popup is handling most of the layout and showing of the items + manually. + + There 4 parts: + 1. Shadow - semi transparent black widget used as shadow. + 2. Background - painted over the shadow with blur effect. All + other items are painted over. + 3. Label - show group label and positioned manually at the top + of the popup. + 4. View - View with variant action items. View is positioned + and resized manually according to the items in the group and then + animated using mask region. + + """ action_triggered = QtCore.Signal(str) config_requested = QtCore.Signal(str, QtCore.QPoint)