def _chromium_version(): """Get the Chromium version for QtWebEngine. This can also be checked by looking at this file with the right Qt tag: https://github.com/qt/qtwebengine/blob/dev/tools/scripts/version_resolver.py#L41 Quick reference: Qt 5.7: Chromium 49 Qt 5.8: Chromium 53 Qt 5.9: Chromium 56 Qt 5.10: Chromium 61 Qt 5.11: Chromium 65 Qt 5.12: Chromium 69 (?) Also see https://www.chromium.org/developers/calendar """ if QWebEngineProfile is None: # This should never happen return 'unavailable' profile = QWebEngineProfile() ua = profile.httpUserAgent() match = re.search(r' Chrome/([^ ]*) ', ua) if not match: log.misc.error("Could not get Chromium version from: {}".format(ua)) return 'unknown' return match.group(1)
def _chromium_version(): """Get the Chromium version for QtWebEngine. This can also be checked by looking at this file with the right Qt tag: http://code.qt.io/cgit/qt/qtwebengine.git/tree/tools/scripts/version_resolver.py#n41 Quick reference: Qt 5.7: Chromium 49 49.0.2623.111 (2016-03-31) 5.7.1: Security fixes up to 54.0.2840.87 (2016-11-01) Qt 5.8: Chromium 53 53.0.2785.148 (2016-08-31) 5.8.0: Security fixes up to 55.0.2883.75 (2016-12-01) Qt 5.9: Chromium 56 (LTS) 56.0.2924.122 (2017-01-25) 5.9.6: Security fixes up to 66.0.3359.170 (2018-05-10) Qt 5.10: Chromium 61 61.0.3163.140 (2017-09-05) 5.10.1: Security fixes up to 64.0.3282.140 (2018-02-01) Qt 5.11: Chromium 65 65.0.3325.151 (.1: .230) (2018-03-06) 5.11.2: Security fixes up to 68.0.3440.75 (2018-07-24) Qt 5.12: Chromium 69 69.0.3497.128 (~2018-09-17) 5.12.0: Security fixes up to 70.0.3538.67 (2018-10-16) Also see https://www.chromium.org/developers/calendar and https://chromereleases.googleblog.com/ """ profile = QWebEngineProfile() ua = profile.httpUserAgent() match = re.search(r' Chrome/([^ ]*) ', ua) if not match: return 'unknown' return match.group(1)
def _chromium_version(): """Get the Chromium version for QtWebEngine.""" if QWebEngineProfile is None: # This should never happen return 'unavailable' profile = QWebEngineProfile() ua = profile.httpUserAgent() match = re.search(r' Chrome/([^ ]*) ', ua) if not match: log.misc.error("Could not get Chromium version from: {}".format(ua)) return 'unknown' return match.group(1)
def create_webprofile(self): """Create a webengineprofile to use in all views.""" if self.config.get("privacy_mode"): webprofile = QWebEngineProfile() else: webprofile = QWebEngineProfile.defaultProfile() debug("Browser session is private: {}".format( webprofile.isOffTheRecord())) if self.config.get("user_agent"): webprofile.setHttpUserAgent(self.config["user_agent"]) debug('Set user agent to "{}"'.format(webprofile.httpUserAgent())) self.webprofile = webprofile
def _chromium_version(): """Get the Chromium version for QtWebEngine.""" if QWebEngineProfile is None: # This should never happen return 'unavailable' profile = QWebEngineProfile() ua = profile.httpUserAgent() match = re.search(r' Chrome/([^ ]*) ', ua) if not match: log.misc.error("Could not get Chromium version from: {}".format(ua)) return 'unknown' return match.group(1)
def _chromium_version(): """Get the Chromium version for QtWebEngine. This can also be checked by looking at this file with the right Qt tag: http://code.qt.io/cgit/qt/qtwebengine.git/tree/tools/scripts/version_resolver.py#n41 Quick reference: Qt 5.7: Chromium 49 49.0.2623.111 (2016-03-31) 5.7.1: Security fixes up to 54.0.2840.87 (2016-11-01) Qt 5.8: Chromium 53 53.0.2785.148 (2016-08-31) 5.8.0: Security fixes up to 55.0.2883.75 (2016-12-01) Qt 5.9: Chromium 56 (LTS) 56.0.2924.122 (2017-01-25) 5.9.8: Security fixes up to 72.0.3626.121 (2019-03-01) Qt 5.10: Chromium 61 61.0.3163.140 (2017-09-05) 5.10.1: Security fixes up to 64.0.3282.140 (2018-02-01) Qt 5.11: Chromium 65 65.0.3325.151 (.1: .230) (2018-03-06) 5.11.3: Security fixes up to 70.0.3538.102 (2018-11-09) Qt 5.12: Chromium 69 (LTS) 69.0.3497.113 (2018-09-27) 5.12.3: Security fixes up to 73.0.3683.75 (2019-03-12) Qt 5.13: (in development) Chromium 73 73.0.3683.105 (~2019-02-28) Also see https://www.chromium.org/developers/calendar and https://chromereleases.googleblog.com/ """ if QWebEngineProfile is None: # This should never happen return 'unavailable' profile = QWebEngineProfile() ua = profile.httpUserAgent() match = re.search(r' Chrome/([^ ]*) ', ua) if not match: log.misc.error("Could not get Chromium version from: {}".format(ua)) return 'unknown' return match.group(1)
def _chromium_version(): """Get the Chromium version for QtWebEngine. This can also be checked by looking at this file with the right Qt tag: http://code.qt.io/cgit/qt/qtwebengine.git/tree/tools/scripts/version_resolver.py#n41 Quick reference: Qt 5.7: Chromium 49 49.0.2623.111 (2016-03-31) 5.7.1: Security fixes up to 54.0.2840.87 (2016-11-01) Qt 5.8: Chromium 53 53.0.2785.148 (2016-08-31) 5.8.0: Security fixes up to 55.0.2883.75 (2016-12-01) Qt 5.9: Chromium 56 (LTS) 56.0.2924.122 (2017-01-25) 5.9.7: Security fixes up to 69.0.3497.113 (2018-09-27) Qt 5.10: Chromium 61 61.0.3163.140 (2017-09-05) 5.10.1: Security fixes up to 64.0.3282.140 (2018-02-01) Qt 5.11: Chromium 65 65.0.3325.151 (.1: .230) (2018-03-06) 5.11.3: Security fixes up to 70.0.3538.102 (2018-11-09) Qt 5.12: Chromium 69 (LTS) 69.0.3497.113 (2018-09-27) 5.12.1: Security fixes up to 71.0.3578.94 (2018-12-14) 5.12.2: Security fixes up to 72.0.3626.96 (2019-02-06) Qt 5.13: (in development) Chromium 71 merged, 73 in review. Also see https://www.chromium.org/developers/calendar and https://chromereleases.googleblog.com/ """ if QWebEngineProfile is None: # This should never happen return 'unavailable' profile = QWebEngineProfile() ua = profile.httpUserAgent() match = re.search(r' Chrome/([^ ]*) ', ua) if not match: log.misc.error("Could not get Chromium version from: {}".format(ua)) return 'unknown' return match.group(1)
def chromium_version(): """ Get the Chromium version for QtWebEngine. This can also be checked by looking at this file with the right Qt tag: https://github.com/qt/qtwebengine/blob/dev/tools/scripts/version_resolver.py#L41 """ if QWebEngineProfile is None: # This should never happen return 'unavailable' profile = QWebEngineProfile() ua = profile.httpUserAgent() match = re.search(r' Chrome/([^ ]*) ', ua) if not match: logging.error("Could not get Chromium version from: {}".format(ua)) return 'unknown' return match.group(1)
def _chromium_version(): """Get the Chromium version for QtWebEngine. This can also be checked by looking at this file with the right Qt tag: http://code.qt.io/cgit/qt/qtwebengine.git/tree/tools/scripts/version_resolver.py#n41 Quick reference: Qt 5.7: Chromium 49 49.0.2623.111 (2016-03-02) 5.7.1: Security fixes up to 54.0.2840.87 (2016-10-19) Qt 5.8: Chromium 53 53.0.2785.148 (2016-08-31) 5.8.0: Security fixes up to 55.0.2883.75 (2016-12-01) Qt 5.9: Chromium 56 (LTS) 56.0.2924.122 (2017-01-25) 5.9.6: Security fixes up to 66.0.3359.170 (2018-04-17) Qt 5.10: Chromium 61 61.0.3163.140 (2017-09-05) 5.10.1: Security fixes up to 64.0.3282.140 (2018-01-24) Qt 5.11: Chromium 65 65.0.3325.151 (.1: .230) (2018-03-06) 5.11.1: Security fixes up to 67.0.3396.87 (2018-05-29) Qt 5.12: Chromium 69 (?) current dev branch: 67.0.3396.76 (2018-05-29) Also see https://www.chromium.org/developers/calendar """ if QWebEngineProfile is None: # This should never happen return 'unavailable' profile = QWebEngineProfile() ua = profile.httpUserAgent() match = re.search(r' Chrome/([^ ]*) ', ua) if not match: log.misc.error("Could not get Chromium version from: {}".format(ua)) return 'unknown' return match.group(1)
def _chromium_version(): """Get the Chromium version for QtWebEngine. This can also be checked by looking at this file with the right Qt tag: https://github.com/qt/qtwebengine/blob/dev/tools/scripts/version_resolver.py#L41 Quick reference: Qt 5.7: Chromium 49 Qt 5.8: Chromium 53 Qt 5.9: Chromium 56 Qt 5.10: Chromium 61 Qt 5.11: Chromium 63 Qt 5.12: Chromium 65 (?) """ if QWebEngineProfile is None: # This should never happen return 'unavailable' profile = QWebEngineProfile() ua = profile.httpUserAgent() match = re.search(r' Chrome/([^ ]*) ', ua) if not match: log.misc.error("Could not get Chromium version from: {}".format(ua)) return 'unknown' return match.group(1)
def __init__(self, url, disable_browser): # initialize super().__init__() self._view = None self._is_closing = False # initialize the main window self.setWindowTitle(APP_NAME) if IS_FROZEN: base_dir = os.path.join(sys._MEIPASS, "vasl_templates/webapp") #pylint: disable=no-member,protected-access else: base_dir = os.path.join(os.path.split(__file__)[0], "webapp") self.setWindowIcon( QIcon(os.path.join(base_dir, "static/images/app.ico"))) # create the menu menu_bar = QMenuBar(self) file_menu = menu_bar.addMenu("&File") def add_action(caption, icon, handler): """Add a menu action.""" icon = QIcon( os.path.join(base_dir, "static/images/menu", icon ) if icon else None) action = QAction(icon, caption, self) action.triggered.connect(handler) file_menu.addAction(action) add_action("&Settings", "settings.png", self.on_settings) add_action("&About", "info.png", self.on_about) file_menu.addSeparator() add_action("E&xit", "exit.png", self.on_exit) # set the window geometry if disable_browser: self.setFixedSize(300, 108) else: # restore it from the previous session val = app_settings.value("MainWindow/geometry") if val: self.restoreGeometry(val) else: self.resize(1000, 650) self.setMinimumSize(1000, 620) # initialize the layout layout = QVBoxLayout(self) layout.setMenuBar(menu_bar) # FUDGE! We offer the option to disable the QWebEngineView since getting it to run # under Windows (especially older versions) is unreliable (since it uses OpenGL). # By disabling it, the program will at least start (in particular, the webapp server), # and non-technical users can then open an external browser and connect to the webapp # that way. Sigh... if not disable_browser: # initialize the web view self._view = QWebEngineView() layout.addWidget(self._view) # initialize the web page # nb: we create an off-the-record profile to stop the view from using cached JS files :-/ profile = QWebEngineProfile(None, self._view) version = APP_NAME.lower().replace(" ", "-") + "/" + APP_VERSION[1:] profile.setHttpUserAgent( re.sub(r"QtWebEngine/\S+", version, profile.httpUserAgent())) page = AppWebPage(profile, self._view) self._view.setPage(page) # create a web channel to communicate with the front-end web_channel = QWebChannel(page) # FUDGE! We would like to register a WebChannelHandler instance as the handler, but this crashes PyQt :-/ # Instead, we register ourself as the handler, and delegate processing to a WebChannelHandler. # The downside is that PyQt emits lots of warnings about our member variables not being properties, # but we filter them out in qtMessageHandler() :-/ self._web_channel_handler = WebChannelHandler(self) web_channel.registerObject("handler", self) page.setWebChannel(web_channel) # load the webapp url += "?pyqt=1" self._view.load(QUrl(url)) else: # show a minimal UI label = QLabel() label.setTextFormat(Qt.RichText) label.setText( "Running the <em>{}</em> application. <br>" \ "Click <a href='{}'>here</a> to connect." \ "<p> Close this window when you're done.".format( APP_NAME, url ) ) label.setStyleSheet( "QLabel { background-color: white ; padding: 0.5em ; }") label.setOpenExternalLinks(True) layout.addWidget(label) layout.setContentsMargins(QMargins(0, 0, 0, 0)) # register the instance assert MainWindow.instance is None MainWindow.instance = self