def mouseReleaseEvent(self, ev: QtGui.QMouseEvent): if ev.button() == QtCore.Qt.LeftButton: self.is_pan = False self.setCursor(QtCore.Qt.ArrowCursor) ev.accept() else: ev.ignore()
def mouseDoubleClickEvent(self, event: QMouseEvent) -> None: if self.isFullScreen(): self._exitFullScreen() else: self.parent.toggleFullscreen() event.accept() super(mpvWidget, self).mouseDoubleClickEvent(event)
def mousePressEvent(self, ev: QMouseEvent): opt = QStyleOptionSlider() self.initStyleOption(opt) sr = QRect(self.style().subControlRect(QStyle.CC_Slider, opt, QStyle.SC_SliderHandle, self)) self.l_click = False if ev.button() == Qt.LeftButton and sr.contains(ev.pos()) is False: if (ev.button() == Qt.Vertical): n_val = self.minimum() + ( (self.maximum() - self.minimum() * (self.height() - ev.y())) / self.height()) else: n_val = self.minimum() + ( (self.maximum() - self.minimum()) * ev.x()) / self.width() if self.invertedAppearance() is True: self.setValue(self.maximum() - n_val) else: self.setValue(n_val) n_val = None self.l_click = True ev.accept() elif ev.button() == Qt.LeftButton: self.l_click = True else: self.l_click = False
def mouseMoveEvent(self, a0: QtGui.QMouseEvent) -> None: if a0.buttons() == QtCore.Qt.RightButton: a0.ignore() return x = a0.x() y = a0.y() absx = x - (self.width() - self.dim.width) / 2 absy = y - (self.height() - self.dim.height) / 2 if absx < 0 or absx > self.dim.width or absy < 0 or absy > self.dim.height \ or len(self.data) == len(self.reference) == 0: a0.ignore() return a0.accept() if len(self.data) > 0: target = self.data else: target = self.reference positions = [] for d in target: thisx = self.width() / 2 + d.re * self.dim.width / 2 thisy = self.height() / 2 + d.im * -1 * self.dim.height / 2 positions.append(math.sqrt((x - thisx)**2 + (y - thisy)**2)) minimum_position = positions.index(min(positions)) m = self.getActiveMarker() if m is not None: m.setFrequency(str(round(target[minimum_position].freq))) m.frequencyInput.setText(str(round(target[minimum_position].freq))) return
def mouseMoveEvent(self, QMouseEvent): try: if Qt.LeftButton and self.m_drag: self.move(QMouseEvent.globalPos()-self.m_DragPosition) QMouseEvent.accept() except: pass
def mouseMoveEvent(self, a0: QtGui.QMouseEvent): if a0.buttons() == QtCore.Qt.RightButton: a0.ignore() return x = a0.x() y = a0.y() absx = x - (self.width() - self.dim.width) / 2 absy = y - (self.height() - self.dim.height) / 2 if absx < 0 or absx > self.dim.width or absy < 0 or absy > self.dim.height \ or len(self.data) == len(self.reference) == 0: a0.ignore() return a0.accept() target = self.data or self.reference positions = [] dim_x_2 = self.dim.width / 2 dim_y_2 = self.dim.height / 2 width_2 = self.width() / 2 height_2 = self.height() / 2 positions = [ math.sqrt((x - (width_2 + d.re * dim_x_2))**2 + (y - (height_2 - d.im * dim_y_2))**2) for d in target ] minimum_position = positions.index(min(positions)) if m := self.getActiveMarker(): m.setFrequency(str(round(target[minimum_position].freq))) m.frequencyInput.setText(str(round(target[minimum_position].freq)))
def mouseMoveEvent(self, a0: QMouseEvent) -> None: if (a0.buttons() == Qt.LeftButton) and abs(a0.pos().y()) > 30: globalPos = self.mapToGlobal(a0.pos()) posInTab = self.mapFromGlobal(globalPos) TabBar.indexTabToDrag = self.currentIndex() tabRect = self.tabRect(self.indexTabToDrag) pixmap = QPixmap(tabRect.size()) self.render(pixmap, QPoint(), QRegion(tabRect)) mimeData = QMimeData() drag = QDrag(self) drag.setMimeData(mimeData) drag.setPixmap(pixmap) cursor = QCursor(Qt.OpenHandCursor) drag.setHotSpot(cursor.pos()) drag.setHotSpot(a0.pos() - posInTab) drag.setDragCursor(cursor.pixmap(), Qt.MoveAction) dropAction = drag.exec(Qt.MoveAction) # If the drag completed outside of the tab bar, detach the tab and move # the content to the current cursor position if dropAction == Qt.IgnoreAction: a0.accept() self.detachTab(self.indexTabToDrag, self.cursor().pos()) else: super(TabBar, self).mouseMoveEvent(a0)
def mousePressEvent(self, evt: QtGui.QMouseEvent) -> None: if evt.button() == Qt.LeftButton: self.setChecked(not self.checked()) evt.accept() return super().mousePressEvent(evt)
def mouseMoveEvent(self, evt: QtGui.QMouseEvent) -> None: measure_editor = self.track.measureEditorAt(evt.pos()) self.track.setHoverMeasureEditor(measure_editor, evt) if self.__selection_first is not None and isinstance( measure_editor, MeasureEditor): start_idx = self.__selection_first.measure_reference.index last_idx = measure_editor.measure_reference.index if start_idx > last_idx: start_idx, last_idx = last_idx, start_idx for meditor in itertools.islice(self.track.measure_editors(), start_idx, last_idx + 1): if isinstance(meditor, MeasureEditor) and not meditor.selected(): self.track.addToSelection(meditor) for seditor in self.track.selection(): if (not (start_idx <= seditor.measure_reference.index <= last_idx) and seditor.selected()): self.track.removeFromSelection(seditor) self.__selection_last = measure_editor evt.accept() return super().mouseMoveEvent(evt)
def mousePressEvent(self, event: QMouseEvent) -> None: event.accept() if event.button() == Qt.LeftButton: if self.parent is None: self.originalParent.playMedia() else: self.parent.playMedia()
def mouseDoubleClickEvent(self, evt: QtGui.QMouseEvent) -> None: if evt.button() == Qt.LeftButton and evt.modifiers() == Qt.NoModifier: # If the first half of the double click initiated a move, # cancel that move now. if self.__moving_point is not None: self.track.setPointPos(self.__moving_point, self.__moving_point_original_pos) self.__moving_point = None time = self.track.xToTime(evt.pos().x()) for point in self.track.track.points: if point.time == time: with self.project.apply_mutations( '%s: Change control point' % self.track.track.name): point.value = self.track.yToValue(evt.pos().y()) break else: with self.project.apply_mutations('%s: Insert control point' % self.track.track.name): self.track.track.create_control_point( self.track.xToTime(evt.pos().x()), self.track.yToValue(evt.pos().y())) evt.accept() return super().mouseDoubleClickEvent(evt)
def mouseMoveEvent(self, evt: QtGui.QMouseEvent) -> None: if self.__dragging: delta_p = (self.mapToGlobal(evt.pos()) - self.__drag_pos) self.__drag_pos = self.mapToGlobal(evt.pos()) if evt.modifiers() & Qt.ShiftModifier: if self.orientation() == Qt.Horizontal: delta = delta_p.x() else: delta = -delta_p.y() step_size = 0.0001 value = self.denormalize(self.normalizedValue() + delta * step_size) value = max(self.minimum(), min(value, self.maximum())) self.setValue(value) else: if self.orientation() == Qt.Horizontal: self.setValue( self.denormalize( (evt.pos().x() - 2) / (self.width() - 5))) else: self.setValue( self.denormalize(1.0 - (evt.pos().y() - 2) / (self.height() - 5))) evt.accept() return super().mouseMoveEvent(evt)
def mousePressEvent(self, event: QMouseEvent) -> None: found = False for tag_index in range(len(self.tags)): if self.in_cross_area(tag_index, event.pos()): self.tags.pop(tag_index) if tag_index <= self.editing_index: self.editing_index -= 1 found = True break if not self.tags[tag_index].rect.contains(event.pos()): continue if self.editing_index == tag_index: self.move_cursor( self.text_layout.lineAt(0).xToCursor( (event.pos() - self.current_rect().topLeft()).x()), False) else: self.edit_tag(tag_index) found = True break if not found: self.edit_new_tag() event.accept() if event.isAccepted(): self.update_display_text() self.compute_tag_rects() self.update_cursor_blinking() self.update()
def mouseReleasevent(self, evt: QtGui.QMouseEvent) -> None: if self.__dragging and evt.button() == Qt.LeftButton: self.__dragging = False evt.accept() return super().mouseReleaseEvent(evt)
def mouseReleaseEvent(self, evt: QtGui.QMouseEvent) -> None: if evt.button() == Qt.LeftButton and self.__click_pos is not None: self.__click_pos = None self.__editor.endTrackMove() self.__editor.setAutoScroll(0) self.setCursor(Qt.OpenHandCursor) evt.accept()
def mouseReleaseEvent(self, evt: QtGui.QMouseEvent) -> None: if evt.button() == Qt.LeftButton: self.__selection_first = None self.__selection_last = None evt.accept() return super().mouseReleaseEvent(evt)
def mouseMoveEvent(self, ev: QtGui.QMouseEvent): if self.is_pan: self.goompy.move(self.coords[0] - ev.x(), self.coords[1] - ev.y()) self.update_map_background() self.coords = ev.x(), ev.y() ev.accept() else: ev.ignore()
def mouseMoveEvent(self, event: QtGui.QMouseEvent) -> None: event.accept() pos = event.pos() if self._bezier_path is None and self._init_line: self._init_line[1] = pos elif self._bezier_path is not None: self._bezier_path.mouse_move_event(pos) self.update()
def mousePressEvent(self, ev: QtGui.QMouseEvent): if ev.button() == QtCore.Qt.LeftButton: self.is_pan = True self.setCursor(QtCore.Qt.ClosedHandCursor) self.coords = ev.x(), ev.y() ev.accept() else: ev.ignore()
def mousePressEvent(self, evt: QtGui.QMouseEvent) -> None: self.__editor.setCurrentTrack(self.__container.track) if evt.button() == Qt.LeftButton: self.__click_pos = evt.pos() self.__editor.beginTrackMove(self.__container) self.setCursor(Qt.ClosedHandCursor) evt.accept()
def mousePressEvent(self, evt: QtGui.QMouseEvent) -> None: if evt.button() == Qt.LeftButton and not self.readOnly(): self.__dragging = True self.__drag_pos = self.mapToGlobal(evt.pos()) evt.accept() return super().mousePressEvent(evt)
def mouseReleaseEvent(self, evt: QtGui.QMouseEvent) -> None: if evt.button() == Qt.LeftButton and self.__drag_handle is not None: self.__drag_handle = None self.__drag_handle_offset = None self.update() evt.accept() return super().mouseReleaseEvent(evt)
def mousePressEvent(self, event: QtGui.QMouseEvent) -> None: event.accept() pos = event.pos() if self._bezier_path is None: self._init_line = [pos, pos] else: self._bezier_path.mouse_press_event(pos) self.update()
def mousePressEvent(self, event: QMouseEvent): event.accept() pos = event.pos() index = self._hoverIndex if not self.isValidIndex(index) or not self._hoverRect.contains(pos): index, _ = self._getTabIndexAt(pos) if not self.isValidIndex(index): return if self._enabled and self._tabs[index].enabled: self._currentIndex = index # triggers update and signal
def mousePressEvent(self, evt: QtGui.QMouseEvent) -> None: if evt.button() == Qt.LeftButton: if self.displayMode() == self.DisplayMode.MusicalTime: self.setDisplayMode(self.DisplayMode.RealTime) else: self.setDisplayMode(self.DisplayMode.MusicalTime) evt.accept() return super().mousePressEvent(evt)
def mouseMoveEvent(self, evt: QtGui.QMouseEvent) -> None: if self.__click_pos is not None: pos = self.mapTo(self.__editor, evt.pos() - self.__click_pos) self.__editor.setTrackHeight( self.__container, max(0, pos.y() - self.__container.track_editor.y())) evt.accept()
def mousePressEvent(self, e: QtGui.QMouseEvent): if e.button() == QtCore.Qt.LeftButton: if e.pos().y() <= self.h_title: # 工具栏高度范围内可以移动窗体 self.setCursor(QtGui.QCursor(QtCore.Qt.OpenHandCursor)) # 更改鼠标图标 self.mPos = e.pos() # self.mPos = event.globalPos() - self.pos() # 获取鼠标相对窗口的位置 else: self.mPos = None e.accept()
def mousePressEvent(self, event: QMouseEvent) -> None: if event.button() == Qt.BackButton and self.cutStartAction.isEnabled(): self.cutStart() event.accept() elif event.button( ) == Qt.ForwardButton and self.cutEndAction.isEnabled(): self.cutEnd() event.accept() else: super(VidCutter, self).mousePressEvent(event)
def mouseDoubleClickEvent(self, a_event: QtGui.QMouseEvent): super().mouseDoubleClickEvent(a_event) result = utils.find_number_re.finditer(self.text()) if result: for num_match in result: begin, end = num_match.span() if begin <= self.cursorPosition() <= end: self.setSelection(begin, end - begin) break a_event.accept()
def mousePressEvent(self, QMouseEvent): if QMouseEvent.button() == Qt.LeftButton: self.flag = True self.m_Position = QMouseEvent.globalPos() - self.pos() QMouseEvent.accept() self.setCursor(QCursor(Qt.OpenHandCursor))
def mousePressEvent(self, evt: QtGui.QMouseEvent) -> None: if evt.button() == Qt.LeftButton and self.__active_handle is not None: handle = self.__handles[self.__active_handle] self.__drag_handle = self.__active_handle self.__drag_handle_offset = evt.pos() - handle.center() self.update() evt.accept() return super().mousePressEvent(evt)
def mouseReleaseEvent(self, event: QtGui.QMouseEvent) -> None: event.accept() if self._bezier_path is None: try: self._bezier_path = RoadPainterPath.create( self._init_line[0], self._init_line[1]) except AssertionError: self._bezier_path = None else: self._bezier_path.mouse_release_event(event.pos())
def mouseReleaseEvent( self, a0: QMouseEvent) -> None: # MUST CALL QT SUPER IN CLIENT CLASS!!!! if a0.button() & Qt.RightButton == Qt.RightButton: a0.accept() a0.setAccepted(True) menu = QMenu(self) self.make_menu(menu) this_idx = self.indexAt(a0.pos()) self.check_index_widget_menu(this_idx, menu) menu.popup(a0.globalPos())