def eventFilter(self, obj, event): e=event.type() if e == QEvent.ApplicationActivate: signals.emitNow('app.activate') elif e == QEvent.ApplicationDeactivate: signals.emitNow('app.deactivate') return QObject.eventFilter( self, obj, event )
def eventFilter(self, obj, event): "Call to handle relevant events." if obj == self.ui.image_label: if event.type() == QtCore.QEvent.MouseMove: self.handle_image_move(event) return True elif obj == self.ui.freq_label: if not self.ui.freq_label.isEnabled(): return False if event.type() == QtCore.QEvent.MouseMove: self.handle_freq_move(event) return True elif event.type() == QtCore.QEvent.MouseButtonPress: if event.button() == QtCore.Qt.MouseButton.LeftButton: self.handle_freq_modify(event) return True elif event.type() == QtCore.QEvent.MouseButtonRelease: if event.button() == QtCore.Qt.MouseButton.LeftButton: if self.current_brush: self.recompute_spatial_image() return True return QObject.eventFilter(self, obj, event)
def eventFilter(self, obj, event): if event.type() == QEvent.Paint: obj.setStyle(QStyleFactory.create('Windows')) p = QStylePainter(obj) tab = QStyleOptionTabV3() # selected = obj.currentIndex() for idx in range(obj.count()): obj.initStyleOption(tab, idx) if idx == 0: bg_color = QColor('#ADEBFF') fg_color = QColor('black') elif idx == 1: bg_color = QColor('#6CBED2') fg_color = QColor('black') elif idx == 2: bg_color = QColor('#0099CC') fg_color = QColor('black') elif idx == 3: bg_color = QColor('#297ACC') fg_color = QColor('black') elif idx == 4: bg_color = QColor('#006BB2') fg_color = QColor('black') elif idx == 5: bg_color = QColor('#003D7A') fg_color = QColor('black') tab.palette.setColor(QPalette.Window, bg_color) tab.palette.setColor(QPalette.WindowText, fg_color) p.drawControl(QStyle.CE_TabBarTab, tab) return True else: # standard event processing return QObject.eventFilter(self, obj, event)
def eventFilter(self, *args, **kwargs): if args[1].type() == QEvent.Resize: self.resizeFunc(None) if args[1].type() == QEvent.Paint: self.resizeFunc(None) return QObject.eventFilter(self, args[0], args[1])
def eventFilter(self, obj, event): """ :type obj: PySide.QtGui.QTableWidget :type event: PySide.QtCore.QEvent """ # TRACK MOUSE AND DISPLAY TOOLTIP WITH LOCAL AND GLOBAL TEXT if event.type() is QEvent.MouseMove: item = self.parent().nonVisTable.itemAt(event.pos()) # if no item on mouse position, ignore event if item: row = item.row() column = item.column() # get object id on mouse position object_id, frame = self.parent( ).annotation.nonvis_table_records[row][column] # show tooltip if there is an object a the object has at least global or local text if object_id is not None: an_object = self.parent( ).annotation.nonvis_objects_in_frame_range[object_id][0] text_global, text_local = an_object.get_text(frame) if text_global or text_local: QToolTip.showText(event.globalPos(), text_global + '\n' + text_local) # TRACK LEFT_MOUSE RELEASE EVENT elif event.type() is QEvent.MouseButtonRelease and event.button( ) is Qt.LeftButton: self.LMouseRelease.emit() return QObject.eventFilter(self, obj, event)
def eventFilter(self, obj, event): """ :type obj: PySide.QtGui.QTableWidget :type event: PySide.QtCore.QEvent """ # TRACK MOUSE AND DISPLAY TOOLTIP WITH LOCAL AND GLOBAL TEXT if event.type() is QEvent.MouseMove: item = self.parent().nonVisTable.itemAt(event.pos()) # if no item on mouse position, ignore event if item: row = item.row() column = item.column() # get object id on mouse position object_id, frame = self.parent().annotation.nonvis_table_records[row][column] # show tooltip if there is an object a the object has at least global or local text if object_id is not None: an_object = self.parent().annotation.nonvis_objects_in_frame_range[object_id][0] text_global, text_local = an_object.get_text(frame) if text_global or text_local: QToolTip.showText(event.globalPos(), text_global + '\n' + text_local) # TRACK LEFT_MOUSE RELEASE EVENT elif event.type() is QEvent.MouseButtonRelease and event.button() is Qt.LeftButton: self.LMouseRelease.emit() return QObject.eventFilter(self, obj, event)
def eventFilter(self, obj, event): e = event.type() if e == QEvent.KeyPress and event.key() == Qt.Key_Escape: obj.hide() elif e == QEvent.WindowDeactivate: obj.hide() return QObject.eventFilter( self, obj, event )
def eventFilter(self, obj, event): e = event.type() if e == QEvent.KeyPress and event.key() == Qt.Key_Escape: obj.hide() elif e == QEvent.WindowDeactivate: obj.hide() return QObject.eventFilter(self, obj, event)
def eventFilter(self, obj, event): if obj and not obj.isEnabled() and event.type() == QEvent.Wheel: newEvent = QWheelEvent(obj.mapToParent(event.pos()), event.globalPos(), event.delta(), event.buttons(), event.modifiers(), event.orientation()) QApplication.instance().postEvent(obj.parent(), newEvent) return True return QObject.eventFilter(self, obj, event)
def eventFilter(self, obj, event): if event.type() == QEvent.WindowActivate: self.activated.emit() return True elif event.type() == QEvent.WindowDeactivate: self.deactivated.emit() return True else: # standard event processing return QObject.eventFilter(self, obj, event)
def eventFilter ( self, object, event ): """ Handles a Qt event by mapping it to a corresponding controller method (if any). """ adapter = self.processEvent( object, event ) if adapter is not None: return adapter.handled # Pass the request along to the superclass: return QObject.eventFilter( self, object, event )
def eventFilter(self, obj, event): '''Just checks if is the correct object and event type incrementing counter until reaching the limit. After that it stops filtering the events for the object.''' if (self.obj == obj): if isinstance(event, self.event_type) and self.events_handled < 5: self.events_handled += 1 return True else: self.events_bypassed += 1 return False else: return QObject.eventFilter(self, obj, event)
def eventFilter(self, obj, event): "Call to handle relevant events." if obj == self.ui.image_label: if event.type() == QtCore.QEvent.MouseMove: self.handle_image_move(event) return True elif obj == self.ui.freq_label: if event.type() == QtCore.QEvent.MouseMove: self.handle_freq_move(event) return True elif event.type() == QtCore.QEvent.MouseButtonPress: if event.button() == QtCore.Qt.MouseButton.LeftButton: self.handle_freq_click(event) return QObject.eventFilter(self, obj, event)
def eventFilter(self, obj, event): e = event.type() if e == QEvent.WindowDeactivate: obj.accept() return QObject.eventFilter( self, obj, event )
def eventFilter(self, obj, event): #TODO/PORT/FIXME """ TOWRITE :param `obj`: TOWRITE :type `obj`: `QObject`_ :param `event`: TOWRITE :type `event`: `QEvent`_ """ if event.type() == QEvent.KeyPress: print('event.type() == QEvent.KeyPress') # if (self.isBlinking): # pass # REMOVEME tmp # #TODO# emit stopBlinking() ## QKeyEvent* pressedKey = (QKeyEvent*)event pressedKey = event # QKeyEvent # NOTE: These shortcuts need to be caught since QLineEdit uses them if pressedKey.matches(QKeySequence.Cut): pressedKey.accept() self.copyPressed.emit() print('CUT') self.cut() return True elif pressedKey.matches(QKeySequence.Copy): pressedKey.accept() self.copyPressed.emit() return True elif pressedKey.matches(QKeySequence.Paste): pressedKey.accept() self.pastePressed.emit() self.paste() return True elif pressedKey.matches(QKeySequence.SelectAll): pressedKey.accept() self.selectAllPressed.emit() self.selectAll() return True elif pressedKey.matches(QKeySequence.Undo): pressedKey.accept() self.undoPressed.emit() self.undo() return True elif pressedKey.matches(QKeySequence.Redo): pressedKey.accept() self.redoPressed.emit() self.redo() return True key = pressedKey.key() print('key = %s' % key) if key in (Qt.Key_Enter, Qt.Key_Return, Qt.Key_Space): # switch(key) pressedKey.accept() # self.processInput(QChar(key)) self.processInput(key) ## print(self.text()[len(self.defaultPrefix):]) ## exec(u'%s' % (self.text()[len(self.defaultPrefix):])) return True elif key == Qt.Key_Backspace: # print('Qt.Key_Backspace') pressedKey.ignore() return True elif key == Qt.Key_Delete: print('Qt.Key_Delete') pressedKey.accept() self.deletePressed.emit() return True elif key == Qt.Key_Tab: pressedKey.accept() self.tabPressed.emit() return True elif key == Qt.Key_Escape: pressedKey.accept() self.prefix = self.defaultPrefix self.clear() self.appendHistory.emit(self.curText + self.tr("*Cancel*"), len(self.prefix)) self.escapePressed.emit() return True elif key == Qt.Key_Up: pressedKey.accept() self.upPressed.emit() return True elif key == Qt.Key_Down: pressedKey.accept() self.downPressed.emit() return True elif key == Qt.Key_F1: pressedKey.accept() self.F1Pressed.emit() return True elif key == Qt.Key_F2: pressedKey.accept() self.F2Pressed.emit() return True elif key == Qt.Key_F3: pressedKey.accept() self.F3Pressed.emit() return True elif key == Qt.Key_F4: pressedKey.accept() self.F4Pressed.emit() return True elif key == Qt.Key_F5: pressedKey.accept() self.F5Pressed.emit() return True elif key == Qt.Key_F6: pressedKey.accept() self.F6Pressed.emit() return True elif key == Qt.Key_F7: pressedKey.accept() self.F7Pressed.emit() return True elif key == Qt.Key_F8: pressedKey.accept() self.F8Pressed.emit() return True elif key == Qt.Key_F9: pressedKey.accept() self.F9Pressed.emit() return True elif key == Qt.Key_F10: pressedKey.accept() self.F10Pressed.emit() return True elif key == Qt.Key_F11: pressedKey.accept() self.F11Pressed.emit() return True elif key == Qt.Key_F12: pressedKey.accept() self.F12Pressed.emit() return True elif key == Qt.Key_Shift: pressedKey.ignore() # we don't want to eat it, we just want to keep track of it self.shiftPressed.emit() else: pressedKey.ignore() if event.type() == QEvent.KeyRelease: # QKeyEvent* releasedKey = (QKeyEvent*)event releasedKey = event # QKeyEvent key = releasedKey.key() if key == Qt.Key_Shift: releasedKey.ignore() # we don't want to eat it, we just want to keep track of it # emit shiftReleased() else: releasedKey.ignore() # return QObject.eventFilter(obj, event) return QObject.eventFilter(self, obj, event)
def eventFilter(self, obj, event): if event.type() == QEvent.KeyPress: pass return QObject.eventFilter(self, obj, event)
def eventFilter(self, obj, event): e = event.type() if e == QEvent.WindowDeactivate: obj.accept() return QObject.eventFilter(self, obj, event)