- added the ability of context menu inside the GuiElements.FCCombobox() object.

- remade the UI for ToolSolderPaste. The object comboboxes now have context menu's that allow object deletion. Also the last object created is set as current item in comboboxes.
This commit is contained in:
Marius Stanciu
2019-02-23 03:38:39 +02:00
committed by Marius S
parent a67e31bda3
commit 21f970204e
5 changed files with 242 additions and 74 deletions

View File

@@ -475,9 +475,25 @@ class FCTextAreaRich(QtWidgets.QTextEdit):
class FCComboBox(QtWidgets.QComboBox):
def __init__(self, parent=None):
def __init__(self, parent=None, callback=None):
super(FCComboBox, self).__init__(parent)
self.setFocusPolicy(QtCore.Qt.StrongFocus)
self.view = self.view()
self.view.viewport().installEventFilter(self)
self.view.setContextMenuPolicy(Qt.CustomContextMenu)
# the callback() will be called on customcontextmenu event and will be be passed 2 parameters:
# pos = mouse right click click position
# self = is the combobox object itself
if callback:
self.view.customContextMenuRequested.connect(lambda pos: callback(pos, self))
def eventFilter(self, obj, event):
if event.type() == QtCore.QEvent.MouseButtonRelease:
if event.button() == Qt.RightButton:
return True
return False
def wheelEvent(self, *args, **kwargs):
pass