mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +01:00
show_actions_menu is separate method now triggered with right click on item
This commit is contained in:
parent
ac26fb31eb
commit
65e9a6a254
1 changed files with 67 additions and 57 deletions
|
|
@ -285,65 +285,75 @@ class SettingObject:
|
|||
|
||||
return "-".join(items) or ""
|
||||
|
||||
def show_actions_menu(self, event=None):
|
||||
if event and event.button() != QtCore.Qt.RightButton:
|
||||
return
|
||||
|
||||
if not self.allow_actions:
|
||||
if event:
|
||||
return self.mouseReleaseEvent(event)
|
||||
return
|
||||
|
||||
menu = QtWidgets.QMenu()
|
||||
|
||||
actions_mapping = {}
|
||||
if self.child_modified:
|
||||
action = QtWidgets.QAction("Discard changes")
|
||||
actions_mapping[action] = self._discard_changes
|
||||
menu.addAction(action)
|
||||
|
||||
if (
|
||||
self.is_overidable
|
||||
and not self.is_overriden
|
||||
and not self.any_parent_is_group
|
||||
):
|
||||
action = QtWidgets.QAction("Set project override")
|
||||
actions_mapping[action] = self._set_as_overriden
|
||||
menu.addAction(action)
|
||||
|
||||
if (
|
||||
not self.is_overidable
|
||||
and (
|
||||
self.has_studio_override
|
||||
)
|
||||
):
|
||||
action = QtWidgets.QAction("Reset to pype default")
|
||||
actions_mapping[action] = self._reset_to_pype_default
|
||||
menu.addAction(action)
|
||||
|
||||
if (
|
||||
not self.is_overidable
|
||||
and not self.is_overriden
|
||||
and not self.any_parent_is_group
|
||||
and not self._had_studio_override
|
||||
):
|
||||
action = QtWidgets.QAction("Set studio default")
|
||||
actions_mapping[action] = self._set_studio_default
|
||||
menu.addAction(action)
|
||||
|
||||
if (
|
||||
not self.any_parent_overriden()
|
||||
and (self.is_overriden or self.child_overriden)
|
||||
):
|
||||
# TODO better label
|
||||
action = QtWidgets.QAction("Remove project override")
|
||||
actions_mapping[action] = self._remove_overrides
|
||||
menu.addAction(action)
|
||||
|
||||
if not actions_mapping:
|
||||
action = QtWidgets.QAction("< No action >")
|
||||
actions_mapping[action] = None
|
||||
menu.addAction(action)
|
||||
|
||||
result = menu.exec_(QtGui.QCursor.pos())
|
||||
if result:
|
||||
to_run = actions_mapping[result]
|
||||
if to_run:
|
||||
to_run()
|
||||
|
||||
def mouseReleaseEvent(self, event):
|
||||
if self.allow_actions and event.button() == QtCore.Qt.RightButton:
|
||||
menu = QtWidgets.QMenu()
|
||||
|
||||
actions_mapping = {}
|
||||
if self.child_modified:
|
||||
action = QtWidgets.QAction("Discard changes")
|
||||
actions_mapping[action] = self._discard_changes
|
||||
menu.addAction(action)
|
||||
|
||||
if (
|
||||
self.is_overidable
|
||||
and not self.is_overriden
|
||||
and not self.any_parent_is_group
|
||||
):
|
||||
action = QtWidgets.QAction("Set project override")
|
||||
actions_mapping[action] = self._set_as_overriden
|
||||
menu.addAction(action)
|
||||
|
||||
if (
|
||||
not self.is_overidable
|
||||
and (
|
||||
self.has_studio_override
|
||||
)
|
||||
):
|
||||
action = QtWidgets.QAction("Reset to pype default")
|
||||
actions_mapping[action] = self._reset_to_pype_default
|
||||
menu.addAction(action)
|
||||
|
||||
if (
|
||||
not self.is_overidable
|
||||
and not self.is_overriden
|
||||
and not self.any_parent_is_group
|
||||
and not self._had_studio_override
|
||||
):
|
||||
action = QtWidgets.QAction("Set studio default")
|
||||
actions_mapping[action] = self._set_studio_default
|
||||
menu.addAction(action)
|
||||
|
||||
if (
|
||||
not self.any_parent_overriden()
|
||||
and (self.is_overriden or self.child_overriden)
|
||||
):
|
||||
# TODO better label
|
||||
action = QtWidgets.QAction("Remove project override")
|
||||
actions_mapping[action] = self._remove_overrides
|
||||
menu.addAction(action)
|
||||
|
||||
if not actions_mapping:
|
||||
action = QtWidgets.QAction("< No action >")
|
||||
actions_mapping[action] = None
|
||||
menu.addAction(action)
|
||||
|
||||
result = menu.exec_(QtGui.QCursor.pos())
|
||||
if result:
|
||||
to_run = actions_mapping[result]
|
||||
if to_run:
|
||||
to_run()
|
||||
return
|
||||
return self.show_actions_menu()
|
||||
|
||||
mro = type(self).mro()
|
||||
index = mro.index(self.__class__)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue