MetaCore-startup/MetaCore/main.py
2025-10-11 09:27:51 +08:00

68 lines
1.7 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
MetaCore - 项目管理平台 (PyQt5版本)
"""
import sys
import json
import os
from datetime import datetime
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
# 导入自定义组件
from MetaCore.ui.main_window import MainWindow
from MetaCore.ui.styles import StyleSheet
from MetaCore.data.project_manager import ProjectManager
class MetaCoreApp(QApplication):
"""MetaCore应用程序主类"""
def __init__(self, argv):
super().__init__(argv)
# 设置应用程序信息
self.setApplicationName("MetaCore")
self.setApplicationVersion("1.0.0")
self.setOrganizationName("MetaCore Team")
# 设置应用程序图标(如果图标文件存在)
icon_path = "resources/icons/app_icon.png"
if os.path.exists(icon_path):
self.setWindowIcon(QIcon(icon_path))
# 初始化数据管理器
self.project_manager = ProjectManager()
# 创建主窗口
self.main_window = MainWindow(self.project_manager)
# 应用样式表
self.setStyleSheet(StyleSheet.get_main_style())
# 显示主窗口
self.main_window.show()
def closeEvent(self, event):
"""应用程序关闭事件"""
# 保存项目数据
self.project_manager.save_projects()
event.accept()
def main():
"""主函数"""
app = MetaCoreApp(sys.argv)
# 设置高DPI支持
app.setAttribute(Qt.AA_EnableHighDpiScaling, True)
app.setAttribute(Qt.AA_UseHighDpiPixmaps, True)
# 运行应用程序
sys.exit(app.exec_())
if __name__ == "__main__":
main()