Ejemplo n.º 1
0
def ready(roomnumber):
    cur, conn = DataBaseRelated.ini()
    number = DataBaseRelated.curretroomusernumber(roomnumber, cur)
    if number >= 2:
        s = server_ini(number)
        c = server_connect(number, s)
        return number, c
    else:
        return 0, 0
Ejemplo n.º 2
0
 def refresh(self):
     cur, conn = DataBaseRelated.ini()
     status1 = DataBaseRelated.numberofrooms(cur)
     status2 = DataBaseRelated.numberofusers(cur)
     self.l3.setText(str(status1))
     self.l4.setText(str(status2))
     numberlist = DataBaseRelated.return_roomnumberlist(cur)
     conn.close()
     for i in numberlist:
         number, c = recv.ready(i)
         if number >= 3:
             t = threading.Thread(target=recv.work, args=c)
             t.start()
Ejemplo n.º 3
0
    def btn2_clk(self):
        username = self.le1.text()
        password = self.le2.text()
        cur, conn = DataBaseRelated.ini()
        if not DataBaseRelated.search_username(username,cur):
            DataBaseRelated.signup(username,password,cur,conn)
            buttonReply = QMessageBox.question(self, 'temproom', "注册成功!", QMessageBox.Yes)
            if buttonReply == QMessageBox.Yes:
                self.hide()
                self.window2 = w2.Window(username)
                self.window2.show()

        else:
            buttonReply = QMessageBox.question(self, 'temproom', "用户名已被占用,请重新注册", QMessageBox.Yes)
            if buttonReply == QMessageBox.Yes:
                self.show()
        conn.close()
Ejemplo n.º 4
0
    def btn2_clk(self):
        roomnumber = int(self.le1.text())
        keyintoroom = int(self.le2.text())
        cur, conn = DataBaseRelated.ini()

        if not DataBaseRelated.search_room(roomnumber,cur):
            DataBaseRelated.newroom(roomnumber,keyintoroom,self.currentuser,cur,conn)
            self.hide()
            self.window3 = temproom.Dialog(self.currentuser, roomnumber)
            self.window3.show()

        else:
            buttonReply = QMessageBox.question(self, 'temproom', "房间已被占用,请重新建立", QMessageBox.Yes)
            if buttonReply == QMessageBox.Yes:
                self.show()



        conn.close()
Ejemplo n.º 5
0
    def btn1_clk(self):
        username=str(self.le1.text())
        password=str(self.le2.text())
        cur,conn=DataBaseRelated.ini()
        if DataBaseRelated.signin(username,password,cur)==0:
                self.hide()
                self.window2=w2.Window(username)
                self.window2.show()

        elif DataBaseRelated.signin(username,password,cur)==1:
            buttonReply = QMessageBox.question(self, 'temproom', "密码错误,请重新登录", QMessageBox.Yes)
            if buttonReply==QMessageBox.Yes:
                self.show()

        elif DataBaseRelated.signin(username,password,cur)==2:
            buttonReply = QMessageBox.question(self, 'temproom', "不存在此用户,请注册", QMessageBox.Yes)
            if buttonReply == QMessageBox.Yes:
                self.show()
        conn.close()
Ejemplo n.º 6
0
    def btn1_clk(self):
        roomnumber = int(self.le1.text())
        keyintoroom = int(self.le2.text())
        cur, conn = DataBaseRelated.ini()
        if DataBaseRelated.getinroom(self.currentuser, roomnumber, keyintoroom, cur, conn)==0:
            self.hide()
            self.window3 = temproom.Dialog(self.currentuser,roomnumber)
            self.window3.show()

        elif DataBaseRelated.getinroom(self.currentuser, roomnumber, keyintoroom, cur, conn)==1:
            buttonReply = QMessageBox.question(self, 'temproom', "房间密钥错误,请核对后输入", QMessageBox.Yes)
            if buttonReply == QMessageBox.Yes:
                self.show()

        elif DataBaseRelated.getinroom(self.currentuser, roomnumber, keyintoroom, cur, conn) ==2:
            buttonReply = QMessageBox.question(self, 'temproom', "不存在此房间,请新建", QMessageBox.Yes)
            if buttonReply == QMessageBox.Yes:
                self.show()

        conn.close()
Ejemplo n.º 7
0
    def __init__(self,username,roomnumber):
        super(Dialog, self).__init__()
        
        self.l1 = QLabel('当前用户:')
        self.l2 = QLabel('房间号:')
        self.l3 = QLabel(str(username))
        self.l4 = QLabel(str(roomnumber))
        self.b1 = QPushButton('上线')
        self.b2 = QPushButton('下线')
        self.b1.clicked.connect(self.connect)

        # self.b2.clicked.connect(self.b2_click(username,roomnumber))
        self.username=username
        # 调整显示内容
        cur, conn = DataBaseRelated.ini()
        self.number = DataBaseRelated.curretroomusernumber(roomnumber,cur)
        for i in range(self.number):
            result=DataBaseRelated.curretroomusers(roomnumber,cur)
            self.userlist.append(result[i][2])
            self.use = QLabel(str(self.userlist[i]))
            self.user.append(self.use)
        conn.close()







        self.formGroupBox = QGroupBox("本房间内用户")
        layout = QVBoxLayout()
        for i in range(self.number):
            layout.addWidget(self.user[i])
        layout.addStretch()
        self.formGroupBox.setLayout(layout)




        #
        # self.createFormGroupBox()

        v_box = QVBoxLayout()
        

        layout = QGridLayout()  
        # layout.addWidget(self.l1,0,0) 
        # layout.addWidget(self.l3,0,1) 
        # layout.addWidget(self.l2,1,0) 
        # layout.addWidget(self.l4,1,1)


        h_box1 = QHBoxLayout()
        h_box2 = QHBoxLayout()

        h_box1.addWidget(self.l1)
        h_box1.addWidget(self.l3)
        v_box.addLayout(h_box1)

        h_box2.addWidget(self.l2)
        h_box2.addWidget(self.l4)
        v_box.addLayout(h_box2)

        layout.addLayout(v_box,0,0,1,1)
        # self.formGroupBox = QGroupBox("房间内用户")
        layout.addWidget(self.formGroupBox,2,0,5,2)
        layout.addWidget(self.b1,7,1,1,1)
        layout.addWidget(self.b2, 8, 1, 1, 1)
        # layout.addWidget(self.user,2,0,0,2)

        self.setLayout(layout)
        self.setWindowTitle('Temproom')
        self.resize(250,600)
        self.center()

        # self.b1.clicked.connect(self.btn1_clk)
        # self.b2.clicked.connect(self.btn2_clk)

        self.hide()
Ejemplo n.º 8
0
 def b2_click(self,username, roomnumber):
     cur, conn = DataBaseRelated.ini()
     DataBaseRelated.useroffline(username, roomnumber, cur, conn)
     DataBaseRelated.roomoffline(roomnumber, cur, conn)
     conn.close()