mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
card widgets can tell if they should trigger double click
This commit is contained in:
parent
55256d59a3
commit
e2849b83e0
1 changed files with 24 additions and 4 deletions
|
|
@ -52,6 +52,7 @@ class SelectionTypes:
|
|||
class BaseGroupWidget(QtWidgets.QWidget):
|
||||
selected = QtCore.Signal(str, str, str)
|
||||
removed_selected = QtCore.Signal()
|
||||
double_clicked = QtCore.Signal()
|
||||
|
||||
def __init__(self, group_name, parent):
|
||||
super(BaseGroupWidget, self).__init__(parent)
|
||||
|
|
@ -192,6 +193,7 @@ class ConvertorItemsGroupWidget(BaseGroupWidget):
|
|||
else:
|
||||
widget = ConvertorItemCardWidget(item, self)
|
||||
widget.selected.connect(self._on_widget_selection)
|
||||
widget.double_clicked(self.double_clicked)
|
||||
self._widgets_by_id[item.id] = widget
|
||||
self._content_layout.insertWidget(widget_idx, widget)
|
||||
widget_idx += 1
|
||||
|
|
@ -254,6 +256,7 @@ class InstanceGroupWidget(BaseGroupWidget):
|
|||
)
|
||||
widget.selected.connect(self._on_widget_selection)
|
||||
widget.active_changed.connect(self._on_active_changed)
|
||||
widget.double_clicked.connect(self.double_clicked)
|
||||
self._widgets_by_id[instance.id] = widget
|
||||
self._content_layout.insertWidget(widget_idx, widget)
|
||||
widget_idx += 1
|
||||
|
|
@ -271,6 +274,7 @@ class CardWidget(BaseClickableFrame):
|
|||
# Group identifier of card
|
||||
# - this must be set because if send when mouse is released with card id
|
||||
_group_identifier = None
|
||||
double_clicked = QtCore.Signal()
|
||||
|
||||
def __init__(self, parent):
|
||||
super(CardWidget, self).__init__(parent)
|
||||
|
|
@ -279,6 +283,11 @@ class CardWidget(BaseClickableFrame):
|
|||
self._selected = False
|
||||
self._id = None
|
||||
|
||||
def mouseDoubleClickEvent(self, event):
|
||||
super(CardWidget, self).mouseDoubleClickEvent(event)
|
||||
if self._is_valid_double_click(event):
|
||||
self.double_clicked.emit()
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
"""Id of card."""
|
||||
|
|
@ -312,6 +321,9 @@ class CardWidget(BaseClickableFrame):
|
|||
|
||||
self.selected.emit(self._id, self._group_identifier, selection_type)
|
||||
|
||||
def _is_valid_double_click(self, event):
|
||||
return True
|
||||
|
||||
|
||||
class ContextCardWidget(CardWidget):
|
||||
"""Card for global context.
|
||||
|
|
@ -527,6 +539,15 @@ class InstanceCardWidget(CardWidget):
|
|||
def _on_expend_clicked(self):
|
||||
self._set_expanded()
|
||||
|
||||
def _is_valid_double_click(self, event):
|
||||
widget = self.childAt(event.pos())
|
||||
if (
|
||||
widget is self._active_checkbox
|
||||
or widget is self._expand_btn
|
||||
):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
class InstanceCardView(AbstractInstanceView):
|
||||
"""Publish access to card view.
|
||||
|
|
@ -580,10 +601,6 @@ class InstanceCardView(AbstractInstanceView):
|
|||
self.sizePolicy().verticalPolicy()
|
||||
)
|
||||
|
||||
def mouseDoubleClickEvent(self, event):
|
||||
if event.button() == QtCore.Qt.LeftButton:
|
||||
self.double_clicked.emit()
|
||||
|
||||
def sizeHint(self):
|
||||
"""Modify sizeHint based on visibility of scroll bars."""
|
||||
# Calculate width hint by content widget and vertical scroll bar
|
||||
|
|
@ -721,6 +738,7 @@ class InstanceCardView(AbstractInstanceView):
|
|||
)
|
||||
group_widget.active_changed.connect(self._on_active_changed)
|
||||
group_widget.selected.connect(self._on_widget_selection)
|
||||
group_widget.double_clicked.connect(self.double_clicked)
|
||||
self._content_layout.insertWidget(widget_idx, group_widget)
|
||||
self._widgets_by_group[group_name] = group_widget
|
||||
|
||||
|
|
@ -761,6 +779,7 @@ class InstanceCardView(AbstractInstanceView):
|
|||
|
||||
widget = ContextCardWidget(self._content_widget)
|
||||
widget.selected.connect(self._on_widget_selection)
|
||||
widget.double_clicked.connect(self.double_clicked)
|
||||
|
||||
self._context_widget = widget
|
||||
|
||||
|
|
@ -784,6 +803,7 @@ class InstanceCardView(AbstractInstanceView):
|
|||
CONVERTOR_ITEM_GROUP, self._content_widget
|
||||
)
|
||||
group_widget.selected.connect(self._on_widget_selection)
|
||||
group_widget.double_clicked.connect(self.double_clicked)
|
||||
self._content_layout.insertWidget(1, group_widget)
|
||||
self._convertor_items_group = group_widget
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue