Example #1
0
    def __init__(self):
        super(UserListWidget, self).__init__()
        self.concentrate_subject = ConcentrateSubject()
        self.concentrate_subject.attach(self)

        self.setAccessibleName(main_widget_styles[0])
        self.setStyleSheet(main_widget_styles[1])
        self.__init_ui__()
class MainAuthWindow(Observer, QMainWindow):
    """ Main window for sign-in and sign-up pages and application
    """
    def __init__(self, parent=None, socket_server=None):
        super(MainAuthWindow, self).__init__(parent=parent)
        self.concentrate_subject = ConcentrateSubject()
        self.concentrate_subject.attach(self)
        self.socket_server = socket_server

        self.setWindowTitle("Auth page")
        self.setMinimumSize(800, 600)
        self.setMaximumSize(800, 600)

        self.setContentsMargins(0, 0, 0, 0)

        self.setAccessibleName(main_window_style[0])
        self.setStyleSheet(main_window_style[1])

        self.__set_centeral_widget_config__()

    @property
    def class_name(self):
        return "MAIN_AUTH_WINDOW"

    def __set_centeral_widget_config__(self):
        """ Add centeral widget for switching between widgets in main window
        :return:
        """
        main_widget = QWidget(self)
        main_widget.setContentsMargins(0, 0, 0, 0)

        # add widget to main widget
        main_widget_layout = QGridLayout(main_widget)
        main_widget_layout.setContentsMargins(0, 0, 0, 0)

        # add another widget
        from gui.windows.pages.auth.signin import SignIn
        from gui.windows.pages.auth.signup import SignUp

        signin_page = SignIn(parent=self, socket_server=self.socket_server)
        signin_page.set_visibility(True)
        signup_page = SignUp(parent=self, socket_server=self.socket_server)
        signup_page.set_visibility(False)

        signin_page.set_sign_up_page(signup_page)
        signup_page.set_sign_in_page(signin_page)

        main_widget_layout.addWidget(signin_page)
        main_widget_layout.addWidget(signup_page)

        self.setCentralWidget(main_widget)

    def execute_app(self):
        """ show main window in application layout
        :return:
        """
        self.show()
Example #3
0
    def __init__(self, parent=None):
        super(ServerLogs, self).__init__(parent=parent)
        self.concentrate_subject = ConcentrateSubject()
        self.concentrate_subject.attach(self)

        self.setAccessibleName(server_log_widget_styles[0])
        self.setStyleSheet(server_log_widget_styles[1])

        main_layout = QHBoxLayout()
        main_layout.setContentsMargins(0, 0, 0, 0)
        main_layout.addWidget(self.__add_widget__())
        self.setLayout(main_layout)
Example #4
0
    def __init__(self, parent=None, socket_server=None):
        super(MainWindow, self).__init__(parent=parent)
        self.concentrate_subject = ConcentrateSubject()
        self.concentrate_subject.attach(self)

        self.socket_server = socket_server

        self.setWindowTitle("main window")
        self.setContentsMargins(0, 0, 0, 0)

        self.setAccessibleName(main_window_styles[0])
        self.setStyleSheet(main_window_styles[1])

        self.__set_main_widget__()
    def __init__(self, parent=None, socket_server=None):
        super(MainAuthWindow, self).__init__(parent=parent)
        self.concentrate_subject = ConcentrateSubject()
        self.concentrate_subject.attach(self)
        self.socket_server = socket_server

        self.setWindowTitle("Auth page")
        self.setMinimumSize(800, 600)
        self.setMaximumSize(800, 600)

        self.setContentsMargins(0, 0, 0, 0)

        self.setAccessibleName(main_window_style[0])
        self.setStyleSheet(main_window_style[1])

        self.__set_centeral_widget_config__()
Example #6
0
    def __init__(self, parent=None, socket_server=None):
        super(TableWidget, self).__init__(parent=parent)
        self.concentrate_subject = ConcentrateSubject()
        self.concentrate_subject.attach(self)

        self.socket_server = socket_server

        self.setAccessibleName(main_table_widget_styles[0])
        self.setStyleSheet(main_table_widget_styles[1])

        table_main_layout = QVBoxLayout()
        table_main_layout.setContentsMargins(10, 0, 10, 0)
        table_main_layout.setStretch(0, 0)
        table_main_layout.setSpacing(0)

        table_main_layout.addWidget(self.__add_widget__())

        self.setLayout(table_main_layout)
