mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add a preference to turn high DPI scaling on or off
This commit is contained in:
parent
32d1fbe1c6
commit
46b9d7762e
@ -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__)
|
||||
|
@ -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)
|
||||
|
@ -28,7 +28,17 @@
|
||||
<string>&Main interface</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_9">
|
||||
<item row="9" column="0">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_17">
|
||||
<property name="text">
|
||||
<string>&User Interface layout (needs restart):</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>opt_gui_layout</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>E&xtra spacing to add between rows in the book list (can be negative):</string>
|
||||
@ -38,7 +48,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<item row="10" column="1">
|
||||
<widget class="QSpinBox" name="opt_book_list_extra_row_spacing">
|
||||
<property name="suffix">
|
||||
<string> px</string>
|
||||
@ -48,7 +58,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="2">
|
||||
<item row="9" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>&Toolbar</string>
|
||||
@ -86,7 +96,7 @@
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="opt_ui_style"/>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<item row="8" column="1">
|
||||
<widget class="QPushButton" name="change_font_button">
|
||||
<property name="text">
|
||||
<string>Change &font (needs restart)</string>
|
||||
@ -109,14 +119,14 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<item row="7" column="0">
|
||||
<widget class="QCheckBox" name="opt_book_list_tooltips">
|
||||
<property name="text">
|
||||
<string>Show &tooltips in the book list</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
<item row="12" column="0">
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -129,7 +139,7 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<item row="5" column="0">
|
||||
<widget class="QCheckBox" name="opt_systray_icon">
|
||||
<property name="text">
|
||||
<string>Enable system &tray icon (needs restart)</string>
|
||||
@ -146,7 +156,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<item row="8" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
@ -174,7 +184,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="6" column="0">
|
||||
<widget class="QCheckBox" name="opt_disable_tray_notification">
|
||||
<property name="text">
|
||||
<string>Disable &notifications in system tray</string>
|
||||
@ -201,17 +211,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_17">
|
||||
<property name="text">
|
||||
<string>&User Interface layout (needs restart):</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>opt_gui_layout</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<item row="5" column="1">
|
||||
<widget class="QCheckBox" name="opt_disable_animations">
|
||||
<property name="toolTip">
|
||||
<string>Disable all animations. Useful if you have a slow/old computer.</string>
|
||||
@ -221,7 +221,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<item row="6" column="1">
|
||||
<widget class="QCheckBox" name="opt_show_splash_screen">
|
||||
<property name="text">
|
||||
<string>Show &splash screen at startup</string>
|
||||
@ -235,13 +235,35 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<item row="11" column="0">
|
||||
<widget class="QCheckBox" name="opt_row_numbers_in_book_list">
|
||||
<property name="text">
|
||||
<string>Show &row numbers in the book list</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_hidpi">
|
||||
<property name="text">
|
||||
<string>Adjust for high resolution screens (needs restart):</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="opt_hidpi">
|
||||
<property name="toolTip">
|
||||
<string><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></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="cover_grid_tab">
|
||||
|
Loading…
x
Reference in New Issue
Block a user