Beispiel #1
0
    def do_after_login(self, from_auto=False):
        while MsgWorker().login_flag == 0:
            time.sleep(0.1)

        if MsgWorker().login_flag == 2:
            QMessageBox.information(self, '登录错误', "用户名或密码无效")
            # tkmsgbox.showerror('登录错误', '用户名或密码无效')
            return

        if not from_auto:
            with open(pickle_file, 'wb') as fw:
                if self.cb.isChecked():
                    pickle.dump(
                        {
                            'auto_login': True,
                            'name': self.login_name,
                            'pwd': self.login_pwd
                        }, fw)
                else:
                    pickle.dump({'auto_login': False}, fw)

        desktop = QApplication.desktop()
        frame_height = desktop.height() - 70
        frame_width = 160
        frame_left = desktop.width() - frame_width
        # self.withdraw()
        self.setVisible(False)

        main = Main(user=MsgWorker().user_info,
                    width=frame_width,
                    height=frame_height)
        main.setGeometry(frame_left, 30, frame_width, frame_height)
        main.show()
Beispiel #2
0
 def send(self):
     # val = self.sdTxt.toHtml()
     val = self.sdTxt.toPlainText()
     if self.cur_chat['mode'] == 'user':
         MsgWorker().send_msg(
             msg_lib.build_chat_msg(MsgWorker().user_info.name,
                                    self.cur_chat['data'].name, val))
     # self.rcTxt.setHtml(self.rcTxt.toHtml()+'\n我:%s'%val)
     self.rcTxt.setPlainText(self.rcTxt.toPlainText() + '我:%s\n' % val)
     self.sdTxt.setPlainText('')
Beispiel #3
0
    def __init__(self, parent=None):
        super().__init__(parent)

        self.msg_signal.connect(self.fill_msg)
        MsgWorker().do_recv_msg = self.do_recv_msg
        self.setWindowTitle('')
        self.op_bar = QFrame(self)
        self.op_bar.setStyleSheet('background-color:rgb(255, 255, 255);')
        self.send_bar = QFrame(self)
        self.send_bar.setStyleSheet('background-color:rgb(255, 255, 255);')
        self.rcTxt = QTextBrowser(self)
        self.rcTxt.setStyleSheet('background-color:rgb(255, 255, 255);')
        self.sdTxt = QTextEdit(self)
        self.sdTxt.setStyleSheet('background-color:rgb(255, 255, 255);')
        self.btn = QPushButton("发送", self.send_bar)
        self.btn.clicked.connect(self.send)
        self.lv = QListView(self)
        self.lv.setViewMode(QListView.ListMode)
        self.lv.setIconSize(QSize(30, 30))
        self.lv.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.lv.setResizeMode(QListView.Adjust)
        self.lv_model = QStandardItemModel()
        self.lv.setModel(self.lv_model)
        self.lv.clicked.connect(self.lv_clicked)
        self.lv.move(0, 0)

        w, h = 600, 400
        self.resize(800, 600)
Beispiel #4
0
    def click_login(self):
        name = self.et_name.text()
        if len(name) == 0:
            QMessageBox.information(self, '登录错误', "请输入用户名")
            # tkmsgbox.showerror('登录错误', '请输入用户名')
            return

        pwd = self.et_pwd.text()
        if len(pwd) == 0:
            QMessageBox.information(self, '登录错误', "请输入密码")
            # tkmsgbox.showerror('登录错误', '请输入密码')
            return

        MsgWorker().do_exit = self.click_cancel

        import hashlib
        md5 = hashlib.md5()
        md5.update(pwd.encode())
        md5_pwd = md5.hexdigest()

        self.login_name = name
        self.login_pwd = md5_pwd
        MsgWorker().send_msg(msg_lib.build_login_msg(name, md5_pwd))
        self.do_after_login()
Beispiel #5
0
    def __init__(self):
        super().__init__()

        auto_login = False
        try:
            with open(pickle_file, 'rb') as rb:
                data = pickle.load(rb)
            auto_login = data['auto_login']
            MsgWorker().send_msg(
                msg_lib.build_login_msg(data['name'], data['pwd']))
            self.do_after_login(from_auto=True)
        except Exception as ex:
            print(ex)

        if not auto_login:
            self.init_ui()
Beispiel #6
0
    def __init__(self, user, width=160, height=660):
        super().__init__()
        self.user = user

        self.lv = QListView(self)
        self.lv.setViewMode(QListView.ListMode)
        self.lv.setIconSize(QSize(30, 30))
        # self.lb.setGridSize(QSize(30,30))
        self.lv.resize(width, height)
        self.lv.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.lv.setResizeMode(QListView.Adjust)
        self.lv_model = QStandardItemModel()
        self.lv.setModel(self.lv_model)
        # self.lb_model.appendRow(QStandardItem(QIcon("./client/image/man.png"), "普通员工A"))
        # self.lb_model.appendRow(QStandardItem(QIcon("./client/image/woman.png"), "普通员工B"))
        self.lv.doubleClicked.connect(self.lv_clicked)

        MsgWorker().do_update = self.do_update
        self.query_all_users()
Beispiel #7
0
 def closeEvent(self, event):
     if self.chat_form:
         self.chat_form.close()
     MsgWorker().send_msg(msg_lib.build_logout_msg(self.user.name))
Beispiel #8
0
 def query_all_users(self):
     MsgWorker().send_msg(msg_lib.build_get_all_users_msg())