Example #7
0
    def __init__(self, parent=None, socket_server=None):
        super(SignUp, self).__init__(parent=parent)
        self.concentrate_subject = ConcentrateSubject()
        self.concentrate_subject.attach(self)
        self.socket_server = socket_server

        self.parent = parent

        self.setContentsMargins(0, 0, 0, 0)

        self.main_layout = QVBoxLayout()
        self.main_layout.setContentsMargins(0, 0, 0, 0)
        self.main_layout.setStretch(0, 0)
        self.main_layout.setAlignment(Qt.AlignHCenter)

        self.__init_ui__()

        self.main_layout.addWidget(self.main_frame)
        self.setLayout(self.main_layout)
Example #8
0
class TableWidget(Observer, QWidget):
    """ this class make the server table widget gui of server app """
    
    client_sets: set = set()

    def __init__(self, parent=None, socket_server=None):
        super(TableWidget, self).__init__(parent=parent)
        self.concentrate_subject = ConcentrateSubject()
        self.concentrate_subject.attach(self)

        self.socket_server = socket_server

        self.setAccessibleName(main_table_widget_styles[0])
        self.setStyleSheet(main_table_widget_styles[1])

        table_main_layout = QVBoxLayout()
        table_main_layout.setContentsMargins(10, 0, 10, 0)
        table_main_layout.setStretch(0, 0)
        table_main_layout.setSpacing(0)

        table_main_layout.addWidget(self.__add_widget__())

        self.setLayout(table_main_layout)

    @property
    def class_name(self):
        """ this function return a class name to access in codes """
        return "TABLE_WIDGET"

    def __add_widget__(self):
        """ this function return a q-frame to use in main layout """

        main_frame = QFrame()
        main_frame.setContentsMargins(0, 10, 0, 0)
        main_frame.setAccessibleName(main_frame_styles[0])
        main_frame.setStyleSheet(main_frame_styles[1])

        frame_layout = QVBoxLayout()
        frame_layout.setContentsMargins(0, 0, 0, 0)
        frame_layout.setStretch(0, 0)
        frame_layout.setSpacing(0)

        self.table_widget = QTableWidget()
        self.table_widget.setAccessibleName(table_widget_styles[0])
        self.table_widget.setStyleSheet(table_widget_styles[1])
        self.table_widget.verticalHeader().hide()
        self.table_widget.setRowCount(0)
        self.table_widget.setColumnCount(4)
        self.table_widget.setHorizontalHeaderLabels(["IP Client", "Name", "Port", "System"])

        header = self.table_widget.horizontalHeader()
        header.setAccessibleName(table_header_styles[0])
        header.setStyleSheet(table_header_styles[1])
        header.setSectionResizeMode(0, QHeaderView.Stretch)
        header.setSectionResizeMode(1, QHeaderView.Stretch)
        header.setSectionResizeMode(2, QHeaderView.Stretch)
        header.setSectionResizeMode(3, QHeaderView.Stretch)

        frame_layout.addWidget(self.table_widget)
        main_frame.setLayout(frame_layout)

        return main_frame

    def notification(self, message):
        """ Receive update from subject
            :params message: incoming message
        """
        from json import loads as json_loads

        incoming_message = json_loads(message)

        if incoming_message["type"] == "[ADD]":
            self.row_position = self.table_widget.rowCount()
            self.table_widget.insertRow(self.row_position)

            self.table_widget.setItem(self.row_position, 0, QTableWidgetItem(incoming_message["message"]["ip"]))
            self.table_widget.setItem(self.row_position, 1, QTableWidgetItem(incoming_message["message"]["name"]))
            self.table_widget.setItem(self.row_position, 2, QTableWidgetItem(incoming_message["message"]["port"]))
            self.table_widget.setItem(self.row_position, 3, QTableWidgetItem(incoming_message["message"]["system"]))
            
        elif incoming_message["type"] == "[REMOVE]":
            model = self.table_widget.model()
            for row in range(model.rowCount()):
                ip_column = model.index(row, 0)
                ip_column_text = str(model.data(ip_column))
                port_column = model.index(row, 2)
                port_column_text = str(model.data(port_column))

                if incoming_message["message"][0] + ":" + str(incoming_message["message"][1]) ==\
                        str(ip_column_text) + ":" + str(port_column_text):

                    self.table_widget.removeRow(row)
                    break
