feat: enhance web engine view with profile isolation and add cache clearing functionality
Some checks failed
Tests & Quality Checks / Test on Python 3.11 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.12 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.11-1 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.12-1 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.10 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.11-2 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.12-2 (push) Has been cancelled
Tests & Quality Checks / Build Artifacts (push) Has been cancelled
Tests & Quality Checks / Build Artifacts-1 (push) Has been cancelled
Some checks failed
Tests & Quality Checks / Test on Python 3.11 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.12 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.11-1 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.12-1 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.10 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.11-2 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.12-2 (push) Has been cancelled
Tests & Quality Checks / Build Artifacts (push) Has been cancelled
Tests & Quality Checks / Build Artifacts-1 (push) Has been cancelled
This commit is contained in:
parent
ba0594c260
commit
705969cdba
5 changed files with 136 additions and 50 deletions
|
|
@ -394,8 +394,10 @@ class MainWindow(QMainWindow):
|
|||
else:
|
||||
logger.warning(f"Window icon not found at {icon_path}")
|
||||
|
||||
# Create web engine view
|
||||
self.web_view = RestrictedWebEngineView(config.allowed_urls)
|
||||
# Create web engine view with URL for profile isolation
|
||||
self.web_view = RestrictedWebEngineView(
|
||||
allowed_urls=config.allowed_urls, webapp_url=config.webapp_url
|
||||
)
|
||||
|
||||
# Enable the main window and web view to receive drag events
|
||||
self.setAcceptDrops(True)
|
||||
|
|
@ -1249,6 +1251,11 @@ class MainWindow(QMainWindow):
|
|||
check_updates_action.setToolTip("Check for Updates")
|
||||
check_updates_action.triggered.connect(self._on_manual_check_for_updates)
|
||||
|
||||
# Clear cache button on the right
|
||||
clear_cache_action = toolbar.addAction("🗑️")
|
||||
clear_cache_action.setToolTip("Clear Cache and Cookies")
|
||||
clear_cache_action.triggered.connect(self._clear_cache_and_cookies)
|
||||
|
||||
# Log file button on the right
|
||||
log_action = toolbar.addAction("📋")
|
||||
log_action.setToolTip("Open Log File")
|
||||
|
|
@ -1321,6 +1328,34 @@ class MainWindow(QMainWindow):
|
|||
# Show the dialog
|
||||
self.checking_dialog.show()
|
||||
|
||||
def _clear_cache_and_cookies(self) -> None:
|
||||
"""Clear web view cache and cookies.
|
||||
|
||||
Useful for clearing authentication tokens or cached data from previous
|
||||
sessions. Also disconnects and reconnects the page to ensure clean state.
|
||||
"""
|
||||
logger.info("Clearing cache and cookies")
|
||||
|
||||
try:
|
||||
# Clear cache and cookies in the web view profile
|
||||
self.web_view.clear_cache_and_cookies()
|
||||
|
||||
# Show confirmation message
|
||||
QMessageBox.information(
|
||||
self,
|
||||
"Cache Cleared",
|
||||
"Browser cache and cookies have been cleared successfully.\n\n"
|
||||
"You may need to reload the page or restart the application for changes to take effect.",
|
||||
)
|
||||
logger.info("Cache and cookies cleared successfully")
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to clear cache and cookies: {e}")
|
||||
QMessageBox.warning(
|
||||
self,
|
||||
"Error",
|
||||
f"Failed to clear cache and cookies: {str(e)}",
|
||||
)
|
||||
|
||||
def _show_about_dialog(self) -> None:
|
||||
"""Show About dialog with version and information."""
|
||||
from PySide6.QtWidgets import QMessageBox
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue