From f01b12e75d3da266f9dc9cb01d9b7bd75fe930e5 Mon Sep 17 00:00:00 2001 From: Alexander Bus <busfromrus@gmail.com> Date: Fri, 12 Jan 2018 15:11:12 +0700 Subject: [PATCH] Attempt at supporting HiDPI displays --- README.md | 2 +- cutelog/config.py | 17 ++++++++++------- cutelog/resources/ui/about_dialog.ui | 2 +- cutelog/settings_dialog.py | 2 +- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 898316c..dfb481a 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ log.info('Hello world!') ## Attributions Free software used: -* [PyQt5](https://riverbankcomputing.com/software/pyqt/intro) - GPLv3 License, Copyright (c) 2017 Riverbank Computing Limited <info@riverbankcomputing.com> +* [PyQt5](https://riverbankcomputing.com/software/pyqt/intro) - GPLv3 License, Copyright (c) 2018 Riverbank Computing Limited <info@riverbankcomputing.com> * [ion-icons](https://github.com/ionic-team/ionicons) - MIT License, Copyright (c) 2016 Drifty (http://drifty.com/) And thanks to [logview](https://pythonhosted.org/logview/) by Vinay Sajip for UI inspiration. diff --git a/cutelog/config.py b/cutelog/config.py index f9e61fb..492a5ef 100644 --- a/cutelog/config.py +++ b/cutelog/config.py @@ -1,10 +1,12 @@ +import logging import os import sys -import logging -from pkg_resources import resource_filename, get_distribution from collections import namedtuple -from PyQt5 import QtCore -from PyQt5.QtCore import QCoreApplication, QObject, pyqtSignal + +from pkg_resources import get_distribution, resource_filename +from PyQt5.QtCore import (QCoreApplication, QFile, QObject, QSettings, Qt, + pyqtSignal) + # from PyQt5.QtGui import QFont @@ -61,7 +63,7 @@ class Config(QObject): self.log = logging.getLogger() self.log.setLevel(99) self.log.debug('Initializing') - self.qsettings = QtCore.QSettings() + self.qsettings = QSettings() self.qsettings.setIniCodec('UTF-8') self.options = None @@ -98,10 +100,10 @@ class Config(QObject): return path def get_ui_qfile(self, name): - file = QtCore.QFile(f':/ui/{name}') + file = QFile(f':/ui/{name}') if not file.exists(): raise FileNotFoundError(f'ui file not found: ":/ui/{name}"') - file.open(QtCore.QFile.ReadOnly) + file.open(QFile.ReadOnly) return file @property @@ -236,6 +238,7 @@ def init_qt_info(): QCoreApplication.setApplicationName('cutelog') version = get_distribution(QCoreApplication.applicationName()).version QCoreApplication.setApplicationVersion(version) + QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True) def init_logging(): diff --git a/cutelog/resources/ui/about_dialog.ui b/cutelog/resources/ui/about_dialog.ui index 97dd992..0f131fa 100644 --- a/cutelog/resources/ui/about_dialog.ui +++ b/cutelog/resources/ui/about_dialog.ui @@ -83,7 +83,7 @@ p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">PyQt5:</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">GPLv3 License, Copyright (c) 2017 Riverbank Computing Limited &lt;info@riverbankcomputing.com&gt;</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">GPLv3 License, Copyright (c) 2018 Riverbank Computing Limited &lt;info@riverbankcomputing.com&gt;</p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">ion-icons</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">MIT License, Copyright (c) 2016 Drifty (http://drifty.com/)</p> diff --git a/cutelog/settings_dialog.py b/cutelog/settings_dialog.py index 64ca895..5aa2aad 100644 --- a/cutelog/settings_dialog.py +++ b/cutelog/settings_dialog.py @@ -39,7 +39,7 @@ class SettingsDialog(*SettingsDialogBase): self.oneTabCheckBox.setToolTip("Forces all connections into one tab. " "Useful for when you're restarting one " "program very often.") - self.oneTabLabel.setBuddy(self.oneTabCheckBox) + self.oneTabLabel.setBuddy(self.oneTabCheckBox) # @Hmmm: why doesn't this work? def load_from_config(self): # Appearance page -- GitLab