mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 13:52:15 +01:00
added ConfigWidget for reimplementing Qt methods
This commit is contained in:
parent
e5960d7fa0
commit
28c4a69ea1
1 changed files with 38 additions and 2 deletions
|
|
@ -1,4 +1,4 @@
|
|||
from Qt import QtWidgets, QtCore
|
||||
from Qt import QtWidgets, QtCore, QtGui
|
||||
|
||||
|
||||
class ModifiedIntSpinBox(QtWidgets.QSpinBox):
|
||||
|
|
@ -38,7 +38,43 @@ class ClickableWidget(QtWidgets.QLabel):
|
|||
super(ClickableWidget, self).mouseReleaseEvent(event)
|
||||
|
||||
|
||||
class ExpandingWidget(QtWidgets.QWidget):
|
||||
class ConfigWidget(QtWidgets.QWidget):
|
||||
allow_actions = True
|
||||
|
||||
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 (
|
||||
not self.any_parent_overriden()
|
||||
and (self.is_overriden or self.child_overriden)
|
||||
):
|
||||
# TODO better label
|
||||
action = QtWidgets.QAction("Remove 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
|
||||
super(ConfigWidget, self).mouseReleaseEvent(event)
|
||||
|
||||
|
||||
class ExpandingWidget(ConfigWidget):
|
||||
def __init__(self, label, parent):
|
||||
super(ExpandingWidget, self).__init__(parent)
|
||||
self.setObjectName("ExpandingWidget")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue