Skip to content

Commit

Permalink
gui: lyric-window should not be moved when dragging sizegrip #752 (#817)
Browse files Browse the repository at this point in the history
  • Loading branch information
cosven committed Mar 13, 2024
1 parent 1669010 commit 22f6a42
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion feeluown/gui/uimain/lyric.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@


IS_MACOS = sys.platform == 'darwin'
IS_WINDOWS = sys.platform == 'win32'


def set_bg_color(palette, color):
Expand All @@ -37,6 +38,38 @@ def set_fg_color(palette, color):
"""


class SizeGrip(QSizeGrip):
"""
On windows, when the user drags the size grip, the lyric window is
resized and the lyric window also moves. This is not the expected.
So override the mouse event to fix this issue.
Check https://github.com/feeluown/FeelUOwn/issues/752 for more details.
"""
def mousePressEvent(self, e):
super().mousePressEvent(e)
if IS_WINDOWS:
e.accept()

def mouseMoveEvent(self, e):
super().mouseMoveEvent(e)
if IS_WINDOWS:
e.accept()

def mouseReleaseEvent(self, e):
super().mouseReleaseEvent(e)
if IS_WINDOWS:
e.accept()

def paintEvent(self, _):
"""
On windows, it draws a icon on the corner. On other platforms, it does not.
So let LyricWindow draw the icon for the SizeGrip.
"""
if IS_WINDOWS:
return


class LyricWindow(QWidget):
"""LyricWindow is a transparent container which contains a real lyric window.
Expand Down Expand Up @@ -230,7 +263,7 @@ def __init__(self, app, parent=None):
# When _auto_resize is True,
# the window size adapts to the lyric sentence width.
self._auto_resize = True
self._size_grip = QSizeGrip(self)
self._size_grip = SizeGrip(self)
self.line_label = LineLabel(self)

self._app.live_lyric.line_changed.connect(self.set_line)
Expand Down

0 comments on commit 22f6a42

Please sign in to comment.