doc/relnotes: add #1000 and #1005 to the v3.6 release notes draft
[git-cola.git] / cola / hidpi.py
blobd433c76cccd6952f81282df940e111780c8f1db4
1 """Provides High DPI support by wrapping Qt options"""
2 from __future__ import absolute_import, division, unicode_literals
4 from qtpy import QtCore
6 from .i18n import N_
7 from . import core
8 from . import compat
9 from . import version
12 class Option(object):
13 AUTO = '0'
14 DISABLE = 'disable'
15 TIMES_1 = '1'
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')
30 and not core.getenv('QT_SCALE_FACTOR')):
31 compat.setenv('QT_AUTO_SCREEN_SCALE_FACTOR', '1')
32 compat.unsetenv('QT_SCALE_FACTOR')
33 elif value in (Option.TIMES_1, Option.TIMES_1_5, Option.TIMES_2):
34 compat.unsetenv('QT_AUTO_SCREEN_SCALE_FACTOR')
35 compat.setenv('QT_SCALE_FACTOR', value)
38 def options():
39 return (
40 (N_('Auto'), Option.AUTO),
41 (N_('Disable'), Option.DISABLE),
42 (N_('x 1'), Option.TIMES_1),
43 (N_('x 1.5'), Option.TIMES_1_5),
44 (N_('x 2'), Option.TIMES_2),