mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 16:44:13 +08:00
movdis
This commit is contained in:
parent
7a66b9c1af
commit
cb0e6fd394
@ -59,18 +59,26 @@ class ButtonX(QWidget):
|
||||
|
||||
class IconLabelX(LIconLabel, ButtonX):
|
||||
clicked = pyqtSignal()
|
||||
startpos = QPoint()
|
||||
movedistance = 0
|
||||
lastpos = QPoint()
|
||||
|
||||
def mouseMoveEvent(self, ev: QMouseEvent) -> None:
|
||||
cur = QCursor.pos()
|
||||
self.movedistance += (cur - self.lastpos).manhattanLength()
|
||||
self.lastpos = cur
|
||||
return super().mouseMoveEvent(ev)
|
||||
|
||||
def mousePressEvent(self, ev: QMouseEvent) -> None:
|
||||
if ev.button() == Qt.MouseButton.LeftButton:
|
||||
self.startpos = QCursor.pos()
|
||||
self.lastpos = QCursor.pos()
|
||||
self.movedistance = 0
|
||||
else:
|
||||
self.startpos = QPoint()
|
||||
self.movedistance = 9999
|
||||
return super().mousePressEvent(ev)
|
||||
|
||||
def mouseReleaseEvent(self, ev: QMouseEvent) -> None:
|
||||
if ev.button() == Qt.MouseButton.LeftButton:
|
||||
if (QCursor.pos() - self.startpos).manhattanLength() < 16:
|
||||
if self.movedistance <= 5:
|
||||
self.clicked.emit()
|
||||
return super().mouseReleaseEvent(ev)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user