47 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
import asyncio
 | 
						|
from PySide6.QtWidgets import QApplication, QMainWindow
 | 
						|
from PySide6.QtGui import QIcon
 | 
						|
from app.controllers.main_controller import MainController
 | 
						|
from app.core.theme import theme_manager
 | 
						|
import app.core.config as config
 | 
						|
import sys
 | 
						|
import qasync
 | 
						|
from app.core.database import init_db
 | 
						|
 | 
						|
class MainWindow(QMainWindow):
 | 
						|
    def __init__(self):
 | 
						|
        super().__init__()
 | 
						|
        self.setWindowTitle(config.APP_HEADER)
 | 
						|
        self.setMinimumSize(400, 650)
 | 
						|
        
 | 
						|
        self.controller = MainController()
 | 
						|
        self.setCentralWidget(self.controller)
 | 
						|
        
 | 
						|
        theme_manager.theme_changed.connect(self.apply_theme)
 | 
						|
        self.apply_theme(theme_manager.get_theme())
 | 
						|
 | 
						|
    def apply_theme(self, theme):
 | 
						|
        if theme == "dark":
 | 
						|
            self.setStyleSheet("background-color: #2e2e2e;")
 | 
						|
        else:
 | 
						|
            self.setStyleSheet("background-color: #f0f0f0;")
 | 
						|
 | 
						|
async def main():
 | 
						|
    init_db()
 | 
						|
    app = QApplication(sys.argv)
 | 
						|
    app.setWindowIcon(QIcon("app/icons/logo3.png"))
 | 
						|
    
 | 
						|
    loop = qasync.QEventLoop(app)
 | 
						|
    asyncio.set_event_loop(loop)
 | 
						|
 | 
						|
    window = MainWindow()
 | 
						|
    window.show()
 | 
						|
    
 | 
						|
    await loop.run_forever()
 | 
						|
 | 
						|
if __name__ == "__main__":
 | 
						|
    try:
 | 
						|
        asyncio.run(main())
 | 
						|
    except KeyboardInterrupt:
 | 
						|
        sys.exit(0)
 |