#!/usr/bin/env python
# -*- encoding: utf-8 -*-

import os
from ui.own.palette_theme import set_my_palette, set_sure_background
from utils.resource import resource_path
from utils.globalvar import SD
from utils.qt import QPixmap, Qt, QFont, QWidget, QComboBox, QVBoxLayout, QHBoxLayout, QLabel, QPushButton, QLineEdit, QSize, QRect, QCoreApplication, QMetaObject


class UiBmsLoginPage(object):
    def setupUi(self, bms_login):
        bms_login.resize(400, 500)
        bms_login.setMinimumSize(QSize(400, 500))
        bms_login.setMaximumSize(QSize(400, 500))
        set_my_palette(bms_login)

        self.layoutWidget = QWidget(bms_login)
        self.layoutWidget.setGeometry(QRect(70, 90, 261, 351))

        self.verticalLayout = QVBoxLayout(self.layoutWidget)
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)


        self.h_layout_role = QHBoxLayout()
        self.lb_role = QLabel()
        self.h_layout_role.addWidget(self.lb_role)
        self.cb_role = QComboBox()
        self.cb_role.setObjectName("cb_role")
        for i in range(5):
            self.cb_role.addItem("")
        self.cb_role.setItemText(0, "普通用户")
        self.cb_role.setItemText(1, "调试工程师")
        self.cb_role.setItemText(2, "BMS产线操作员")
        self.cb_role.setItemText(3, "PACK产线操作")
        self.cb_role.setItemText(4, "系统管理员")
        self.h_layout_role.addWidget(self.cb_role)
        self.verticalLayout.addLayout(self.h_layout_role)


        self.h_layout_password = QHBoxLayout()
        self.lb_password = QLabel()
        self.h_layout_password.addWidget(self.lb_password)
        self.edt_password = QLineEdit()
        self.edt_password.setEchoMode(QLineEdit.Password)
        self.edt_password.setObjectName("edt_password")
        self.h_layout_password.addWidget(self.edt_password)
        self.verticalLayout.addLayout(self.h_layout_password)

        self.h_layout_prj = QHBoxLayout()
        self.lb_prj = QLabel()
        self.h_layout_prj.addWidget(self.lb_prj)
        self.cb_prj = QComboBox()
        self.cb_prj.setObjectName("cb_prj")
        for i in range(2):
            self.cb_prj.addItem("")
        self.cb_prj.setItemText(0, "户储")
        self.cb_prj.setItemText(1, "工商业")
        self.cb_prj.setCurrentIndex(1)
        self.h_layout_prj.addWidget(self.cb_prj)
        self.verticalLayout.addLayout(self.h_layout_prj)


        self.h_layout_con_type = QHBoxLayout()
        self.lb_con_type = QLabel()
        self.h_layout_con_type.addWidget(self.lb_con_type)
        self.cb_con_type = QComboBox()
        self.cb_con_type.setObjectName("cb_con_type")
        self.cb_con_type.addItem("")
        self.cb_con_type.addItem("")
        self.cb_con_type.setItemText(0, "ZLGCAN")
        self.cb_con_type.setItemText(1, "PCAN")
        self.h_layout_con_type.addWidget(self.cb_con_type)
        self.verticalLayout.addLayout(self.h_layout_con_type)


        self.h_layout_channel = QHBoxLayout()
        self.lb_channel = QLabel()
        self.h_layout_channel.addWidget(self.lb_channel)
        self.cb_channel = QComboBox()
        self.cb_channel.setObjectName("cb_channel")
        for i in range(9):
            self.cb_channel.addItem("")
        self.cb_channel.setItemText(0, "0")
        self.cb_channel.setItemText(1, "1")
        self.cb_channel.setItemText(2, "2")
        self.cb_channel.setItemText(3, "3")
        self.cb_channel.setItemText(4, "4")
        self.cb_channel.setItemText(5, "5")
        self.cb_channel.setItemText(6, "6")
        self.cb_channel.setItemText(7, "7")
        self.cb_channel.setItemText(8, "8")
        self.h_layout_channel.addWidget(self.cb_channel)
        self.verticalLayout.addLayout(self.h_layout_channel)

        self.h_layout_index = QHBoxLayout()
        self.lb_index = QLabel()
        self.h_layout_index.addWidget(self.lb_index)
        self.cb_index = QComboBox()
        self.cb_index.setObjectName("cb_index")
        for i in range(2):
            self.cb_index.addItem("")
        self.cb_index.setItemText(0, "0")
        self.cb_index.setItemText(1, "1")
        self.h_layout_index.addWidget(self.cb_index)
        self.verticalLayout.addLayout(self.h_layout_index)

        self.h_layout_baudrate = QHBoxLayout()
        self.lb_baudrate = QLabel()
        self.h_layout_baudrate.addWidget(self.lb_baudrate)
        self.cb_baudrate = QComboBox()
        self.cb_baudrate.setObjectName("cb_baudrate")
        for i in range(3):
            self.cb_baudrate.addItem("")
        self.cb_baudrate.setItemText(0, "125Kbps")
        self.cb_baudrate.setItemText(1, "250Kbps")
        self.cb_baudrate.setItemText(2, "500Kbps")
        self.h_layout_baudrate.addWidget(self.cb_baudrate)
        self.verticalLayout.addLayout(self.h_layout_baudrate)

        self.cb_change_languqge = QComboBox(bms_login)
        self.cb_change_languqge.setObjectName("language")
        self.cb_change_languqge.addItem("")
        self.cb_change_languqge.addItem("")
        self.cb_change_languqge.setItemText(0, "中文")
        self.cb_change_languqge.setItemText(1, "English")
        self.verticalLayout.addWidget(self.cb_change_languqge)

        self.horizontalLayout = QHBoxLayout()

        self.btn_login = QPushButton(self.layoutWidget)
        self.btn_login.setObjectName("btn_login")
        set_sure_background(self.btn_login)
        self.horizontalLayout.addWidget(self.btn_login)

        self.btn_cancel = QPushButton(self.layoutWidget)
        self.btn_cancel.setObjectName("btn_cancel")
        self.horizontalLayout.addWidget(self.btn_cancel)

        self.verticalLayout.addLayout(self.horizontalLayout)


        self.retranslateUi(bms_login)
        QMetaObject.connectSlotsByName(bms_login)

    def retranslateUi(self, bms_login):
        _translate = QCoreApplication.translate
        bms_login.setWindowTitle(_translate("bms_login", "用户登录" if SD.SYSTEM_LANGUAGE == 0 else "Login"))
        self.lb_role.setText("登录角色" if SD.SYSTEM_LANGUAGE == 0 else "Role")
        self.lb_password.setText("登录密码" if SD.SYSTEM_LANGUAGE == 0 else "PassWord")
        self.lb_prj.setText("登录项目" if SD.SYSTEM_LANGUAGE == 0 else "Project")
        self.lb_con_type.setText("通讯类型" if SD.SYSTEM_LANGUAGE == 0 else "Conn Type")
        self.lb_channel.setText("索引号" if SD.SYSTEM_LANGUAGE == 0 else "Index")
        self.lb_index.setText("通道号" if SD.SYSTEM_LANGUAGE == 0 else "Channel")
        self.lb_baudrate.setText("波特率" if SD.SYSTEM_LANGUAGE == 0 else "BPS")
        self.edt_password.setPlaceholderText("密码" if SD.SYSTEM_LANGUAGE == 0 else "PassWord")
        self.btn_login.setText(_translate("bms_login", "登录" if SD.SYSTEM_LANGUAGE == 0 else "Login"))
        self.btn_cancel.setText(_translate("bms_login", "取消" if SD.SYSTEM_LANGUAGE == 0 else "Cancel"))
