feat: Enhance navigation toolbar with help actions and update related tests

This commit is contained in:
claudi 2026-01-30 11:22:33 +01:00
parent a355c13c82
commit c621e63a8d
2 changed files with 35 additions and 26 deletions

View file

@ -6,9 +6,20 @@ from pathlib import Path
from typing import Optional from typing import Optional
from PySide6.QtCore import QObject, QPoint, QSize, Qt, QThread, QTimer, QUrl, Signal, Slot from PySide6.QtCore import QObject, QPoint, QSize, Qt, QThread, QTimer, QUrl, Signal, Slot
from PySide6.QtGui import QIcon
from PySide6.QtWebChannel import QWebChannel from PySide6.QtWebChannel import QWebChannel
from PySide6.QtWebEngineCore import QWebEngineScript from PySide6.QtWebEngineCore import QWebEngineScript
from PySide6.QtWidgets import QLabel, QMainWindow, QStatusBar, QToolBar, QVBoxLayout, QWidget from PySide6.QtWidgets import (
QLabel,
QMainWindow,
QSizePolicy,
QSpacerItem,
QStatusBar,
QToolBar,
QVBoxLayout,
QWidget,
QWidgetAction,
)
from webdrop_bridge.config import Config from webdrop_bridge.config import Config
from webdrop_bridge.core.drag_interceptor import DragInterceptor from webdrop_bridge.core.drag_interceptor import DragInterceptor
@ -248,9 +259,6 @@ class MainWindow(QMainWindow):
# Create navigation toolbar (Kiosk-mode navigation) # Create navigation toolbar (Kiosk-mode navigation)
self._create_navigation_toolbar() self._create_navigation_toolbar()
# Create menu bar
self._create_menu_bar()
# Create status bar # Create status bar
self._create_status_bar() self._create_status_bar()
@ -411,6 +419,7 @@ class MainWindow(QMainWindow):
"""Create navigation toolbar with Home, Back, Forward, Refresh buttons. """Create navigation toolbar with Home, Back, Forward, Refresh buttons.
In Kiosk-mode, users can navigate history but cannot freely browse. In Kiosk-mode, users can navigate history but cannot freely browse.
Help actions are positioned on the right side of the toolbar.
""" """
toolbar = QToolBar("Navigation") toolbar = QToolBar("Navigation")
toolbar.setMovable(False) toolbar.setMovable(False)
@ -433,7 +442,8 @@ class MainWindow(QMainWindow):
toolbar.addSeparator() toolbar.addSeparator()
# Home button # Home button
home_action = toolbar.addAction("Home") home_action = toolbar.addAction(self.style().standardIcon(self.style().StandardPixmap.SP_DirHomeIcon), "")
home_action.setToolTip("Home")
home_action.triggered.connect(self._navigate_home) home_action.triggered.connect(self._navigate_home)
# Refresh button # Refresh button
@ -442,24 +452,21 @@ class MainWindow(QMainWindow):
) )
toolbar.addAction(refresh_action) toolbar.addAction(refresh_action)
def _create_menu_bar(self) -> None: # Add stretch spacer to push help buttons to the right
"""Create menu bar with Help menu and update check action.""" spacer = QWidget()
menu_bar = self.menuBar() spacer.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum)
toolbar.addWidget(spacer)
# Help menu
help_menu = menu_bar.addMenu("Help") # About button (info icon) on the right
about_action = toolbar.addAction("")
# Check for Updates action about_action.setToolTip("About WebDrop Bridge")
check_updates_action = help_menu.addAction("Check for Updates...")
check_updates_action.triggered.connect(self._on_manual_check_for_updates)
# Separator
help_menu.addSeparator()
# About action
about_action = help_menu.addAction("About WebDrop Bridge...")
about_action.triggered.connect(self._show_about_dialog) about_action.triggered.connect(self._show_about_dialog)
# Check for Updates button on the right
check_updates_action = toolbar.addAction("🔄")
check_updates_action.setToolTip("Check for Updates")
check_updates_action.triggered.connect(self._on_manual_check_for_updates)
def _create_status_bar(self) -> None: def _create_status_bar(self) -> None:
"""Create status bar with update status indicator.""" """Create status bar with update status indicator."""
self.status_bar = self.statusBar() self.status_bar = self.statusBar()

View file

@ -324,15 +324,17 @@ class TestMainWindowSignals:
class TestMainWindowMenuBar: class TestMainWindowMenuBar:
"""Test menu bar and menu actions.""" """Test toolbar help actions integration."""
def test_menu_bar_created(self, qtbot, sample_config): def test_navigation_toolbar_created(self, qtbot, sample_config):
"""Test menu bar is created.""" """Test navigation toolbar is created with help buttons."""
window = MainWindow(sample_config) window = MainWindow(sample_config)
qtbot.addWidget(window) qtbot.addWidget(window)
menu_bar = window.menuBar() # Check that toolbar exists
assert menu_bar is not None assert len(window.findChildren(QToolBar)) > 0
toolbar = window.findChildren(QToolBar)[0]
assert toolbar is not None
def test_window_has_check_for_updates_signal(self, qtbot, sample_config): def test_window_has_check_for_updates_signal(self, qtbot, sample_config):
"""Test window has check_for_updates signal.""" """Test window has check_for_updates signal."""