MetaCore-startup/MetaCore/main.py

69 lines
1.8 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/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 ui.main_window import MainWindow
from ui.styles import StyleSheet
from 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():
"""主函数"""
# 设置高DPI支持必须在创建 QApplication 之前设置)
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps, True)
# 创建应用程序
app = MetaCoreApp(sys.argv)
# 运行应用程序
sys.exit(app.exec_())
if __name__ == "__main__":
main()