mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
better scaling method
This commit is contained in:
parent
a52c025816
commit
5c515096af
1 changed files with 6 additions and 12 deletions
|
|
@ -69,15 +69,12 @@ class LauncherSettingsLabel(QtWidgets.QWidget):
|
|||
return cls._settings_icon
|
||||
|
||||
def paintEvent(self, event):
|
||||
painter = QtGui.QPainter()
|
||||
painter.begin(self)
|
||||
painter = QtGui.QPainter(self)
|
||||
|
||||
render_hints = (
|
||||
painter.setRenderHints(
|
||||
QtGui.QPainter.Antialiasing
|
||||
| QtGui.QPainter.SmoothPixmapTransform
|
||||
)
|
||||
if hasattr(QtGui.QPainter, "HighQualityAntialiasing"):
|
||||
render_hints |= QtGui.QPainter.HighQualityAntialiasing
|
||||
|
||||
rect = event.rect()
|
||||
size = min(rect.height(), rect.width())
|
||||
|
|
@ -85,14 +82,11 @@ class LauncherSettingsLabel(QtWidgets.QWidget):
|
|||
rect.x(), rect.y(),
|
||||
size, size
|
||||
)
|
||||
pixmap = self._pixmap.scaled(
|
||||
pix_rect.size(),
|
||||
QtCore.Qt.KeepAspectRatio,
|
||||
QtCore.Qt.SmoothTransformation
|
||||
|
||||
src_rect = QtCore.QRect(
|
||||
0, 0,
|
||||
self._pixmap.width(), self._pixmap.height()
|
||||
)
|
||||
painter.setRenderHints(render_hints)
|
||||
painter.drawPixmap(0, 0, pixmap)
|
||||
painter.drawPixmap(pix_rect, self._pixmap, src_rect)
|
||||
|
||||
painter.end()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue