def eventFilter(self, source: QObject, event: QEvent) -> bool: """Method which applies the event filter""" if event.type( ) == QEvent.Type.MouseMove and self.tab_bar.edge_offset is not None: if source.currentIndex( ) == self.tab_bar.count() - 1: # Block MouseMove for last tab return True # For remaining tabs: # block MouseMove if the left edge of the moving tab goes # farther to the left than the right edge of first tab. moving_right_edge: int = event.pos().x() + self.tab_bar.edge_offset fixed_left_edge: int = self.tab_bar.tabRect(self.tab_bar.count() - 1).x() if moving_right_edge > fixed_left_edge: return True elif event.type() == QEvent.Type.MouseButtonPress: # Get mouse click horizontal position. xclick: QPoint = event.pos().x() # Get the left edge horizontal position of the targeted tab. xleft: int = self.tab_bar.tabRect(self.tab_bar.tabAt( event.pos())).x() # Compute and store offset between mouse click horizontal # position and the left edge of the targeted tab self.tab_bar.edge_offset = xclick - xleft self.tab_bar.edge_offset = self.tab_bar.tabRect( self.tab_bar.tabAt(event.pos())).width() - (xclick - xleft) return QWidget.eventFilter(self, source, event)
def eventFilter(self, obj, event): if obj is self.view.viewport(): if event.type() == QEvent.MouseButtonPress: pass # self.mousePressEvent(event) elif event.type() == QEvent.MouseButtonRelease: self.mouseReleaseEvent(event) return QWidget.eventFilter(self, obj, event)
def eventFilter(self, obj, event): if obj is self.view.viewport(): if event.type() == QEvent.MouseButtonPress: print('mouse press event = ', event.pos()) elif event.type() == QEvent.MouseButtonRelease: self.mouseReleaseEvent(event) print('mouse release event = ', event.pos()) return QWidget.eventFilter(self, obj, event)
def eventFilter(self, widget, event): if event.type() == QEvent.KeyPress: key = event.key() if key == Qt.Key_Return and not self.computation_started: self.__start_computation() elif key == Qt.Key_Enter and not self.computation_started: self.__start_computation() return True return QWidget.eventFilter(self, widget, event)
def eventFilter(self, obj, event: QEvent): if obj == self.window and self.is_recording: if event.type() == QEvent.MouseButtonPress: self.write_to_table(EventHandler.invert_mouse_event(event)) elif event.type() == QEvent.KeyPress and not event.isAutoRepeat(): key = EventHandler.hook_key_event(event) if key == True: return True self.write_to_table(QKeySequence(key).toString()) elif event.type() == QEvent.KeyRelease and event.key( ) == Qt.Key_Tab: self.write_to_table(QKeySequence(Qt.Key_Tab)) else: return False try: return QWidget.eventFilter(self, obj, event) except RuntimeError: return True
def eventFilter(self, source, event): if (event.type() == QEvent.MouseButtonPress or (event.type() == QEvent.MouseMove and event.buttons() == Qt.LeftButton)): self.pos = pos = event.pos() t = atan2(self.cen.y() - pos.y(), pos.x() - self.cen.x()) if self.colWhlPath.contains(pos): # in the color wheel self.chPt = pos #if not self._startedTimer: # self.timer = QTimer() # self.timer.timeout.connect(self.timerSpinner) # self.timer.start(30.303) # self._startedTimer = True # hue -> mouse angle (same as t here) h = (int(degrees(t)) - self.o_ang) * -self.rot_d self.hue = (h if h > 0 else h + 360) % 360 # saturation -> mouse radius (clipped to wheel radius) m_rad = sqrt((self.pos.x() - self.cen.x())**2 + (self.pos.y() - self.cen.y())**2) self.sat = int(255 * min(m_rad / self.cW_rad, 1)) if self.vInArcPath.contains(pos): # in the value selection arc self.vIdAng = t if t > 0 else t + 2 * pi r2 = self.vAoBox.width() / 2.0 x, y = r2 * cos(t) + self.cen.x(), r2 * -sin(t) + self.cen.y() self.vIdCen = QPointF(x, y) self.vIdBox.moveCenter(self.vIdCen) self.value = int(255 * (t - radians(self.e_ang)) / self.ang_w) % 256 self.update() col = QColor() col.setHsv(self.hue, self.sat, self.value) self.currentColorChanged.emit(col) return QWidget.eventFilter(self, source, event)
def eventFilter(self, watched: QObject, event: QEvent) -> bool: if watched == self.ui.curve and event.type() == QEvent.Paint: self.drawCurve() return QWidget.eventFilter(self, watched, event)