Example #9
0
class ServerLogs(Observer, QWidget):
    """ this class make the server logs widget gui of server app """
    def __init__(self, parent=None):
        super(ServerLogs, self).__init__(parent=parent)
        self.concentrate_subject = ConcentrateSubject()
        self.concentrate_subject.attach(self)

        self.setAccessibleName(server_log_widget_styles[0])
        self.setStyleSheet(server_log_widget_styles[1])

        main_layout = QHBoxLayout()
        main_layout.setContentsMargins(0, 0, 0, 0)
        main_layout.addWidget(self.__add_widget__())
        self.setLayout(main_layout)

    @property
    def class_name(self):
        """ this function return a class name to access in codes """

        return "EDIT_LOGGER"

    def __add_widget__(self):
        """ this function return a q-frame to use in main layout """

        main_frame = QFrame()
        main_frame.setContentsMargins(0, 0, 0, 0)
        main_frame.setAccessibleName(main_frame_styles[0])
        main_frame.setStyleSheet(main_frame_styles[1])

        frame_layout = QHBoxLayout()
        frame_layout.setContentsMargins(0, 0, 0, 0)
        frame_layout.setStretch(0, 0)
        frame_layout.setSpacing(0)

        self.q_text_edit = QTextEdit()
        self.q_text_edit.setAccessibleName(q_text_edit_styles[0])
        self.q_text_edit.setReadOnly(True)
        self.q_text_edit.setStyleSheet(q_text_edit_styles[1])

        frame_layout.addWidget(self.q_text_edit)

        main_frame.setLayout(frame_layout)

        return main_frame

    def notification(self, message):
        """ Receive update from subject
            :params message: incoming message
        """
        from json import loads as json_loads

        incoming_message = json_loads(message)

        if incoming_message["type_log"] == "CLIENT_LOG":

            last_text = self.q_text_edit.toPlainText()
            self.q_text_edit.setText(last_text + "\n" +
                                     str(datetime.now()).split(".")[0] + " " +
                                     str(incoming_message["client_address"]) +
                                     ": " + incoming_message["message"])
        elif incoming_message["type_log"] == "SERVER_LOG":
            last_text = self.q_text_edit.toPlainText()
            self.q_text_edit.setText(last_text + "\n" +
                                     str(datetime.now()).split(".")[0] + " " +
                                     incoming_message["message"])

    @property
    def signal(self):
        return self._signal
