"""
Main StartUp Script 
inits Settings and loads gui afterwards
"""

import sys
import os

from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *

# debug für Laufzeit auskommentiert
#import time
#start_proc = time.process_time()

import utils.globalSettings as globalSettings
globalSettings.init()

from LayoutElements.mainWindowGUI import mainWindowGUI

#nachfolgender Abschnitt notwendig, damit sich Splash-Screen sich wieder automatisch schließt
import importlib.util

if '_PYIBoot_SPLASH' in os.environ and importlib.util.find_spec("pyi_splash"):
    import pyi_splash
    pyi_splash.update_text('UI Loaded ...')
    pyi_splash.close()
    #log.info('Splash screen closed.')



basedir = os.path.dirname(__file__)


#nachfolgender Abschnitt notwendig, damit Icon in Taskbar angezeigt wird


try:
    from ctypes import windll

    myappid = "com.PTW_TU_Darmstadt.Bohrentgraten.1"
    windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)

except ImportError:
    pass

#background-color: rgb(0,0,0); MenuBar
stylesheet="""
QTextEdit{
    background-color: white;
}

#MainWindow {
    background-color: rgb(8,156,220);
}

#MenuBar {
    background-color: rgb(8,156,220);
}

#MenuBar::item {
    spacing: 3px;           
    padding: 2px 10px;
    background-color: lightblue;
    color= rgb(255,255,255)
    border-radius: 5px;

}

.QWidget{
    background-color: rgb(255,255,255);
}



"""

App = QApplication(sys.argv)
#App.setStyleSheet(stylesheet)
App.setStyle('Fusion')
App.setStyleSheet("""
    QToolTip {
        background-color: white;
        color: black;
        border: 1px solid black;
    }
""")
App.setWindowIcon(QIcon(os.path.join(basedir, "Images/icon.svg")))

window = mainWindowGUI(App)
window.show()
window.activateWindow()
window.raise_()

sys.exit(App.exec())

