fix: prevent More menu arrow overlapping its label
This commit is contained in:
1 parent
da9d1dc25f
commit
b51bcb0b3e
6 files changed
+80
-2
No files matched your search
@@ -71,7 +71,9 @@ def test_drag_only_handle_moves_toolbar_and_panel_without_switching(qtbot, monke
|
||||
):
|
||||
event = QMouseEvent(kind, local, global_pos, button, buttons, Qt.KeyboardModifier.NoModifier)
|
||||
QCoreApplication.sendEvent(handle, event)
|
||||
assert floating.pos() == QPoint(20, 60)
|
||||
# A wider menu button can reach the edge of the offscreen test monitor.
|
||||
bounds = floating.screen().availableGeometry()
|
||||
assert floating.pos() == QPoint(min(20, bounds.right() - floating.width() + 1), 60)
|
||||
assert window.pos().y() == panel_position.y() + 20
|
||||
assert window.pages.currentIndex() == 0
|
||||
|
||||
@@ -112,6 +114,7 @@ def test_page_size_and_toolbar_position_restore_without_overwriting_settings(qtb
|
||||
window.show_panel(0)
|
||||
assert window.size().width() == 750 and window.size().height() == 470
|
||||
window.toolbar.move_within_screen(QPoint(20, 50))
|
||||
saved_position = window.toolbar.pos()
|
||||
path = window.layout_preferences.path
|
||||
window.request_exit()
|
||||
from dx_productivity.ui.main_window import MainWindow
|
||||
@@ -119,7 +122,7 @@ def test_page_size_and_toolbar_position_restore_without_overwriting_settings(qtb
|
||||
qtbot.addWidget(restored)
|
||||
restored.show_panel(7)
|
||||
assert restored.size().width() == 700 and restored.size().height() == 410
|
||||
assert restored.toolbar.pos() == QPoint(20, 50)
|
||||
assert restored.toolbar.pos() == saved_position
|
||||
|
||||
|
||||
def test_menu_registration_blocks_exit_but_not_panel_hide(qtbot, monkeypatch, tmp_path):
|
||||
|
||||
@@ -75,6 +75,38 @@ def test_expanded_panel_is_a_frameless_tool_card(qtbot):
|
||||
assert window.centralWidget().objectName() == 'appRoot'
|
||||
|
||||
|
||||
def test_more_button_reserves_room_for_text_and_arrow_in_both_themes(qtbot, qapp, tmp_path):
|
||||
from PySide6.QtWidgets import QStyle
|
||||
from dx_productivity.ui.app import create_application
|
||||
from dx_productivity.ui.theme import Theme, apply_theme
|
||||
|
||||
create_application([])
|
||||
window = MainWindow(layout_path=tmp_path / 'layout.json')
|
||||
qtbot.addWidget(window)
|
||||
window.show_toolbar()
|
||||
toolbar = window.toolbar
|
||||
button = toolbar.more_button
|
||||
for theme in (Theme.LIGHT, Theme.DARK):
|
||||
apply_theme(qapp, theme)
|
||||
toolbar.refresh_theme(theme)
|
||||
toolbar.fit_available_width(1100)
|
||||
qapp.processEvents()
|
||||
text_width = button.fontMetrics().horizontalAdvance('更多')
|
||||
arrow_width = button.style().pixelMetric(QStyle.PixelMetric.PM_MenuButtonIndicator)
|
||||
assert button.width() >= text_width + arrow_width + 14
|
||||
assert button.text() == '更多'
|
||||
assert toolbar.rect().contains(button.geometry())
|
||||
|
||||
toolbar.fit_available_width(96)
|
||||
qapp.processEvents()
|
||||
assert toolbar.rect().contains(button.geometry())
|
||||
assert button.menu() is toolbar.more_menu
|
||||
toolbar.fit_available_width(1100)
|
||||
qapp.processEvents()
|
||||
assert button.text() == '更多'
|
||||
assert button.width() >= text_width + arrow_width + 14
|
||||
|
||||
|
||||
def test_passive_status_keeps_host_focus_and_tracks_background_task(qtbot, qapp, tmp_path, monkeypatch):
|
||||
from types import SimpleNamespace
|
||||
from PySide6.QtWidgets import QWidget
|
||||
|
||||
Reference in new issue
Block a user