diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index 7238c97148..4c4363d1ce 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -148,6 +148,7 @@ def create_defs(): defs['metadata_diff_mark_rejected'] = False defs['tag_browser_show_counts'] = True defs['row_numbers_in_book_list'] = True + defs['hidpi'] = 'auto' create_defs() @@ -938,17 +939,28 @@ class Application(QApplication): self.headless = headless qargs = [i.encode('utf-8') if isinstance(i, unicode) else i for i in args] self.pi = plugins['progress_indicator'][0] - if not isosx and not headless and hasattr(Qt, 'AA_EnableHighDpiScaling'): + if not isosx and not headless: # On OS X high dpi scaling is turned on automatically by the OS, so we dont need to set it explicitly # This requires Qt >= 5.6 - for v in ('QT_AUTO_SCREEN_SCALE_FACTOR', 'QT_SCALE_FACTOR', 'QT_SCREEN_SCALE_FACTORS', 'QT_DEVICE_PIXEL_RATIO'): + has_env_setting = False + env_vars = ('QT_AUTO_SCREEN_SCALE_FACTOR', 'QT_SCALE_FACTOR', 'QT_SCREEN_SCALE_FACTORS', 'QT_DEVICE_PIXEL_RATIO') + for v in env_vars: if os.environ.get(v): + has_env_setting = True break - else: - # Should probably make a preference to allow the user to - # control this, if needed. - # Could have options: auto, off, 1.25, 1.5, 1.75, 2, 2.25, 2.5 + hidpi = gprefs['hidpi'] + if hidpi == 'on' or (hidpi == 'auto' and not has_env_setting): + if DEBUG: + prints('Turning on hidpi scaling') QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True) + elif hidpi == 'off': + if DEBUG: + prints('Turning off hidpi scaling') + QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, False) + for p in env_vars: + os.environ.pop(p, None) + elif DEBUG: + prints('Not controlling hidpi scaling') QApplication.setOrganizationName('calibre-ebook.com') QApplication.setOrganizationDomain(QApplication.organizationName()) QApplication.setApplicationVersion(__version__) diff --git a/src/calibre/gui2/preferences/look_feel.py b/src/calibre/gui2/preferences/look_feel.py index cdb2d4051f..a3eae5b21f 100644 --- a/src/calibre/gui2/preferences/look_feel.py +++ b/src/calibre/gui2/preferences/look_feel.py @@ -20,6 +20,7 @@ from PyQt5.Qt import ( from calibre import human_readable from calibre.ebooks.metadata.book.render import DEFAULT_AUTHOR_LINK +from calibre.constants import isosx from calibre.ebooks.metadata.sources.prefs import msprefs from calibre.gui2 import default_author_link from calibre.gui2.dialogs.template_dialog import TemplateDialog @@ -338,8 +339,10 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): self.default_author_link = DefaultAuthorLink(self.default_author_link_container) self.default_author_link.changed_signal.connect(self.changed_signal) r('gui_layout', config, restart_required=True, choices=[(_('Wide'), 'wide'), (_('Narrow'), 'narrow')]) - r('ui_style', gprefs, restart_required=True, choices=[(_('System default'), 'system'), (_('calibre style'), - 'calibre')]) + r('hidpi', gprefs, restart_required=True, choices=[(_('Automatic'), 'auto'), (_('On'), 'on'), (_('Off'), 'off')]) + if isosx: + self.opt_hidpi.setVisible(False), self.label_hidpi.setVisible(False) + r('ui_style', gprefs, restart_required=True, choices=[(_('System default'), 'system'), (_('calibre style'), 'calibre')]) r('book_list_tooltips', gprefs) r('row_numbers_in_book_list', gprefs) r('tag_browser_old_look', gprefs, restart_required=True) diff --git a/src/calibre/gui2/preferences/look_feel.ui b/src/calibre/gui2/preferences/look_feel.ui index 76748bac75..f4250d02af 100644 --- a/src/calibre/gui2/preferences/look_feel.ui +++ b/src/calibre/gui2/preferences/look_feel.ui @@ -28,7 +28,17 @@ &Main interface - + + + + &User Interface layout (needs restart): + + + opt_gui_layout + + + + E&xtra spacing to add between rows in the book list (can be negative): @@ -38,7 +48,7 @@ - + px @@ -48,7 +58,7 @@ - + &Toolbar @@ -86,7 +96,7 @@ - + Change &font (needs restart) @@ -109,14 +119,14 @@ - + Show &tooltips in the book list - + Qt::Vertical @@ -129,7 +139,7 @@ - + Enable system &tray icon (needs restart) @@ -146,7 +156,7 @@ - + @@ -174,7 +184,7 @@ - + Disable &notifications in system tray @@ -201,17 +211,7 @@ - - - - &User Interface layout (needs restart): - - - opt_gui_layout - - - - + Disable all animations. Useful if you have a slow/old computer. @@ -221,7 +221,7 @@ - + Show &splash screen at startup @@ -235,13 +235,35 @@ - + Show &row numbers in the book list + + + + Adjust for high resolution screens (needs restart): + + + + + + + <p>Whether to automatically adjust the calibre user interface for high resolution (high DPI) monitors. There are three possible values:</p> + +<ul> +<li><b>Automatic</b>: Adjust the user interface if a high resolution monitor is detected. Will respect Qt environment variables controlling high DPI behavior. So if you use the environment variable QT_AUTO_SCREEN_SCALE_FACTOR then it will be used instead of this setting.</li> + +<li><b>On</b>: Same as "Automatic", but ignores Qt environment variables controlling high dpi behavior.</li> + +<li><b>Off</b>: Do not adjust the user interface, regardless of Qt environment variables.</li> +</ul> + + +