Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add key combo for hard refresh in kiosk #147

Merged
merged 3 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions controller/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Added

- kiosk: Add a key combination to perform hard refresh (Ctrl-Shift-R)
- os: Added localization options for Polish and Czech

# [2023.9.0] - 2023-09-12
Expand Down
4 changes: 4 additions & 0 deletions docs/user-manual/Readme.org
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ View what has been added, changed and fixed with each version.

A status screen providing a brief status report about various components of the system is available on ~tty8~. It can be accessed using the key combination ~Ctrl-Alt-F8~. To get back from the status screen to the graphical interface, use ~Ctrl-Alt-F7~.

** Clearing kiosk browser cache

At times network issues may cause corrupted media resources to end up in the kiosk browser's cache. In this case it may be helpful to clear this cache to force all resources being downloaded again. A hard refresh can be triggered using ~Ctrl-Shift-R~, which clears the cache and then reloads the kiosk application. The hard refresh does not affect user sessions or preferences, so it can be performed without the user having to log in again.

** Wiping user data

Certain user data such as Play login credentials, wireless settings are stored persistently on the computer's disk.
Expand Down
25 changes: 23 additions & 2 deletions kiosk/kiosk_browser/browser_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from enum import Enum, auto
import logging
import re
import time

from kiosk_browser import system

Expand Down Expand Up @@ -59,8 +60,11 @@ def __init__(self, url, get_current_proxy, parent):
self._webview.loadFinished.connect(self._load_finished)

# Shortcut to manually reload
self.reload_shortcut = QtWidgets.QShortcut('CTRL+R', self)
self.reload_shortcut.activated.connect(self.reload)
self._reload_shortcut = QtWidgets.QShortcut('CTRL+R', self)
self._reload_shortcut.activated.connect(self.reload)
# Shortcut to perform a hard refresh
self._hard_refresh_shortcut = QtWidgets.QShortcut('CTRL+SHIFT+R', self)
self._hard_refresh_shortcut.activated.connect(self._hard_refresh)

# Prepare reload timer
self._reload_timer = QtCore.QTimer(self)
Expand Down Expand Up @@ -93,6 +97,23 @@ def _load_finished(self, success):
self._view(Status.NETWORK_ERROR)
self._reload_timer.start(reload_on_network_error_after)

def _hard_refresh(self):
""" Clear cache, then reload.
Does not affect cookies or localstorage contents.
NOTE This clears the entire HTTP cache, assumed to be OK as the kiosk targets a specific page.
"""
logging.info(f"Clearing HTTP cache (hard refresh)")
self._webview.page().profile().clearHttpCache()

# Sleep before triggering reload to avoid a possible race condition.
# Future Qt versions may provide a signal on `QWebEngineProfile` to
# allow to queue the reload on clear-cache completion instead.
# https://bugreports.qt.io/browse/QTBUG-111541
time.sleep(0.25)
self.reload()

def _proxy_auth(self, get_current_proxy, url, auth, proxyHost):
proxy = get_current_proxy()
if proxy is not None and proxy.credentials is not None:
Expand Down