import sys

from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication
import mytool.db_helper.db_operation as spmng
import mytool.json_helper.parse_json as parse_json
import main_window_XmSgj
import main_window_GyBhhy

if __name__ == '__main__':
    app = QApplication(sys.argv)
    desktop = QApplication.desktop()
    config = parse_json.parse_json_with_comments('./config.json')
    # 数据库配置
    db_config = config['db_config']
    # 显示配置
    show_config = config['show_config']
    task_type = 0
    if show_config['task_type'] == 'park':
        task_type = 1
    elif show_config['task_type'] == 'pick':
        task_type = 2
    if config['project_name'] == 'xm_sgj':
        window = main_window_XmSgj.MainWindow(task_type,show_config,db_config)
    elif config['project_name'] == 'gy_bhhy':
        window = main_window_GyBhhy.MainWindow(show_config['display_number'],show_config['unit'],show_config['unit_list'][show_config['unit']],task_type,show_config['font_size'],db_config)
    screen_count = desktop.screenCount()
    if screen_count > 1:
        screen = desktop.screen(1)
        window.move(screen.geometry().x(), screen.geometry().y())
    window.setGeometry(desktop.screenGeometry(1))
    window.showMaximized()
    sys.exit(app.exec_())
