Make the QT_VERSION available to the JS runtime

This commit is contained in:
Kovid Goyal 2020-07-24 11:57:34 +05:30
parent d2db909851
commit 6436d36f2e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 4 additions and 1 deletions

View File

@ -9,7 +9,7 @@ import sys
from itertools import count
from PyQt5.Qt import (
QApplication, QBuffer, QByteArray, QFontDatabase, QFontInfo, QHBoxLayout, QSize,
QApplication, QBuffer, QByteArray, QFontDatabase, QFontInfo, QHBoxLayout, QSize, QT_VERSION,
Qt, QTimer, QUrl, QWidget, pyqtSignal
)
from PyQt5.QtWebEngineCore import QWebEngineUrlSchemeHandler
@ -581,6 +581,7 @@ class WebView(RestartingWebEngineView):
'ui_font_sz': '{}px'.format(fi.pixelSize()),
'show_home_page_on_ready': self.show_home_page_on_ready,
'system_colors': system_colors(),
'QT_VERSION': QT_VERSION,
}
self.bridge.create_view(
vprefs['session_data'], vprefs['local_storage'], field_metadata.all_metadata(), ui_data)

View File

@ -81,6 +81,7 @@ runtime = {
'is_standalone_viewer': False,
'viewer_in_full_screen': False,
'in_develop_mode': IN_DEVELOP_MODE is '1',
'QT_VERSION': 0,
}

View File

@ -175,6 +175,7 @@ def create_view(prefs, local_storage, field_metadata, ui_data):
library_data.field_metadata = field_metadata
document.documentElement.style.fontFamily = f'"{ui_data.ui_font_family}", sans-serif'
document.documentElement.style.fontSize = ui_data.ui_font_sz
runtime.QT_VERSION = ui_data.QT_VERSION
if view is None:
create_session_data(prefs, local_storage)
view = View(document.getElementById('view'))