Skip to content

Commit

Permalink
refine code
Browse files Browse the repository at this point in the history
  • Loading branch information
cosven committed Jul 31, 2024
1 parent 87d09f6 commit 7e965e8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions feeluown/gui/uimain/page_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,24 +270,24 @@ def _draw_overlay(self, painter, draw_width, draw_height, scrolled):
def _draw_pixmap(self, painter, draw_width, draw_height, scrolled):
# scale pixmap
assert self._pixmap is not None
scaled_pixmap = self._pixmap.scaledToWidth(
draw_width,
mode=Qt.SmoothTransformation)
pixmap_size = self._pixmap.size()

# draw the center part of the pixmap on available rect
painter.save()
if scaled_pixmap.height() < draw_height:
if pixmap_size.width() / draw_width * draw_height >= pixmap_size.height():
scaled_pixmap = self._pixmap.scaledToHeight(
draw_height,
mode=Qt.SmoothTransformation
)
mode=Qt.SmoothTransformation)
brush = QBrush(scaled_pixmap)
painter.setBrush(brush)
pixmap_size = scaled_pixmap.size()
x = (pixmap_size.width() - draw_width) // 2
painter.translate(-x, -scrolled)
rect = QRect(0, 0, pixmap_size.width(), draw_height)
else:
scaled_pixmap = self._pixmap.scaledToWidth(
draw_width,
mode=Qt.SmoothTransformation)
pixmap_size = scaled_pixmap.size()
brush = QBrush(scaled_pixmap)
painter.setBrush(brush)
Expand Down

0 comments on commit 7e965e8

Please sign in to comment.