A spot of refatoring

This commit is contained in:
Kovid Goyal 2017-04-22 17:30:05 +05:30
parent 46b9d7762e
commit 3c9f17bd2b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -924,23 +924,7 @@ def show_temp_dir_error(err):
'Could not create temporary directory, calibre cannot start.') + ' ' + extra, det_msg=traceback.format_exc(), show=True)
class Application(QApplication):
shutdown_signal_received = pyqtSignal()
def __init__(self, args, force_calibre_style=False, override_program_name=None, headless=False, color_prefs=gprefs):
self.file_event_hook = None
if override_program_name:
args = [override_program_name] + args[1:]
if headless:
if not args:
args = sys.argv[:1]
args.extend(['-platformpluginpath', sys.extensions_location, '-platform', 'headless'])
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:
# On OS X high dpi scaling is turned on automatically by the OS, so we dont need to set it explicitly
def setup_hidpi():
# This requires Qt >= 5.6
has_env_setting = False
env_vars = ('QT_AUTO_SCREEN_SCALE_FACTOR', 'QT_SCALE_FACTOR', 'QT_SCREEN_SCALE_FACTORS', 'QT_DEVICE_PIXEL_RATIO')
@ -961,6 +945,26 @@ class Application(QApplication):
os.environ.pop(p, None)
elif DEBUG:
prints('Not controlling hidpi scaling')
class Application(QApplication):
shutdown_signal_received = pyqtSignal()
def __init__(self, args, force_calibre_style=False, override_program_name=None, headless=False, color_prefs=gprefs):
self.file_event_hook = None
if override_program_name:
args = [override_program_name] + args[1:]
if headless:
if not args:
args = sys.argv[:1]
args.extend(['-platformpluginpath', sys.extensions_location, '-platform', 'headless'])
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:
# On OS X high dpi scaling is turned on automatically by the OS, so we dont need to set it explicitly
setup_hidpi()
QApplication.setOrganizationName('calibre-ebook.com')
QApplication.setOrganizationDomain(QApplication.organizationName())
QApplication.setApplicationVersion(__version__)