Initial commit
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
# main.py
|
||||
import sys
|
||||
import os
|
||||
from pathlib import Path
|
||||
from PyQt6.QtWidgets import QApplication
|
||||
|
||||
# Явное добавление текущей директории в пути поиска модулей Python
|
||||
project_root = os.path.dirname(os.path.abspath(__file__))
|
||||
if project_root not in sys.path:
|
||||
sys.path.insert(0, project_root)
|
||||
|
||||
from database.db_manager import DBManager
|
||||
from watcher.fs_watcher import FolderWatcher
|
||||
from ui.main_window import MainWindow
|
||||
from utils.settings import load_settings
|
||||
|
||||
def main():
|
||||
db_path = "comfygallery.db"
|
||||
|
||||
# 1. Инициализация БД
|
||||
db_manager = DBManager(db_path)
|
||||
|
||||
# 2. Загрузка конфигурационного файла (JSON)
|
||||
settings = load_settings()
|
||||
tracked_paths = settings.get("tracked_paths", [])
|
||||
|
||||
# Гарантируем, что папки существуют
|
||||
for path_str in tracked_paths:
|
||||
Path(path_str).mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# 3. Инициализация и запуск фонового вотчера
|
||||
watcher = FolderWatcher(db_manager)
|
||||
watcher.start_monitoring(tracked_paths)
|
||||
|
||||
# 4. Запуск GUI приложения
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
window = MainWindow(db_manager, watcher)
|
||||
|
||||
# Загружаем список путей в дерево
|
||||
if tracked_paths:
|
||||
window.left_panel.set_tracked_folders(tracked_paths)
|
||||
window.left_panel.set_root_path(tracked_paths[0])
|
||||
window.load_folder_images(tracked_paths[0])
|
||||
|
||||
window.show()
|
||||
|
||||
try:
|
||||
sys.exit(app.exec())
|
||||
finally:
|
||||
# Корректное завершение фоновых потоков при выходе из приложения
|
||||
watcher.stop_monitoring()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user