def init_qt(args): parser = option_parser() opts, args = parser.parse_args(args) find_portable_library() if opts.with_library is not None: libpath = os.path.expanduser(opts.with_library) if not os.path.exists(libpath): os.makedirs(libpath) if os.path.isdir(libpath): prefs.set('library_path', os.path.abspath(libpath)) prints('Using library at', prefs['library_path']) override = 'calibre-gui' if islinux else None app = Application(args, override_program_name=override) app.file_event_hook = EventAccumulator() try: from PyQt5.Qt import QX11Info is_x11 = QX11Info.isPlatformX11() except Exception: is_x11 = False # Ancient broken VNC servers cannot handle icons of size greater than 256 # https://www.mobileread.com/forums/showthread.php?t=278447 ic = 'lt.png' if is_x11 else 'library.png' app.setWindowIcon(QIcon(I(ic, allow_user_override=False))) return app, opts, args