66 lines
2.0 KiB
Python
66 lines
2.0 KiB
Python
"""
|
|
pyside6-rcc resources.qrc -o resources.py
|
|
|
|
"""
|
|
import sys
|
|
import platform
|
|
import logging
|
|
from PySide6.QtWidgets import QApplication
|
|
from PySide6.QtCore import QSettings
|
|
from PySide6.QtGui import QIcon, QPalette
|
|
|
|
from fixtracks import fixtracks, info
|
|
|
|
logging.basicConfig(level=logging.DEBUG, force=True)
|
|
|
|
|
|
def is_dark_mode(app: QApplication) -> bool:
|
|
palette = app.palette()
|
|
# Check the brightness of the window text and base colors
|
|
text_color = palette.color(QPalette.ColorRole.WindowText)
|
|
base_color = palette.color(QPalette.ColorRole.Base)
|
|
|
|
# Calculate brightness (0 for dark, 255 for bright)
|
|
def brightness(color):
|
|
return (color.red() * 299 + color.green() * 587 + color.blue() * 114) // 1000
|
|
|
|
return brightness(base_color) < brightness(text_color)
|
|
|
|
|
|
# import resources # needs to be imported somewhere in the project to be picked up by qt
|
|
|
|
if platform.system() == "Windows":
|
|
# from PySide6.QtWinExtras import QtWin
|
|
myappid = f"{info.organization_name}.{info.application_version}"
|
|
# QtWin.setCurrentProcessExplicitAppUserModelID(myappid)
|
|
settings = QSettings()
|
|
width = int(settings.value("app/width", 1024))
|
|
height = int(settings.value("app/height", 768))
|
|
x = int(settings.value("app/pos_x", 100))
|
|
y = int(settings.value("app/pos_y", 100))
|
|
app = QApplication(sys.argv)
|
|
app.setApplicationName(info.application_name)
|
|
app.setApplicationVersion(str(info.application_version))
|
|
app.setOrganizationDomain(info.organization_name)
|
|
|
|
# if platform.system() == 'Linux':
|
|
# icn = QIcon(":/icons/app_icon")
|
|
# app.setWindowIcon(icn)
|
|
# Create a Qt widget, which will be our window.
|
|
window = fixtracks.MainWindow(is_dark_mode(app))
|
|
window.setGeometry(100, 100, 1024, 768)
|
|
window.setWindowTitle("FixTracks")
|
|
window.setMinimumWidth(1024)
|
|
window.setMinimumHeight(768)
|
|
window.resize(width, height)
|
|
window.move(x, y)
|
|
window.show()
|
|
|
|
# Start the event loop.
|
|
app.exec()
|
|
pos = window.pos()
|
|
settings.setValue("app/width", window.width())
|
|
settings.setValue("app/height", window.height())
|
|
settings.setValue("app/pos_x", pos.x())
|
|
settings.setValue("app/pos_y", pos.y())
|