Skip to content

Commit 909a119

Browse files
authored
Merge pull request #1740 from ales-erjavec/canvas/toolgrid-fix
[FIX] canvas/toolgrid: Remove (unused) mouse press event tracking
2 parents 7e5556c + 9625543 commit 909a119

File tree

1 file changed

+3
-55
lines changed

1 file changed

+3
-55
lines changed

Orange/canvas/gui/toolgrid.py

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,6 @@ def __init__(self, parent=None, columns=4, buttonSize=None,
147147
self.__toolButtonStyle = toolButtonStyle
148148

149149
self.__gridSlots = []
150-
151-
self.__buttonListener = ToolButtonEventListener(self)
152-
self.__buttonListener.buttonRightClicked.connect(
153-
self.__onButtonRightClick)
154-
155-
self.__buttonListener.buttonEnter.connect(
156-
self.__onButtonEnter)
157-
158150
self.__mapper = QSignalMapper()
159151
self.__mapper.mapped[QObject].connect(self.__onClicked)
160152

@@ -317,7 +309,7 @@ def __insertActionButton(self, index, action):
317309
self.__shiftGrid(index, 1)
318310
button = self.createButtonForAction(action)
319311

320-
row = index / self.__columns
312+
row = index // self.__columns
321313
column = index % self.__columns
322314

323315
self.layout().addWidget(
@@ -331,7 +323,6 @@ def __insertActionButton(self, index, action):
331323

332324
self.__mapper.setMapping(button, action)
333325
button.clicked.connect(self.__mapper.map)
334-
button.installEventFilter(self.__buttonListener)
335326
button.installEventFilter(self)
336327

337328
def __removeActionButton(self, action):
@@ -341,7 +332,6 @@ def __removeActionButton(self, action):
341332
index = actions.index(action)
342333
slot = self.__gridSlots.pop(index)
343334

344-
slot.button.removeEventFilter(self.__buttonListener)
345335
slot.button.removeEventFilter(self)
346336
self.__mapper.removeMappings(slot.button)
347337

@@ -391,9 +381,6 @@ def __indexOf(self, button):
391381
buttons = [slot.button for slot in self.__gridSlots]
392382
return buttons.index(button)
393383

394-
def __onButtonRightClick(self, button):
395-
pass
396-
397384
def __onButtonEnter(self, button):
398385
action = button.defaultAction()
399386
self.actionHovered.emit(action)
@@ -412,7 +399,8 @@ def eventFilter(self, obj, event):
412399
if self.__focusMove(obj, key):
413400
event.accept()
414401
return True
415-
402+
elif etype == QEvent.HoverEnter and obj.parent() is self:
403+
self.__onButtonEnter(obj)
416404
return QFrame.eventFilter(self, obj, event)
417405

418406
def __focusMove(self, focus, key):
@@ -437,43 +425,3 @@ def __focusMove(self, focus, key):
437425
return True
438426
else:
439427
return False
440-
441-
442-
class ToolButtonEventListener(QObject):
443-
"""
444-
An event listener(filter) for :class:`QToolButtons`.
445-
"""
446-
buttonLeftClicked = Signal(QToolButton)
447-
buttonRightClicked = Signal(QToolButton)
448-
buttonEnter = Signal(QToolButton)
449-
buttonLeave = Signal(QToolButton)
450-
451-
def __init__(self, parent=None):
452-
QObject.__init__(self, parent)
453-
self.button_down = None
454-
self.button = None
455-
self.button_down_pos = None
456-
457-
def eventFilter(self, obj, event):
458-
if not isinstance(obj, QToolButton):
459-
return False
460-
461-
if event.type() == QEvent.MouseButtonPress:
462-
self.button = obj
463-
self.button_down = event.button()
464-
self.button_down_pos = event.pos()
465-
466-
elif event.type() == QEvent.MouseButtonRelease:
467-
if self.button.underMouse():
468-
if event.button() == Qt.RightButton:
469-
self.buttonRightClicked.emit(self.button)
470-
elif event.button() == Qt.LeftButton:
471-
self.buttonLeftClicked.emit(self.button)
472-
473-
elif event.type() == QEvent.Enter:
474-
self.buttonEnter.emit(obj)
475-
476-
elif event.type() == QEvent.Leave:
477-
self.buttonLeave.emit(obj)
478-
479-
return False

0 commit comments

Comments
 (0)