__init__.py 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. """
  2. UI module for BMAD Novel Translator.
  3. Provides the user interface components for the translation application.
  4. The module can be imported without PyQt6 for testing models only.
  5. """
  6. # Data models (no PyQt6 required)
  7. from .models import (
  8. FileItem,
  9. TranslationTask,
  10. FileStatus,
  11. TaskStatus,
  12. ProgressUpdate,
  13. Statistics,
  14. )
  15. # PyQt6-dependent imports (may fail if PyQt6 not installed)
  16. try:
  17. from .main_window import MainWindow
  18. from .file_list_model import FileListModel
  19. _pyqt6_available = True
  20. except ImportError:
  21. _pyqt6_available = False
  22. # Create placeholder for type checking
  23. MainWindow = None # type: ignore
  24. FileListModel = None # type: ignore
  25. # Core UI components (Epic 7b Phase 1)
  26. try:
  27. from .file_selector import FileSelector, FileListDialog
  28. except ImportError:
  29. FileSelector = None # type: ignore
  30. FileListDialog = None # type: ignore
  31. try:
  32. from .progress_widget import ProgressWidget, ChapterProgressItem
  33. except ImportError:
  34. ProgressWidget = None # type: ignore
  35. ChapterProgressItem = None # type: ignore
  36. # Phase 2 components (Epic 7b Phase 2 - Stories 7.10, 7.14, 7.16, 7.18, 7.20, 7.21, 7.24)
  37. try:
  38. from .translation_controller import (
  39. TranslationController,
  40. UIProgressObserver,
  41. TranslationWorker,
  42. )
  43. except ImportError:
  44. TranslationController = None # type: ignore
  45. UIProgressObserver = None # type: ignore
  46. TranslationWorker = None # type: ignore
  47. try:
  48. from .settings_dialog import SettingsDialog
  49. except ImportError:
  50. SettingsDialog = None # type: ignore
  51. try:
  52. from .error_dialog import ErrorDialog, ErrorReporter
  53. except ImportError:
  54. ErrorDialog = None # type: ignore
  55. ErrorReporter = None # type: ignore
  56. try:
  57. from .preview_dialog import (
  58. ImportPreviewDialog,
  59. ImportProgressDialog,
  60. BatchImportDialog,
  61. )
  62. except ImportError:
  63. ImportPreviewDialog = None # type: ignore
  64. ImportProgressDialog = None # type: ignore
  65. BatchImportDialog = None # type: ignore
  66. try:
  67. from .content_preview import (
  68. ContentPreviewWidget,
  69. ContentPreviewDialog,
  70. SynchronizedTextEdit,
  71. )
  72. except ImportError:
  73. ContentPreviewWidget = None # type: ignore
  74. ContentPreviewDialog = None # type: ignore
  75. SynchronizedTextEdit = None # type: ignore
  76. try:
  77. from .batch_operations import (
  78. BatchFileSelector,
  79. BatchOperationWorker,
  80. BatchOperationDialog,
  81. BatchOperationsManager,
  82. )
  83. except ImportError:
  84. BatchFileSelector = None # type: ignore
  85. BatchOperationWorker = None # type: ignore
  86. BatchOperationDialog = None # type: ignore
  87. BatchOperationsManager = None # type: ignore
  88. __all__ = [
  89. # Main window (PyQt6 required)
  90. "MainWindow",
  91. # Data models (no dependencies)
  92. "FileItem",
  93. "TranslationTask",
  94. "FileStatus",
  95. "TaskStatus",
  96. "ProgressUpdate",
  97. "Statistics",
  98. # Qt model (PyQt6 required)
  99. "FileListModel",
  100. # Core UI components (Phase 1)
  101. "FileSelector",
  102. "FileListDialog",
  103. "ProgressWidget",
  104. "ChapterProgressItem",
  105. # Translation control (Story 7.20)
  106. "TranslationController",
  107. "UIProgressObserver",
  108. "TranslationWorker",
  109. # Settings (Story 7.10)
  110. "SettingsDialog",
  111. # Error handling (Story 7.16)
  112. "ErrorDialog",
  113. "ErrorReporter",
  114. # Import preview (Story 7.24)
  115. "ImportPreviewDialog",
  116. "ImportProgressDialog",
  117. "BatchImportDialog",
  118. # Content preview (Story 7.18)
  119. "ContentPreviewWidget",
  120. "ContentPreviewDialog",
  121. "SynchronizedTextEdit",
  122. # Batch operations (Story 7.21)
  123. "BatchFileSelector",
  124. "BatchOperationWorker",
  125. "BatchOperationDialog",
  126. "BatchOperationsManager",
  127. ]
  128. def is_pyqt6_available() -> bool:
  129. """Check if PyQt6 is available."""
  130. return _pyqt6_available