# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'device.ui'
#
# Created by: PyQt5 UI code generator 5.15.1
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.  Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets

from ui import media


class Ui_widget(object):
    def setupUi(self, widget, owner, mac):
        self.mac = mac
        self.owner = owner
        widget.setObjectName("widget")
        widget.resize(600, 45)
        widget.setStyleSheet("#widget {\n"
                             "    background: black;\n"
                             "    border-bottom: 1px solid #CCC\n"
                             "}\n"
                             "\n"
                             "* {\n"
                             "    color: white\n"
                             "}")
        self.label_sound = QtWidgets.QLabel(widget)
        self.label_sound.setGeometry(QtCore.QRect(10, 10, 25, 25))
        if not self.mac == media.Ui_content.current_bt_device:
            self.label_sound.setVisible(False)
        font = QtGui.QFont()
        font.setFamily("Avenir Next LT Pro")
        font.setPointSize(13)
        self.label_sound.setFont(font)
        self.label_sound.setStyleSheet("color: #CCC")
        self.label_sound.setText("")
        self.label_sound.setPixmap(QtGui.QPixmap(":/images/sound_gray.svg"))
        self.label_sound.setScaledContents(True)
        self.label_sound.setAlignment(QtCore.Qt.AlignCenter)
        self.label_sound.setObjectName("label_sound")
        self.label_name = QtWidgets.QLabel(widget)
        self.label_name.setGeometry(QtCore.QRect(70, 10, 300, 25))
        font = QtGui.QFont()
        font.setFamily("Montserrat")
        font.setPointSize(14)
        self.label_name.setFont(font)
        self.label_name.setStyleSheet("")
        self.label_name.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
        self.label_name.setObjectName("label_name")
        self.btn_remove = QtWidgets.QWidget(widget)
        self.btn_remove.setEnabled(True)
        self.btn_remove.setGeometry(QtCore.QRect(555, 7, 30, 30))
        self.btn_remove.setStyleSheet("#btn_remove {\n"
                                      "    background: #252525; color: white\n"
                                      "}\n"
                                      "\n"
                                      "#btn_remove::hover {\n"
                                      "    background: #303030;\n"
                                      "}\n"
                                      "\n"
                                      "#btn_remove::!enabled {\n"
                                      "    background: #595959;\n"
                                      "    border-bottom: 3px solid #E00000;\n"
                                      "}")
        self.btn_remove.setObjectName("btn_remove")
        self.btn_remove.mouseReleaseEvent = self.removeClicked
        self.label_btn_remove = QtWidgets.QLabel(self.btn_remove)
        self.label_btn_remove.setGeometry(QtCore.QRect(3, 3, 24, 24))
        self.label_btn_remove.setText("")
        self.label_btn_remove.setPixmap(QtGui.QPixmap(":/images/remove.svg"))
        self.label_btn_remove.setScaledContents(True)
        self.label_btn_remove.setObjectName("label_btn_remove")
        self.btn_connect = QtWidgets.QWidget(widget)
        self.btn_connect.setEnabled(True)
        self.btn_connect.setGeometry(QtCore.QRect(515, 7, 30, 30))
        self.btn_connect.setStyleSheet("#btn_connect {\n"
                                          "    background: #252525; color: white\n"
                                          "}\n"
                                          "\n"
                                          "#btn_connect::hover {\n"
                                          "    background: #303030;\n"
                                          "}\n"
                                          "\n"
                                          "#btn_connect::!enabled {\n"
                                          "    background: #595959;\n"
                                          "    border-bottom: 3px solid #E00000;\n"
                                          "}")
        self.btn_connect.setObjectName("btn_connect")
        self.btn_connect.mouseReleaseEvent = self.connectClicked
        self.label_btn_connect = QtWidgets.QLabel(self.btn_connect)
        self.label_btn_connect.setGeometry(QtCore.QRect(3, 3, 24, 24))
        self.label_btn_connect.setText("")
        if self.owner.current_tab_connected:
            self.label_btn_connect.setPixmap(QtGui.QPixmap(":/images/disconnect.svg"))
        else:
            self.label_btn_connect.setPixmap(QtGui.QPixmap(":/images/connect.svg"))
        self.label_btn_connect.setScaledContents(True)
        self.label_btn_connect.setObjectName("label_btn_connect")
        self.btn_sound = QtWidgets.QWidget(widget)
        self.btn_sound.setEnabled(True)
        self.btn_sound.setGeometry(QtCore.QRect(475, 7, 30, 30))
        self.btn_sound.setStyleSheet("#btn_sound {\n"
                                     "    background: #252525; color: white\n"
                                     "}\n"
                                     "\n"
                                     "#btn_sound::hover {\n"
                                     "    background: #303030;\n"
                                     "}\n"
                                     "\n"
                                     "#btn_sound::!enabled {\n"
                                     "    background: #595959;\n"
                                     "    border-bottom: 3px solid #E00000;\n"
                                     "}")
        self.btn_sound.setObjectName("btn_sound")
        self.btn_sound.mouseReleaseEvent = self.soundClicked
        self.btn_sound.setVisible(False)
        #if not self.owner.current_tab_connected or self.mac == media.Ui_content.current_bt_device:
            #self.btn_sound.setVisible(False)
        self.label_btn_sound = QtWidgets.QLabel(self.btn_sound)
        self.label_btn_sound.setGeometry(QtCore.QRect(3, 3, 24, 24))
        self.label_btn_sound.setText("")
        self.label_btn_sound.setPixmap(QtGui.QPixmap(":/images/sound_white.svg"))
        self.label_btn_sound.setScaledContents(True)
        self.label_btn_sound.setObjectName("label_btn_sound")

        self.retranslateUi(widget)
        QtCore.QMetaObject.connectSlotsByName(widget)

    def retranslateUi(self, widget):
        _translate = QtCore.QCoreApplication.translate
        widget.setWindowTitle(_translate("widget", "Form"))
        self.label_name.setText(_translate("widget", "Device"))

    def removeClicked(self, event):
        self.owner.bluetooth.remove(self.mac)
        self.owner.updateDevices()

    def connectClicked(self, event):
        if self.owner.current_tab_connected:
            self.owner.bluetooth.disconnect(self.mac)
        else:
            self.owner.bluetooth.trust(self.mac)
            self.owner.bluetooth.connect(self.mac)
        self.owner.updateDevices()

    def soundClicked(self, event):
        media.Ui_content.current_bt_device = self.mac
        self.owner.updateDevices()
