Replace leaf entry with persistent horizontal toolbar and shared panel state

This commit is contained in:
阿白叔 committed 2026-10-11 11:31:07 +08:00
1 parent d2501d0112
commit 19361fd1cc
18 files changed
+1010 -454

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
import json
from PySide6.QtCore import QPoint, QSize
from dx_productivity.ui.layout_preferences import LayoutPreferences
def test_layout_preferences_validate_types_and_recover_from_corruption(tmp_path):
path = tmp_path / 'ui-layout.json'
path.write_text('{broken', encoding='utf-8')
assert LayoutPreferences(path).position is None
path.write_text(json.dumps({'toolbar_position': [True, 40], 'page_sizes': {'0': [720, '420'], '7': [660, 380], '999': [900, 600]}, 'screen': 123}), encoding='utf-8')
preferences = LayoutPreferences(path)
assert preferences.position is None
assert preferences.screen_name == ''
assert preferences.page_sizes == {7: QSize(660, 380)}
def test_layout_preferences_round_trip_negative_monitor_position_and_atomic_write(tmp_path):
path = tmp_path / 'DxProductivity' / 'ui-layout.json'
settings = tmp_path / 'DxProductivity' / 'settings.json'
settings.parent.mkdir()
settings.write_text('{"channel":"stable"}', encoding='utf-8')
preferences = LayoutPreferences(path)
preferences.position = QPoint(-1200, 80)
preferences.screen_name = 'Second monitor'
preferences.page_sizes[0] = QSize(780, 490)
preferences.save()
fresh = LayoutPreferences(path)
assert fresh.position == QPoint(-1200, 80)
assert fresh.page_sizes[0] == QSize(780, 490)
assert fresh.screen_name == 'Second monitor'
assert settings.read_text(encoding='utf-8') == '{"channel":"stable"}'
assert not tuple(path.parent.glob('*.tmp'))