Files
DBClient/main.py
T
2026-05-21 15:46:41 -04:00

58 lines
1.5 KiB
Python

"""
DBClient — entry point.
"""
import sys
import os
from PyQt6.QtWidgets import QApplication
from PyQt6.QtCore import Qt
from PyQt6.QtGui import QFont
from app.utils.logger import setup_logging, install_qt_message_handler, get_logger
from app.main_window import MainWindow
log = get_logger(__name__)
def load_stylesheet(app: QApplication) -> None:
style_path = os.path.join(os.path.dirname(__file__), "resources", "style.qss")
if os.path.exists(style_path):
with open(style_path, "r", encoding="utf-8") as f:
app.setStyleSheet(f.read())
def main():
# ── Logging must be set up before anything else ───────────────────────────
setup_logging()
# High DPI
os.environ.setdefault("QT_ENABLE_HIGHDPI_SCALING", "1")
app = QApplication(sys.argv)
app.setApplicationName("DBClient")
app.setApplicationDisplayName("DBClient")
app.setApplicationVersion("1.0.0")
app.setOrganizationName("DBClient")
# Route Qt's own warning/critical messages into the Python log
install_qt_message_handler()
# Default font
font = QFont("Segoe UI", 10)
app.setFont(font)
load_stylesheet(app)
log.info("Starting MainWindow")
window = MainWindow()
window.show()
log.info("Entering event loop")
exit_code = app.exec()
log.info("Application exited with code %d", exit_code)
sys.exit(exit_code)
if __name__ == "__main__":
main()