Example #10
0
class SignIn(Observer, QWidget):
    def __init__(self, parent=None, socket_server=None):
        super(SignIn, self).__init__(parent=parent)
        self.concentrate_subject = ConcentrateSubject()
        self.concentrate_subject.attach(self)
        self.socket_server = socket_server

        self.check_user_pass()

        self.setContentsMargins(0, 0, 0, 0)

        self.parent = parent

        self.main_layout = QVBoxLayout()
        self.main_layout.setContentsMargins(0, 0, 0, 0)
        self.main_layout.setStretch(0, 0)
        self.main_layout.setAlignment(Qt.AlignHCenter)

        self.__init_ui__()

        self.main_layout.addWidget(self.main_frame)
        self.setLayout(self.main_layout)

    def check_user_pass(self):
        last_user = User.select()
        if len(last_user) > 0:
            last_user = last_user[len(last_user) - 1]
            if last_user is not None:
                data = json_dumps({
                    "message": {
                        "username": last_user.username,
                        "password": last_user.password
                    },
                    "command": "[LOGIN]",
                    "session": None,
                    "option": None,
                    "route": {
                        "group": "",
                        "to": "server"
                    },
                })

                self.socket_server.get_socket.sendall(data.encode("utf-8"))

    @property
    def class_name(self):
        return "SIGN_IN"

    def __init_ui__(self):
        self.main_frame = QFrame()
        self.main_frame.setContentsMargins(0, 0, 0, 0)
        self.main_frame.setAccessibleName(main_frame_styles[0])
        self.main_frame.setStyleSheet(main_frame_styles[1])

        self.frame_layout = QVBoxLayout()
        self.frame_layout.setContentsMargins(0, 0, 0, 0)
        self.frame_layout.setStretch(0, 0)
        self.frame_layout.setSpacing(0)

        self._add_textboxs_()
        self._add_forgot_password_()
        self._add_btn_login_()
        self._add_btn_create_account_()

        self.main_frame.setLayout(self.frame_layout)

    def _add_textboxs_(self):

        self.username_edit_text = QLineEdit()
        self.username_edit_text.setPlaceholderText("Enter UserName")
        self.username_edit_text.setAccessibleName(q_edit_text_style[0])
        self.username_edit_text.setStyleSheet(q_edit_text_style[1])

        self.frame_layout.addWidget(self.username_edit_text)

        self.password_edit_text = QLineEdit()
        self.password_edit_text.setPlaceholderText("Enter Password")
        self.password_edit_text.setAccessibleName(q_edit_text_style[0])
        self.password_edit_text.setStyleSheet(q_edit_text_style[1])

        self.frame_layout.addWidget(self.password_edit_text)

    def _add_forgot_password_(self):
        btn_forgot_password = QPushButton("Forgot password?")
        btn_forgot_password.setAccessibleName(btn_forgot_password_style[0])
        btn_forgot_password.setStyleSheet(btn_forgot_password_style[1])

        # self.main_layout.addWidget(btn_forgot_password)
        self.frame_layout.addWidget(btn_forgot_password)

    def _add_btn_login_(self):
        btn_login = QPushButton("SingIn")
        btn_login.setAccessibleName(btn_login_style[0])
        btn_login.setStyleSheet(btn_login_style[1])

        def btn_login_clicked():
            username: str = self.username_edit_text.text()
            password: str = self.password_edit_text.text()

            try:
                if username != "" and password != "":
                    user = User.select().where((User.username == username)
                                               & (User.password == password))
                    if len(user) > 0:
                        data = json_dumps({
                            "message": "",
                            "command": "[LOGIN_INF]",
                            "session": "",
                            "option": {
                                "sys_info": str(uname().system),
                                "username": username
                            },
                            "route": {
                                "group": "",
                                "to": "server"
                            },
                        })

                        self.socket_server.get_socket.sendall(
                            data.encode("utf-8"))

                        from gui.windows.window_handler.main_window_handler.mainwindow import MainWindow
                        main_window = MainWindow(self.parent,
                                                 self.socket_server)
                        self.parent.hide()
                        main_window.execute_app()
                    else:
                        MessageBox(title="Not Success",
                                   message="UnAuthorized").show()
                else:
                    MessageBox(
                        title="Error",
                        message=str("Please fill both of password and username"
                                    )).show()

            except Exception as error:
                MessageBox(title="Error", message=str(error)).show()

        btn_login.clicked.connect(btn_login_clicked)

        self.frame_layout.addWidget(btn_login)

    def _add_btn_create_account_(self):
        btn_create_account = QPushButton("Create new account ?")
        btn_create_account.setAccessibleName(btn_create_account_style[0])
        btn_create_account.setStyleSheet(btn_create_account_style[1])
        btn_create_account.setContentsMargins(0, 0, 0, 0)

        def clicked_create_account():
            self.set_visibility(False)
            self.signup_page.set_visibility(True)

        btn_create_account.clicked.connect(clicked_create_account)

        # self.main_layout.addWidget(btn_create_account)
        self.frame_layout.addWidget(btn_create_account)

    def set_visibility(self, visible: bool):
        if visible:
            self.show()
        else:
            self.hide()

    def set_sign_up_page(self, signup: object):
        self.signup_page = signup

    def notification(self, message):
        incoming_message = json_loads(message)
        last_user = User.select()
        last_user = last_user[len(last_user) - 1]
        if incoming_message["message"]["code"] == 200:
            data = json_dumps({
                "message": "",
                "command": "[LOGIN_INF]",
                "session": "",
                "option": {
                    "sys_info": str(uname().system),
                    "username": last_user.username
                },
                "route": {
                    "group": "",
                    "to": "server"
                },
            })
            self.socket_server.get_socket.sendall(data.encode("utf-8"))

            self.concentrate_subject.notify(incoming_message, to="USER_LIST")

            from gui.windows.window_handler.main_window_handler.mainwindow import MainWindow
            main_window = MainWindow(self.parent,
                                     socket_server=self.socket_server)
            self.parent.hide()
            main_window.execute_app()
        else:
            return

    @property
    def signal(self):
        return self._signal
