Skip to content

Commit

Permalink
fix: fix UI scaling with high DPI
Browse files Browse the repository at this point in the history
  • Loading branch information
vzhd1701 committed Dec 1, 2021
1 parent 2bba89d commit ddbf005
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions gridplayer/main/init_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys

from PyQt5.QtCore import QDir, QDirIterator, Qt
from PyQt5.QtGui import QFont, QFontDatabase, QIcon
from PyQt5.QtGui import QFont, QFontDatabase, QGuiApplication, QIcon
from PyQt5.QtWidgets import QApplication, QStyleFactory

if platform.system() == "Windows":
Expand Down Expand Up @@ -30,6 +30,10 @@ def setup_app_env():
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)

QGuiApplication.setHighDpiScaleFactorRoundingPolicy(
Qt.HighDpiScaleFactorRoundingPolicy.PassThrough
)


def init_app():
app = QApplication(sys.argv)
Expand Down Expand Up @@ -59,11 +63,10 @@ def _init_icon(app):
app.setWindowIcon(QIcon(":/icons/main_ico_mac.icns"))
elif platform.system() == "Windows":
app.setWindowIcon(QIcon(":/icons/main_ico_win.ico"))
elif app.desktop().devicePixelRatio() == 1:
app.setWindowIcon(QIcon(":/icons/main_ico_48.png"))
else:
if app.desktop().devicePixelRatio() == 1:
app.setWindowIcon(QIcon(":/icons/main_ico_48.png"))
else:
app.setWindowIcon(QIcon(":/icons/main_ico_svg.svg"))
app.setWindowIcon(QIcon(":/icons/main_ico_svg.svg"))


def _switch_icon_theme():
Expand Down

0 comments on commit ddbf005

Please sign in to comment.