Skip to content

Commit

Permalink
refine EmojiIconDrawer
Browse files Browse the repository at this point in the history
  • Loading branch information
cosven committed Nov 19, 2024
1 parent e8d4929 commit 9145559
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 8 additions & 3 deletions feeluown/gui/drawers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
)
from PyQt5.QtWidgets import QWidget

from feeluown.gui.helpers import random_solarized_color, painter_save
from feeluown.gui.helpers import random_solarized_color, painter_save, IS_MACOS


class SizedPixmapDrawer:
Expand Down Expand Up @@ -483,6 +483,11 @@ def paint(self, painter: QPainter):
with painter_save(painter):
painter.translate(self._padding, self._padding)
font = painter.font()
font.setPixelSize(width - 3)
if IS_MACOS:
# -4 works well on macOS when length is in range(30, 200)
font.setPixelSize(width - 4)
else:
# -1 works well on KDE when length is in range(30, 200)
font.setPixelSize(width - (self._length//20))
painter.setFont(font)
painter.drawText(0, 0, width, width, Qt.AlignCenter, self._emoji)
painter.drawText(0, 0, width, width, Qt.AlignHCenter | Qt.AlignVCenter, self._emoji)
3 changes: 2 additions & 1 deletion feeluown/gui/widgets/selfpaint_btn.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ def paintEvent(self, _):
l1.addWidget(CalendarButton(height=length))

l2.addWidget(PlayPreviousButton(length=length))
l2.addWidget(PlayPauseButton(length=100))
l2.addWidget(PlayPauseButton(length=60))
l2.addWidget(PlayNextButton(length=length))
volume_button = VolumeButton(length=length)
volume_button.set_volume(60)
Expand All @@ -576,4 +576,5 @@ def paintEvent(self, _):
l3.addWidget(RankButton(height=length))
l3.addWidget(StarButton(height=length))
l3.addWidget(EmojiButton('😁', '开心', height=length))
l3.addWidget(EmojiButton('🔥', '热门', height=length))
l3.addStretch(0)

0 comments on commit 9145559

Please sign in to comment.