fix: keep settings actions visible while expanded options scroll

This commit is contained in:
阿白叔 committed 2026-10-11 11:54:04 +08:00
1 parent 5e0ba81c3e
commit f00dee7791
2 files changed
+70 -5

No files matched your search

+52
View File
@@ -2,6 +2,7 @@ from datetime import datetime, timezone
from pathlib import Path
import pytest
from PySide6.QtCore import QPoint, QRect, Qt
from PySide6.QtWidgets import QHeaderView, QLabel
from dx_productivity.domain.models import HistoryEntry
@@ -87,6 +88,57 @@ def test_settings_options_and_release_notes_fold_without_losing_check_values(qtb
assert page.release_notes_view.toPlainText() == "版本说明内容"
def test_settings_expanded_sections_scroll_without_overlap_in_minimum_main_window(
qtbot, qapp, monkeypatch, tmp_path
):
from dx_productivity.ui.app import FEATURE_PAGE_INDEX, create_main_window
from dx_productivity.ui.theme import Theme, apply_theme
monkeypatch.setenv("LOCALAPPDATA", str(tmp_path))
original_style = qapp.styleSheet()
try:
apply_theme(qapp, Theme.LIGHT)
window = create_main_window()
qtbot.addWidget(window)
window.show_panel(FEATURE_PAGE_INDEX["settings"])
page = window.settings_page
page.advanced_section.set_expanded(True)
page.notes_section.set_expanded(True)
page.release_notes_view.setPlainText("版本说明\n" * 30)
window.resize(660, 340)
qapp.processEvents()
qapp.processEvents()
assert (window.width(), window.height()) == (660, 340)
def rect_in(widget, parent):
return QRect(widget.mapTo(parent, QPoint()), widget.size())
source_rect = rect_in(page.source_input, page)
channel_rect = rect_in(page.channel_combo, page)
assert source_rect.bottom() < channel_rect.top()
for control in (page.check_button, page.install_button, page.version_label, page.status_label):
rect = rect_in(control, page)
assert page.rect().contains(rect)
assert not channel_rect.intersects(rect)
assert window.rect().contains(rect_in(control, window))
scroll = page.parameters_scroll
assert scroll.widgetResizable()
assert scroll.horizontalScrollBarPolicy() == Qt.ScrollBarPolicy.ScrollBarAlwaysOff
assert scroll.verticalScrollBar().maximum() > 0
assert scroll.widget().isAncestorOf(page.source_input)
assert scroll.widget().isAncestorOf(page.release_notes_view)
assert not scroll.widget().isAncestorOf(page.check_button)
assert rect_in(page.release_notes_view, scroll.widget()).bottom() <= scroll.widget().height()
scroll.verticalScrollBar().setValue(scroll.verticalScrollBar().maximum())
qapp.processEvents()
assert scroll.viewport().rect().intersects(rect_in(page.release_notes_view, scroll.viewport()))
assert page.release_notes_view.toPlainText() == "版本说明\n" * 30
assert page.rect().contains(rect_in(page.check_button, page))
finally:
qapp.setStyleSheet(original_style)
def test_history_backup_path_is_accessible_in_folded_details_and_tooltips(qtbot):
page = HistoryPage()
qtbot.addWidget(page)