
from PyQt6 import QtCore
from PyQt6.QtWidgets import QWidget

from UI.addseverlipphone import Ui_Addserveripphone
from .LogerinTxt import app_logger


class serveripphoneset(Ui_Addserveripphone, QWidget):
    serveripphoneset_signal = QtCore.pyqtSignal(str)

    def __init__(self, parent=None):
        super().__init__(parent)
        try:
            self.setupUi(self)
            self.pushButton.clicked.connect(self.btn)
            self.serveripphone1 = None
            self.serveripphone = None
        except Exception as e:
            app_logger.log_error(e)

    def start(self):
        self.show()
        self.lineEditIP.setText("172.27.241.131")

    def btn(self):
        try:
            self.serveripphone1 = self.lineEditIP.text()
            self.serveripphoneset_signal.emit(self.serveripphone1)
            self.close()
        except Exception as e:
            app_logger.log_error(e)