Example #11
0
class MainWindow(Observer, QMainWindow):
    """ this class make the main window gui of server app """
    def __init__(self, parent=None, socket_server=None):
        super(MainWindow, self).__init__(parent=parent)
        self.concentrate_subject = ConcentrateSubject()
        self.concentrate_subject.attach(self)

        self.socket_server = socket_server

        self.setWindowTitle("main window")
        self.setContentsMargins(0, 0, 0, 0)

        self.setAccessibleName(main_window_styles[0])
        self.setStyleSheet(main_window_styles[1])

        self.__set_main_widget__()

    @property
    def class_name(self):
        """ this function return a class name to access in codes """

        return "MAIN_WINDOW"

    def __set_main_widget__(self):
        """ Add centeral widget for switching between widgets in main window
            :return:
        """
        main_widget = QWidget(self)
        self.setCentralWidget(main_widget)

        self.main_widget_layout = QHBoxLayout()
        self.main_widget_layout.setStretch(0, 0)
        self.main_widget_layout.setContentsMargins(0, 0, 0, 0)

        self.__create_grid_layout__()

        self.main_widget_layout.addWidget(self.horizontalGroupBox)
        main_widget.setLayout(self.main_widget_layout)

    def __create_grid_layout__(self):
        """ this function create a grid layout to add widgets on it """

        self.horizontalGroupBox = QGroupBox()
        self.horizontalGroupBox.setContentsMargins(0, 0, 0, 0)

        layout = QGridLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)

        from ...pages.main_window_widgets.main_server_widget import ServerMainWidget
        from ...pages.main_window_widgets.table_widget import TableWidget

        server_widget = ServerMainWidget(parent=self,
                                         socket_server=self.socket_server)
        table_widget = TableWidget(parent=self,
                                   socket_server=self.socket_server)

        layout.addWidget(server_widget, 0, 0)
        layout.addWidget(table_widget, 0, 1)

        self.horizontalGroupBox.setLayout(layout)

    def execute_app(self):
        """ this function show up the window """

        self.show()
Example #12
0
class UserListWidget(Observer, QWidget):
    def __init__(self):
        super(UserListWidget, self).__init__()
        self.concentrate_subject = ConcentrateSubject()
        self.concentrate_subject.attach(self)

        self.setAccessibleName(main_widget_styles[0])
        self.setStyleSheet(main_widget_styles[1])
        self.__init_ui__()

    def __init_ui__(self):
        self.scroll_layout = QFormLayout()
        self.scroll_layout.setContentsMargins(10, 10, 10, 10)
        self.scroll_layout.setSpacing(0)

        self.scroll_widget = QWidget()
        self.scroll_widget.setAccessibleName(main_scroll_holder_frame[0])
        self.scroll_widget.setStyleSheet(main_scroll_holder_frame[1])
        self.scroll_widget.setLayout(self.scroll_layout)

        self.scroll_area = QScrollArea()
        self.scroll_area.setAccessibleName(scroll_layout_styles[0])
        self.scroll_area.setStyleSheet(scroll_layout_styles[1])
        self.scroll_area.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.scroll_area.setWidgetResizable(True)
        self.scroll_area.setWidget(self.scroll_widget)

    def get_scroll_widget(self):
        return self.scroll_area

    @property
    def class_name(self):
        return "USER_LIST"

    def __add_scroll_area__(self, username):
        sub_frame = QFrame()
        sub_frame.setContentsMargins(0, 0, 0, 0)

        sub_frame.setAccessibleName(sub_qframe_styles[0])
        sub_frame.setStyleSheet(sub_qframe_styles[1])

        user_profile_layout = QHBoxLayout()
        user_profile_layout.setContentsMargins(0, 0, 0, 0)

        self.username_icon = QPushButton()
        self.username_icon.setContentsMargins(0, 0, 0, 0)
        self.username_icon.setAccessibleName(username_icon_styles[0])
        self.username_icon.setStyleSheet(username_icon_styles[1])
        icon = QIcon('./assets/user.png')
        self.username_icon.setIcon(icon)
        self.username_icon.setIconSize(QSize(40, 40))

        self.username_label = QLabel(username)
        self.username_label.setContentsMargins(0, 0, 0, 0)
        self.username_label.setAccessibleName(username_label_styles[0])
        self.username_label.setStyleSheet(username_label_styles[1])

        user_profile_layout.addWidget(self.username_icon)
        user_profile_layout.addWidget(self.username_label)

        sub_frame.setLayout(user_profile_layout)

        self.scroll_layout.addRow(sub_frame)

    def notification(self, message):
        for item in message["message"]["option"]["online_users"]:
            self.__add_scroll_area__(item["username"])
