mirror of
https://github.com/Xevion/tcp-chat.git
synced 2025-12-06 13:16:42 -06:00
fix QStatusBar not updating, ConnectionOptions namedtuple settings func, Connect button basic logic, DEFAULT_IP/PORT
This commit is contained in:
@@ -61,6 +61,24 @@ class ConnectionDialog(QDialog, Ui_ConnectionDialog):
|
||||
|
||||
self.show()
|
||||
|
||||
def connect(self) -> None:
|
||||
self.connect_pressed = True
|
||||
self.close()
|
||||
|
||||
def event(self, event: QEvent) -> bool:
|
||||
if event.type() == QEvent.StatusTip:
|
||||
self.status_bar.showMessage(event.tip())
|
||||
return True
|
||||
return super().event(event)
|
||||
|
||||
@property
|
||||
def settings(self) -> ConnectionOptions:
|
||||
return ConnectionOptions(ip=self.server_address_input.text(),
|
||||
port=int(self.port_input.text()),
|
||||
nickname=self.nickname_input.text(),
|
||||
password=self.password_input.text(),
|
||||
remember=self.remember_checkbox.checkState())
|
||||
|
||||
def validation(self, full: bool = True) -> None:
|
||||
address, port = self.validate_address()
|
||||
|
||||
@@ -84,7 +102,8 @@ class ConnectionDialog(QDialog, Ui_ConnectionDialog):
|
||||
address = self.server_address_input.text() or constants.DEFAULT_IP
|
||||
port = self.port_input.text() or constants.DEFAULT_PORT
|
||||
|
||||
valid_address = len(address) > 0 and re.match(r'^\d{1,4}\.\d{1,4}\.\d{1,4}\.\d{1,4}|localhost$', address) is not None
|
||||
valid_address = len(address) > 0 and re.match(r'^\d{1,4}\.\d{1,4}\.\d{1,4}\.\d{1,4}|localhost$',
|
||||
address) is not None
|
||||
valid_port = len(port) > 0 and re.match(r'^\d{4,5}$', port) is not None and 1024 <= int(port) <= 65536
|
||||
|
||||
return valid_address, valid_port
|
||||
|
||||
@@ -1,8 +1,20 @@
|
||||
from typing import Tuple
|
||||
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
|
||||
from client.dialog import ConnectionDialog
|
||||
from client.gui import MainWindow
|
||||
|
||||
|
||||
# def connection_dialog() -> Tuple[str, int, str, str, bool]:
|
||||
# connect_dialog = ConnectionDialog()
|
||||
|
||||
|
||||
def main():
|
||||
app = QApplication([])
|
||||
app.setApplicationName("TCPChat Client")
|
||||
m = MainWindow()
|
||||
|
||||
connect_dialog = ConnectionDialog()
|
||||
# m = MainWindow()
|
||||
app.exec_()
|
||||
if connect_dialog.connect_pressed:
|
||||
print(connect_dialog.settings)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from typing import List
|
||||
from collections import namedtuple
|
||||
|
||||
import os
|
||||
import webcolors
|
||||
@@ -9,6 +10,11 @@ HEADER_LENGTH = 10
|
||||
MINIMUM_CONTRAST = 4.65
|
||||
DATABASE = os.path.join(__BASE_DIR, 'messages.db')
|
||||
|
||||
DEFAULT_IP = "127.0.0.1"
|
||||
DEFAULT_PORT = "5555"
|
||||
|
||||
ConnectionOptions = namedtuple('ConnectionOptions', ['ip', 'port', 'nickname', 'password', 'remember'])
|
||||
|
||||
|
||||
class Types:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user