feat: Add branding change prompts and corresponding translations for restart notifications
This commit is contained in:
parent
ca7105a6bc
commit
2ecd299f31
5 changed files with 79 additions and 15 deletions
|
|
@ -1958,6 +1958,7 @@ class MainWindow(QMainWindow):
|
|||
# Store current URL before opening dialog
|
||||
old_webapp_url = self.config.webapp_url
|
||||
old_language = self.config.language
|
||||
old_branding_id = self.config.active_branding_id
|
||||
|
||||
# Show dialog
|
||||
dialog = SettingsDialog(self.config, self)
|
||||
|
|
@ -1966,6 +1967,9 @@ class MainWindow(QMainWindow):
|
|||
# Check if webapp URL changed
|
||||
new_webapp_url = self.config.webapp_url
|
||||
language_changed = old_language != self.config.language
|
||||
branding_changed = old_branding_id != self.config.active_branding_id
|
||||
restart_prompt_shown = False
|
||||
|
||||
if old_webapp_url != new_webapp_url:
|
||||
logger.info(f"Web application URL changed: {old_webapp_url} → {new_webapp_url}")
|
||||
|
||||
|
|
@ -1975,6 +1979,7 @@ class MainWindow(QMainWindow):
|
|||
if domain_changed:
|
||||
logger.warning("Domain has changed - recommending restart")
|
||||
self._handle_domain_change_restart()
|
||||
restart_prompt_shown = True
|
||||
else:
|
||||
logger.info("Path changed but domain is same - reloading...")
|
||||
# Clear cache and navigate to home asynchronously
|
||||
|
|
@ -1982,7 +1987,16 @@ class MainWindow(QMainWindow):
|
|||
self.web_view.clear_cache_and_cookies()
|
||||
QTimer.singleShot(100, self._navigate_home)
|
||||
|
||||
if language_changed:
|
||||
if not restart_prompt_shown and branding_changed:
|
||||
logger.info(
|
||||
"Branding changed: %s → %s",
|
||||
old_branding_id,
|
||||
self.config.active_branding_id,
|
||||
)
|
||||
self._handle_branding_change_restart()
|
||||
restart_prompt_shown = True
|
||||
|
||||
if not restart_prompt_shown and language_changed:
|
||||
logger.info(f"Language changed: {old_language} → {self.config.language}")
|
||||
self._handle_language_change_restart()
|
||||
|
||||
|
|
@ -2046,21 +2060,42 @@ class MainWindow(QMainWindow):
|
|||
self.web_view.clear_cache_and_cookies()
|
||||
self._navigate_home()
|
||||
|
||||
def _handle_branding_change_restart(self) -> None:
|
||||
"""Handle branding change by prompting for an optional restart."""
|
||||
self._show_restart_prompt(
|
||||
title_key="dialog.branding_changed.title",
|
||||
message_key="dialog.branding_changed.msg",
|
||||
restart_now_key="dialog.branding_changed.restart_now",
|
||||
restart_later_key="dialog.branding_changed.restart_later",
|
||||
)
|
||||
|
||||
def _handle_language_change_restart(self) -> None:
|
||||
"""Handle language change by prompting for an optional restart."""
|
||||
self._show_restart_prompt(
|
||||
title_key="dialog.language_changed.title",
|
||||
message_key="dialog.language_changed.msg",
|
||||
restart_now_key="dialog.language_changed.restart_now",
|
||||
restart_later_key="dialog.language_changed.restart_later",
|
||||
)
|
||||
|
||||
def _show_restart_prompt(
|
||||
self,
|
||||
*,
|
||||
title_key: str,
|
||||
message_key: str,
|
||||
restart_now_key: str,
|
||||
restart_later_key: str,
|
||||
) -> None:
|
||||
"""Show a restart prompt for settings that require a full restart."""
|
||||
from PySide6.QtWidgets import QMessageBox
|
||||
|
||||
msg = QMessageBox(self)
|
||||
msg.setWindowTitle(tr("dialog.language_changed.title"))
|
||||
msg.setWindowTitle(tr(title_key))
|
||||
msg.setIcon(QMessageBox.Icon.Information)
|
||||
msg.setText(tr("dialog.language_changed.msg"))
|
||||
msg.setText(tr(message_key))
|
||||
|
||||
restart_now_btn = msg.addButton(
|
||||
tr("dialog.language_changed.restart_now"), QMessageBox.ButtonRole.AcceptRole
|
||||
)
|
||||
msg.addButton(
|
||||
tr("dialog.language_changed.restart_later"), QMessageBox.ButtonRole.RejectRole
|
||||
)
|
||||
restart_now_btn = msg.addButton(tr(restart_now_key), QMessageBox.ButtonRole.AcceptRole)
|
||||
msg.addButton(tr(restart_later_key), QMessageBox.ButtonRole.RejectRole)
|
||||
|
||||
msg.exec()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue