git-cola v4.9.0
[git-cola.git] / cola / hidpi.py
blobf5e53178f5e7b73af3cd5e8aa2d8732b1243cb57
1 """Provides High DPI support by wrapping Qt options"""
3 from qtpy import QtCore
5 from .i18n import N_
6 from . import core
7 from . import compat
8 from . import version
11 class Option:
12 AUTO = '0'
13 DISABLE = 'disable'
14 TIMES_1 = '1'
15 TIMES_1_25 = '1.25'
16 TIMES_1_5 = '1.5'
17 TIMES_2 = '2'
20 def is_supported():
21 return version.check('qt-hidpi-scale', QtCore.__version__)
24 def apply_choice(value):
25 value = compat.ustr(value)
26 if value == Option.AUTO:
27 # Do not override the configuration when either of these
28 # two environment variables are defined.
29 if not core.getenv('QT_AUTO_SCREEN_SCALE_FACTOR') and not core.getenv(
30 'QT_SCALE_FACTOR'
32 compat.setenv('QT_AUTO_SCREEN_SCALE_FACTOR', '1')
33 compat.unsetenv('QT_SCALE_FACTOR')
34 elif value and value != Option.DISABLE:
35 compat.unsetenv('QT_AUTO_SCREEN_SCALE_FACTOR')
36 compat.setenv('QT_SCALE_FACTOR', value)
39 def options():
40 return (
41 (N_('Auto'), Option.AUTO),
42 (N_('Disable'), Option.DISABLE),
43 (N_('x 1'), Option.TIMES_1),
44 (N_('x 1.25'), Option.TIMES_1_25),
45 (N_('x 1.5'), Option.TIMES_1_5),
46 (N_('x 2'), Option.TIMES_2),