From c621e63a8dfbcedece2e03557cf8c27b83ab1a61 Mon Sep 17 00:00:00 2001 From: claudi Date: Fri, 30 Jan 2026 11:22:33 +0100 Subject: [PATCH] feat: Enhance navigation toolbar with help actions and update related tests --- src/webdrop_bridge/ui/main_window.py | 49 ++++++++++++++++------------ tests/unit/test_main_window.py | 12 ++++--- 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/src/webdrop_bridge/ui/main_window.py b/src/webdrop_bridge/ui/main_window.py index 1bfcbcc..1d977e4 100644 --- a/src/webdrop_bridge/ui/main_window.py +++ b/src/webdrop_bridge/ui/main_window.py @@ -6,9 +6,20 @@ from pathlib import Path from typing import Optional 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.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.core.drag_interceptor import DragInterceptor @@ -248,9 +259,6 @@ class MainWindow(QMainWindow): # Create navigation toolbar (Kiosk-mode navigation) self._create_navigation_toolbar() - # Create menu bar - self._create_menu_bar() - # Create status bar self._create_status_bar() @@ -411,6 +419,7 @@ class MainWindow(QMainWindow): """Create navigation toolbar with Home, Back, Forward, Refresh buttons. 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.setMovable(False) @@ -433,7 +442,8 @@ class MainWindow(QMainWindow): toolbar.addSeparator() # 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) # Refresh button @@ -442,24 +452,21 @@ class MainWindow(QMainWindow): ) toolbar.addAction(refresh_action) - def _create_menu_bar(self) -> None: - """Create menu bar with Help menu and update check action.""" - menu_bar = self.menuBar() - - # Help menu - help_menu = menu_bar.addMenu("Help") - - # Check for Updates action - 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...") + # Add stretch spacer to push help buttons to the right + spacer = QWidget() + spacer.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum) + toolbar.addWidget(spacer) + + # About button (info icon) on the right + about_action = toolbar.addAction("â„šī¸") + about_action.setToolTip("About WebDrop Bridge") 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: """Create status bar with update status indicator.""" self.status_bar = self.statusBar() diff --git a/tests/unit/test_main_window.py b/tests/unit/test_main_window.py index d7f7321..b38057e 100644 --- a/tests/unit/test_main_window.py +++ b/tests/unit/test_main_window.py @@ -324,15 +324,17 @@ class TestMainWindowSignals: class TestMainWindowMenuBar: - """Test menu bar and menu actions.""" + """Test toolbar help actions integration.""" - def test_menu_bar_created(self, qtbot, sample_config): - """Test menu bar is created.""" + def test_navigation_toolbar_created(self, qtbot, sample_config): + """Test navigation toolbar is created with help buttons.""" window = MainWindow(sample_config) qtbot.addWidget(window) - menu_bar = window.menuBar() - assert menu_bar is not None + # Check that toolbar exists + 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): """Test window has check_for_updates signal."""