switch to type/request based JSON messages, improve GUI, add proper nickname dialog

This commit is contained in:
Xevion
2021-01-08 18:42:03 -06:00
parent 390595c0e2
commit b792d9cb9c
7 changed files with 326 additions and 233 deletions

35
client/dialog.py Normal file
View File

@@ -0,0 +1,35 @@
from PyQt5.QtWidgets import QDialog
from client.nickname import Ui_NicknameDialog
class NicknameDialog(QDialog, Ui_NicknameDialog):
def __init__(self, *args, **kwargs):
super(NicknameDialog, self).__init__(*args, **kwargs)
self.setupUi(self)
self.disabled = True
self.buttonBox.setDisabled(True)
self.setWindowTitle("Set Nickname")
self.lineEdit.returnPressed.connect(self.trySubmit)
self.lineEdit.textEdited.connect(self.controlSubmit)
self.show()
def controlSubmit(self):
"""Updates whether or not the dialog box is allowed to proceed"""
if len(self.lineEdit.text()) > 2:
if self.disabled:
self.disabled = False
self.buttonBox.setDisabled(False)
else:
if not self.disabled:
self.disabled = True
self.buttonBox.setDisabled(True)
def trySubmit(self):
"""Tries to submit the Dialog through the QLineEdit via Enter key"""
if not self.disabled:
self.accept()