mirror of
https://github.com/Xevion/tcp-chat.git
synced 2025-12-06 03:16:44 -06:00
switch to type/request based JSON messages, improve GUI, add proper nickname dialog
This commit is contained in:
35
client/dialog.py
Normal file
35
client/dialog.py
Normal 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()
|
||||
Reference in New Issue
Block a user