feat: add Fortran support and tab controls

This commit is contained in:
shenw
2026-06-22 18:07:34 +08:00
parent 2f480e7c8f
commit 4113236128
10 changed files with 301 additions and 41 deletions
+44 -4
View File
@@ -57,6 +57,29 @@ def main() -> int:
empty_window.set_project_root(project_root, save=False)
if not empty_window.has_project or empty_window.project_root != project_root.resolve() or not empty_window.entries:
checks.append("set_project_root")
switch_root = project_root / "__gui_smoke_switch_root__"
try:
switch_root.mkdir(exist_ok=True)
(switch_root / "first.md").write_text("# First\n", encoding="utf-8")
empty_window.open_document(project_root / "sample.md", add_history=False)
if not empty_window.set_project_root(switch_root, save=False):
checks.append("switch_project_root")
if empty_window.current_file is not None:
checks.append("switch_project_clears_current_file")
if empty_window.tabs.count() != 1 or not bool(empty_window.tabs.currentWidget().property("is_welcome")):
checks.append("switch_project_closes_tabs")
(switch_root / "second.md").write_text("# Second\n", encoding="utf-8")
empty_window._poll_directory_changes()
if not any(entry.path == (switch_root / "second.md").resolve() for entry in empty_window.entries):
checks.append("directory_poll_refresh")
finally:
for cleanup_path in (switch_root / "first.md", switch_root / "second.md"):
cleanup_path.unlink(missing_ok=True)
try:
switch_root.rmdir()
except OSError:
pass
empty_window.set_project_root(project_root, save=False)
supported_suffixes = {".md", ".markdown", ".html", ".htm", ".xhtml"}
if any(entry.path.suffix.lower() not in supported_suffixes for entry in empty_window.entries):
checks.append("project_supported_files_only")
@@ -65,9 +88,9 @@ def main() -> int:
if any(entry.path == (project_root / "requirements.txt").resolve() for entry in empty_window.entries):
checks.append("project_hidden_unsupported_files")
original_file_groups = empty_window.document_file_groups
empty_window.document_file_groups = ("markdown", "python", "cpp")
empty_window.document_file_groups = ("markdown", "python", "cpp", "fortran")
empty_window._refresh_document_entries(force=True)
code_suffixes = {".py", ".c", ".cc", ".cxx", ".cpp", ".h", ".hh", ".hxx", ".hpp"}
code_suffixes = {".py", ".c", ".cc", ".cxx", ".cpp", ".h", ".hh", ".hxx", ".hpp", ".f", ".for", ".f90", ".f95"}
if not any(entry.path.suffix.lower() in code_suffixes for entry in empty_window.entries):
checks.append("project_optional_code_files")
empty_window.open_document(project_root / "sample.md", add_history=False)
@@ -162,8 +185,24 @@ def main() -> int:
checks.append("tabs_non_expanding")
if hasattr(tab_bar, "changeCurrentOnDrag") and tab_bar.changeCurrentOnDrag():
checks.append("tabs_no_drag_switch")
if tab_bar.contextMenuPolicy() != Qt.ContextMenuPolicy.CustomContextMenu:
checks.append("tabs_context_menu_policy")
if window._welcome_tab_index() >= 0:
checks.append("welcome_closed_for_document")
window.open_document(project_root / "docs" / "user_manual.md", new_tab=True, add_history=False)
user_manual_index = window.tabs.currentIndex()
if sum(1 for index in range(window.tabs.count()) if window._is_content_tab_index(index)) < 2:
checks.append("tab_context_multiple_tabs")
if not window._close_other_tabs(user_manual_index):
checks.append("tab_context_close_others")
if window.tabs.count() != 1 or window.current_file != (project_root / "docs" / "user_manual.md").resolve():
checks.append("tab_context_close_others_result")
window.open_document(project_root / "sample.md", new_tab=True, add_history=False)
if not window._close_tab_indexes(list(range(window.tabs.count()))):
checks.append("tab_context_close_all")
if window.tabs.count() != 1 or not bool(window.tabs.currentWidget().property("is_welcome")):
checks.append("tab_context_close_all_result")
window.open_document(project_root / "sample.md", add_history=False)
if window.windowIcon().isNull():
checks.append("window_icon")
if app.windowIcon().isNull():
@@ -240,12 +279,15 @@ def main() -> int:
)
if abs(settings_dialog.wheel_scroll_speed_spin.value() - 1.4) > 0.01:
checks.append("settings_wheel_scroll_speed")
settings_dialog.fortran_files_check.setChecked(True)
settings_dialog.wheel_scroll_speed_spin.setValue(2.2)
prefs = settings_dialog.preferences()
if abs(prefs.wheel_scroll_speed - 2.2) > 0.01:
checks.append("settings_wheel_scroll_speed_value")
if abs(prefs.reader_width_scale - 1.5) > 0.01:
checks.append("settings_reader_width_scale")
if "fortran" not in prefs.document_file_groups:
checks.append("settings_fortran_file_group")
if not prefs.reader_embedded_toc or prefs.reader_external_toc or not prefs.reader_embedded_progress:
checks.append("settings_reader_navigation")
external_settings_dialog = SettingsDialog(
@@ -948,5 +990,3 @@ def main() -> int:
if __name__ == "__main__":
raise SystemExit(main())