Example #13
0
class SignUp(Observer, QWidget):

    def __init__(self, parent=None, socket_server=None):
        super(SignUp, self).__init__(parent=parent)
        self.concentrate_subject = ConcentrateSubject()
        self.concentrate_subject.attach(self)
        self.socket_server = socket_server

        self.parent = parent

        self.setContentsMargins(0, 0, 0, 0)

        self.main_layout = QVBoxLayout()
        self.main_layout.setContentsMargins(0, 0, 0, 0)
        self.main_layout.setStretch(0, 0)
        self.main_layout.setAlignment(Qt.AlignHCenter)

        self.__init_ui__()

        self.main_layout.addWidget(self.main_frame)
        self.setLayout(self.main_layout)

    @property
    def class_name(self):
        return "SIGN_UP"

    def __init_ui__(self):
        self.main_frame = QFrame()
        self.main_frame.setContentsMargins(0, 0, 0, 0)
        self.main_frame.setAccessibleName(main_frame_styles[0])
        self.main_frame.setStyleSheet(main_frame_styles[1])

        self.frame_layout = QVBoxLayout()
        self.frame_layout.setContentsMargins(0, 0, 0, 0)
        self.frame_layout.setStretch(0, 0)
        self.frame_layout.setSpacing(0)

        self._add_textboxs_()
        self._add_btn_signup_()
        self._add_btn_register_account_()

        self.main_frame.setLayout(self.frame_layout)

    def _add_textboxs_(self):
        self.username_edit_text = QLineEdit()
        self.username_edit_text.setPlaceholderText("UserName")
        self.username_edit_text.setAccessibleName(q_edit_text_style[0])
        self.username_edit_text.setStyleSheet(q_edit_text_style[1])

        self.frame_layout.addWidget(self.username_edit_text)

        self.password_edit_text = QLineEdit()
        self.password_edit_text.setPlaceholderText("Password")
        self.password_edit_text.setAccessibleName(q_edit_text_style[0])
        self.password_edit_text.setStyleSheet(q_edit_text_style[1])

        self.frame_layout.addWidget(self.password_edit_text)

    def _add_btn_signup_(self):
        btn_signup = QPushButton("SignUp")
        btn_signup.setAccessibleName(btn_signup_style[0])
        btn_signup.setStyleSheet(btn_signup_style[1])

        def btn_register_clicked():
            username: str = self.username_edit_text.text()
            password: str = self.password_edit_text.text()

            try:
                if username != "" and password != "":                    
                    
                    self.socket_server.get_socket.sendall(json_dumps({
                        "message": {
                            "USERNAME": username,
                            "PASSWORD": password
                        },
                        "params": {
                            "USERNAME": username
                        },
                        "command": "[REGISTER]",
                        "session": None,
                        "route": {
                            "group": "",
                            "to": "server"
                        },
                        "option": None
                    }).encode("utf-8"))
                else:
                    MessageBox(
                        title="Error",
                        message=str("Please fill both of password and username")
                    ).show()
            except Exception as error:
                MessageBox(
                    title="Error",
                    message=str(error)
                ).show()

        btn_signup.clicked.connect(btn_register_clicked)

        self.frame_layout.addWidget(btn_signup)

    def _add_btn_register_account_(self):
        btn_goto_register_page = QPushButton("SignIn?")
        btn_goto_register_page.setAccessibleName(btn_goto_register_page_style[0])
        btn_goto_register_page.setStyleSheet(btn_goto_register_page_style[1])
        btn_goto_register_page.setContentsMargins(0, 0, 0, 0)

        def change_page_to_register():
            self.set_visibility(False)
            self.signin_page.set_visibility(True)

        btn_goto_register_page.clicked.connect(change_page_to_register)

        self.frame_layout.addWidget(btn_goto_register_page)

    def set_visibility(self, visible: bool):
        if visible:
            self.show()
        else:
            self.hide()

    def set_sign_in_page(self, signin: object):
        self.signin_page = signin

    def notification(self, message):
        incoming_message = json_loads(message)
        
        if incoming_message["message"]["code"] == 200:
            User.create(
                username=self.username_edit_text.text(),
                password=self.password_edit_text.text()
            )

            data = json_dumps({
                "message": "",
                "command": "[LOGIN_INF]",
                "session": "",
                "option": {
                    "sys_info": str(uname().system),
                    "username": self.username_edit_text.text()
                },
                "route": {
                    "group": "",
                    "to": "server"
                },
            })

            self.signal.emit(data)

            self.socket_server.get_socket.sendall(data.encode("utf-8"))

            from gui.windows.window_handler.main_window_handler.mainwindow import MainWindow
            main_window = MainWindow(self.parent, socket_server=self.socket_server)
            self.parent.hide()
            main_window.execute_app()

    @property
    def signal(self):
        return self._signal