def __init__(self, reactor, downloader, global_options): super().__init__() self._reactor = reactor self.downloader = downloader self.options = global_options QWebSettings.setObjectCacheCapacities(0, 0, 0) QWebSettings.setMaximumPagesInCache(0) self._windows = None
def initUI(self): self.setMinimumSize(300, 300) # self.TextEdit = QtWidgets.QTextEdit(self) # self.TextEdit.setMinimumSize(300, 300) # self.TextEdit.setReadOnly(True) # self.load(QtCore.QUrl('file:///'+os.getcwd()+"/generated_html/index.html")) QWebSettings.setMaximumPagesInCache(0) QWebSettings.setObjectCacheCapacities(0, 0, 0)
def __init__(self, fullscreen=False, sizes=None): """ This constructor function initializes a layout of the Arius output module but doesn`t displays it on the screen. Firstly, it creates a new app and detects screens configuration. Then, QGridLayout is created and its appearance is configured: margins and spaces between elements is set to 0. After that, we create three QWebViews: one for our main content view and two others for header and footer views. Immideately after creating these instances we assign them their heights according to percentages given by user and dimensions of the screen. Next, we remove scroll bars from top and bottom views and load predefined pages into them. Then we allow QWebKit to run all extensions it needs to render the page. After that, wee set the layout design as a grid of three rows. Finally, we create an updater object which will run in another stream and a timer instance which checks that stream for new commands from the server, and in case if there`s some update handles it. """ if not fullscreen and not sizes: print 'You must initialize windows size' raise Exception self._fullscreen = fullscreen if sizes: self._screen_width = sizes[0] self._screen_height = sizes[1] self._app = QtWidgets.QApplication(sys.argv) self._app.setStyle("Fusion") if self._fullscreen: self._get_screen_height() self._layout = QGridLayout() # create a main view of an app self._layout.setSpacing(0) # and do some design settings self._layout.setContentsMargins(0, 0, 0, 0) self._main_browser = QWebView() # create a main content view # and initialize zoom factor variable which will be used to control # zoom main_page = FakeBrowser(self) self._main_browser.setPage(main_page) self._zoom_factor = 1 self._top_browser = QWebView() # and create top and bottom views self._bottom_browser = QWebView() self._top_browser_height = config[ 'output_header_height'] * self._screen_height # calculate views sizes self._bottom_browser_height = config[ 'output_footer_height'] * self._screen_height self._top_browser.setMaximumHeight( self._top_browser_height) # and assign them to the views self._top_browser.setMinimumHeight(self._top_browser_height) self._bottom_browser.setMaximumHeight(self._bottom_browser_height) self._bottom_browser.setMinimumHeight(self._bottom_browser_height) self._top_browser.page().mainFrame().setScrollBarPolicy( QtCore.Qt.Vertical, QtCore.Qt.ScrollBarAlwaysOff) # remove the scroll bars self._main_browser.page().mainFrame().setScrollBarPolicy(QtCore.Qt.Vertical, QtCore.Qt.ScrollBarAlwaysOff) self._main_browser.page().mainFrame().setScrollBarPolicy(QtCore.Qt.Horizontal, QtCore.Qt.ScrollBarAlwaysOff) self._bottom_browser.page().mainFrame().setScrollBarPolicy( QtCore.Qt.Vertical, QtCore.Qt.ScrollBarAlwaysOff) self._top_browser_load_url( config['flask_server_home'] + config['output_browser_top_page']) # load default design self._bottom_browser_load_url( config['flask_server_home'] + config['output_browser_bottom_page']) self._main_browser.settings().setAttribute( QWebSettings.DeveloperExtrasEnabled, True) # enable console self._main_browser.settings().setAttribute( QWebSettings.PluginsEnabled, True) # enable plugins QWebSettings.setObjectCacheCapacities(0, 0, 0) # disable caching self._main_browser.settings().setAttribute( QWebSettings.AcceleratedCompositingEnabled, True) self._main_browser.settings().setAttribute( QWebSettings.WebGLEnabled, True) self._layout.addWidget(self._top_browser, 1, 0) # set views positions self._layout.addWidget(self._main_browser, 2, 0) self._layout.addWidget(self._bottom_browser, 3, 0) # create a RLock object to syncronyze threads. self._lock = threading.RLock() # and create an updater object self._updater = OutputUpdater(self._lock) self._updater.start() # which is ran in another non-blocking stream self.timeoutTimer = QTimer() # create a timer to check for commands tCallback = functools.partial( self._handle_command) # set a timer`s function self.timeoutTimer.timeout.connect(tCallback) self.timeoutTimer.start( config['output_update_frequency']) # and start it # as no data is displayed on the main view - curent content type is # None self._cur_filetype = None # text to speech speaker self._speaker = None # audioplayer self._player = Player()
# (MapType.attribute, QWebSettings.AcceleratedCompositingEnabled), #'tiled-backing-store': # (MapType.attribute, QWebSettings.TiledBackingStoreEnabled), }, 'storage': { 'offline-storage-database': (MapType.attribute, QWebSettings.OfflineStorageDatabaseEnabled), 'offline-web-application-storage': (MapType.attribute, QWebSettings.OfflineWebApplicationCacheEnabled), 'local-storage': (MapType.attribute, QWebSettings.LocalStorageEnabled), 'maximum-pages-in-cache': (MapType.static_setter, lambda v: QWebSettings.setMaximumPagesInCache(v)), 'object-cache-capacities': (MapType.static_setter, lambda v: QWebSettings.setObjectCacheCapacities(*v)), 'offline-storage-default-quota': (MapType.static_setter, lambda v: QWebSettings.setOfflineStorageDefaultQuota(v)), 'offline-web-application-cache-quota': (MapType.static_setter, lambda v: QWebSettings.setOfflineWebApplicationCacheQuota(v)), }, 'general': { 'private-browsing': (MapType.attribute, QWebSettings.PrivateBrowsingEnabled), 'developer-extras': (MapType.attribute, QWebSettings.DeveloperExtrasEnabled), 'print-element-backgrounds': (MapType.attribute, QWebSettings.PrintElementBackgrounds), 'xss-auditing': (MapType.attribute, QWebSettings.XSSAuditingEnabled),
# (MapType.attribute, QWebSettings.TiledBackingStoreEnabled), }, 'storage': { 'offline-storage-database': (MapType.attribute, QWebSettings.OfflineStorageDatabaseEnabled), 'offline-web-application-storage': (MapType.attribute, QWebSettings.OfflineWebApplicationCacheEnabled), 'local-storage': (MapType.attribute, QWebSettings.LocalStorageEnabled), 'maximum-pages-in-cache': (MapType.static_setter, lambda v: QWebSettings.setMaximumPagesInCache(v)), 'object-cache-capacities': (MapType.static_setter, lambda v: QWebSettings.setObjectCacheCapacities(*v)), 'offline-storage-default-quota': (MapType.static_setter, lambda v: QWebSettings.setOfflineStorageDefaultQuota(v)), 'offline-web-application-cache-quota': (MapType.static_setter, lambda v: QWebSettings.setOfflineWebApplicationCacheQuota(v)), }, 'general': { 'private-browsing': (MapType.attribute, QWebSettings.PrivateBrowsingEnabled), 'developer-extras': (MapType.attribute, QWebSettings.DeveloperExtrasEnabled), 'print-element-backgrounds': (MapType.attribute, QWebSettings.PrintElementBackgrounds), 'xss-auditing':
def __init__(self, fullscreen=False, sizes=None): """ This constructor function initializes a layout of the Arius output module but doesn`t displays it on the screen. Firstly, it creates a new app and detects screens configuration. Then, QGridLayout is created and its appearance is configured: margins and spaces between elements is set to 0. After that, we create three QWebViews: one for our main content view and two others for header and footer views. Immideately after creating these instances we assign them their heights according to percentages given by user and dimensions of the screen. Next, we remove scroll bars from top and bottom views and load predefined pages into them. Then we allow QWebKit to run all extensions it needs to render the page. After that, wee set the layout design as a grid of three rows. Finally, we create an updater object which will run in another stream and a timer instance which checks that stream for new commands from the server, and in case if there`s some update handles it. """ if not fullscreen and not sizes: print 'You must initialize windows size' raise Exception self._fullscreen = fullscreen if sizes: self._screen_width = sizes[0] self._screen_height = sizes[1] self._app = QtWidgets.QApplication(sys.argv) self._app.setStyle("Fusion") if self._fullscreen: self._get_screen_height() self._layout = QGridLayout() # create a main view of an app self._layout.setSpacing(0) # and do some design settings self._layout.setContentsMargins(0, 0, 0, 0) self._main_browser = QWebView() # create a main content view # and initialize zoom factor variable which will be used to control # zoom main_page = FakeBrowser(self) self._main_browser.setPage(main_page) self._zoom_factor = 1 self._top_browser = QWebView() # and create top and bottom views self._bottom_browser = QWebView() self._top_browser_height = config[ 'output_header_height'] * self._screen_height # calculate views sizes self._bottom_browser_height = config[ 'output_footer_height'] * self._screen_height self._top_browser.setMaximumHeight( self._top_browser_height) # and assign them to the views self._top_browser.setMinimumHeight(self._top_browser_height) self._bottom_browser.setMaximumHeight(self._bottom_browser_height) self._bottom_browser.setMinimumHeight(self._bottom_browser_height) self._top_browser.page().mainFrame().setScrollBarPolicy( QtCore.Qt.Vertical, QtCore.Qt.ScrollBarAlwaysOff) # remove the scroll bars self._main_browser.page().mainFrame().setScrollBarPolicy( QtCore.Qt.Vertical, QtCore.Qt.ScrollBarAlwaysOff) self._main_browser.page().mainFrame().setScrollBarPolicy( QtCore.Qt.Horizontal, QtCore.Qt.ScrollBarAlwaysOff) self._bottom_browser.page().mainFrame().setScrollBarPolicy( QtCore.Qt.Vertical, QtCore.Qt.ScrollBarAlwaysOff) self._top_browser_load_url( config['flask_server_home'] + config['output_browser_top_page']) # load default design self._bottom_browser_load_url(config['flask_server_home'] + config['output_browser_bottom_page']) self._main_browser.settings().setAttribute( QWebSettings.DeveloperExtrasEnabled, True) # enable console self._main_browser.settings().setAttribute(QWebSettings.PluginsEnabled, True) # enable plugins QWebSettings.setObjectCacheCapacities(0, 0, 0) # disable caching self._main_browser.settings().setAttribute( QWebSettings.AcceleratedCompositingEnabled, True) self._main_browser.settings().setAttribute(QWebSettings.WebGLEnabled, True) self._layout.addWidget(self._top_browser, 1, 0) # set views positions self._layout.addWidget(self._main_browser, 2, 0) self._layout.addWidget(self._bottom_browser, 3, 0) # create a RLock object to syncronyze threads. self._lock = threading.RLock() # and create an updater object self._updater = OutputUpdater(self._lock) self._updater.start() # which is ran in another non-blocking stream self.timeoutTimer = QTimer() # create a timer to check for commands tCallback = functools.partial( self._handle_command) # set a timer`s function self.timeoutTimer.timeout.connect(tCallback) self.timeoutTimer.start( config['output_update_frequency']) # and start it # as no data is displayed on the main view - curent content type is # None self._cur_filetype = None # text to speech speaker self._speaker = None # audioplayer self._player = Player()
def __init__(self, parent, fullscreen, sizes): """ This constructor function initializes a layout of the Arius output module but doesn`t displays it on the screen. Firstly, it creates a new app and detects screens configuration. Then, QGridLayout is created and its appearance is configured: margins and spaces between elements is set to 0. After that, we create three QWebViews: one for our main content view and two others for header and footer views. Immideately after creating these instances we assign them their heights according to percentages given by user and dimensions of the screen. Next, we remove scroll bars from top and bottom views and load predefined pages into them. Then we allow QWebKit to run all extensions it needs to render the page. After that, wee set the layout design as a grid of three rows. Finally, we create an updater object which will run in another stream and a timer instance which checks that stream for new commands from the server, and in case if there`s some update handles it. """ super(BrowserController, self).__init__() if not fullscreen and not sizes: print 'You must initialize windows size' raise Exception self._fullscreen = fullscreen if sizes: self._screen_width = sizes[0] self._screen_height = sizes[1] self._app = QtWidgets.QApplication(sys.argv) self._app.setStyle("Fusion") if self._fullscreen: self._get_screen_height() self._layout = QGridLayout() self._layout.setSpacing(0) self._layout.setContentsMargins(0, 0, 0, 0) self._main_browser = QWebView() main_page = FakePage(self) self._main_browser.setPage(main_page) self._top_browser = QWebView() self._bottom_browser = QWebView() self._top_browser_height = config['output_header_height'] * self._screen_height self._bottom_browser_height = config['output_footer_height'] * self._screen_height self._top_browser.setMaximumHeight(self._top_browser_height) self._top_browser.setMinimumHeight(self._top_browser_height) self._bottom_browser.setMaximumHeight(self._bottom_browser_height) self._bottom_browser.setMinimumHeight(self._bottom_browser_height) self._top_browser.page().mainFrame().setScrollBarPolicy( QtCore.Qt.Vertical, QtCore.Qt.ScrollBarAlwaysOff) self._main_browser.page().mainFrame().setScrollBarPolicy( QtCore.Qt.Vertical, QtCore.Qt.ScrollBarAlwaysOff) self._main_browser.page().mainFrame().setScrollBarPolicy( QtCore.Qt.Horizontal, QtCore.Qt.ScrollBarAlwaysOff) self._bottom_browser.page().mainFrame().setScrollBarPolicy( QtCore.Qt.Vertical, QtCore.Qt.ScrollBarAlwaysOff) self._top_browser_load_url( config['flask_server_home'] + config['output_browser_top_page']) self._bottom_browser_load_url( config['flask_server_home'] + config['output_browser_bottom_page']) self._main_browser.settings().setAttribute( QWebSettings.DeveloperExtrasEnabled, True) self._main_browser.settings().setAttribute(QWebSettings.PluginsEnabled, True) QWebSettings.setObjectCacheCapacities(0, 0, 0) self._main_browser.settings().setAttribute( QWebSettings.AcceleratedCompositingEnabled, True) self._main_browser.settings().setAttribute(QWebSettings.WebGLEnabled, True) self._layout.addWidget(self._top_browser, 1, 0) self._layout.addWidget(self._main_browser, 2, 0) self._layout.addWidget(self._bottom_browser, 3, 0) self._parent = parent self._parent.load_url.connect(self._load_url) self._parent.js_execution.connect(self._execute_js) self._parent.zooming.connect(self._zoom)
def __init__(self, parent, fullscreen, sizes): """ This constructor function initializes a layout of the Arius output module but doesn`t displays it on the screen. Firstly, it creates a new app and detects screens configuration. Then, QGridLayout is created and its appearance is configured: margins and spaces between elements is set to 0. After that, we create three QWebViews: one for our main content view and two others for header and footer views. Immideately after creating these instances we assign them their heights according to percentages given by user and dimensions of the screen. Next, we remove scroll bars from top and bottom views and load predefined pages into them. Then we allow QWebKit to run all extensions it needs to render the page. After that, wee set the layout design as a grid of three rows. Finally, we create an updater object which will run in another stream and a timer instance which checks that stream for new commands from the server, and in case if there`s some update handles it. """ super(BrowserController, self).__init__() if not fullscreen and not sizes: print 'You must initialize windows size' raise Exception self._fullscreen = fullscreen if sizes: self._screen_width = sizes[0] self._screen_height = sizes[1] self._app = QtWidgets.QApplication(sys.argv) self._app.setStyle("Fusion") if self._fullscreen: self._get_screen_height() self._layout = QGridLayout() self._layout.setSpacing(0) self._layout.setContentsMargins(0, 0, 0, 0) self._main_browser = QWebView() main_page = FakePage(self) self._main_browser.setPage(main_page) self._top_browser = QWebView() self._bottom_browser = QWebView() self._top_browser_height = config[ 'output_header_height'] * self._screen_height self._bottom_browser_height = config[ 'output_footer_height'] * self._screen_height self._top_browser.setMaximumHeight(self._top_browser_height) self._top_browser.setMinimumHeight(self._top_browser_height) self._bottom_browser.setMaximumHeight(self._bottom_browser_height) self._bottom_browser.setMinimumHeight(self._bottom_browser_height) self._top_browser.page().mainFrame().setScrollBarPolicy( QtCore.Qt.Vertical, QtCore.Qt.ScrollBarAlwaysOff) self._main_browser.page().mainFrame().setScrollBarPolicy( QtCore.Qt.Vertical, QtCore.Qt.ScrollBarAlwaysOff) self._main_browser.page().mainFrame().setScrollBarPolicy( QtCore.Qt.Horizontal, QtCore.Qt.ScrollBarAlwaysOff) self._bottom_browser.page().mainFrame().setScrollBarPolicy( QtCore.Qt.Vertical, QtCore.Qt.ScrollBarAlwaysOff) self._top_browser_load_url(config['flask_server_home'] + config['output_browser_top_page']) self._bottom_browser_load_url(config['flask_server_home'] + config['output_browser_bottom_page']) self._main_browser.settings().setAttribute( QWebSettings.DeveloperExtrasEnabled, True) self._main_browser.settings().setAttribute(QWebSettings.PluginsEnabled, True) QWebSettings.setObjectCacheCapacities(0, 0, 0) self._main_browser.settings().setAttribute( QWebSettings.AcceleratedCompositingEnabled, True) self._main_browser.settings().setAttribute(QWebSettings.WebGLEnabled, True) self._layout.addWidget(self._top_browser, 1, 0) self._layout.addWidget(self._main_browser, 2, 0) self._layout.addWidget(self._bottom_browser, 3, 0) self._parent = parent self._parent.load_url.connect(self._load_url) self._parent.js_execution.connect(self._execute_js) self._parent.zooming.connect(self._zoom)