def __init__(self, master_password=None, urls=(), new_instance=False, shutdown=False, restart_state=None, no_session=False, run_local_server=True): if not isosx: # OS X turns this on automatically for v in ('QT_AUTO_SCREEN_SCALE_FACTOR', 'QT_SCALE_FACTOR', 'QT_SCREEN_SCALE_FACTORS', 'QT_DEVICE_PIXEL_RATIO'): if os.environ.get(v): break else: QApplication.setAttribute( Qt.ApplicationAttribute.AA_EnableHighDpiScaling, True) QApplication.__init__(self, [appname, '-name', appname]) if in_dark_mode: self.setPalette(dark_palette()) self.setOrganizationName('kovidgoyal') self.setApplicationName(appname) self.setApplicationVersion(str_version) self.no_session = no_session self.handle_unix_signals() if not QSslSocket.supportsSsl(): raise SystemExit('Qt has been compiled without SSL support!') from .config import font_families ff = font_families().get('sans-serif') or 'default' if ff == 'default': ff = font_families().get('default') or 'default' f = self.font() if ff != 'default': f.setFamily(ff) self.setFont(f) self.password_loaded.connect(self.on_password_load, type=Qt.ConnectionType.QueuedConnection) if master_password is not None: password_db.start_load(master_password, self.password_loaded.emit) elif restart_state and 'key' in restart_state: password_db.start_load(restart_state.pop('key'), self.password_loaded.emit, pw_is_key=True) self.lastWindowClosed.connect(self.shutdown) if run_local_server: self.run_local_server(urls, new_instance, shutdown) sys.excepthook = self.on_unhandled_error self.windows = [] f = self.font() if (f.family(), f.pointSize()) == ( 'Sans Serif', 9): # Hard coded Qt settings, no user preference detected f.setPointSize(10) if 'Ubuntu' in QFontDatabase().families(): f.setFamily('Ubuntu') self.setFont(f) self.downloads = Downloads(self) self.disk_cache = create_favicon_cache() self.key_filter = KeyFilter(self) self.installEventFilter(self.key_filter)
def __init__(self): QApplication.__init__(self, []) self.setStyle("Fusion") self.setQuitOnLastWindowClosed(False)