diff --git a/client/gui.py b/client/gui.py index 5cf5c64..3baab77 100644 --- a/client/gui.py +++ b/client/gui.py @@ -108,6 +108,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): cursor = self.messageBox.textCursor() cursor.setPosition(0) self.messageBox.setTextCursor(cursor) + return True return super().eventFilter(obj, event) def addMessage(self, nickname: str, message: str, color: str, time: int) -> None: diff --git a/constants.py b/constants.py index 34ac28a..e5cd066 100644 --- a/constants.py +++ b/constants.py @@ -3,6 +3,7 @@ from typing import List import webcolors HEADER_LENGTH = 10 +MINIMUM_CONTRAST = 4.65 class Types: diff --git a/server/commands.py b/server/commands.py index 9ee1544..343b15a 100644 --- a/server/commands.py +++ b/server/commands.py @@ -70,7 +70,7 @@ class CommandHandler: logger.error(f'Could not process client {self.client.nickname}\'s command request.', exc_info=e) return 'A fatal error occurred while trying to process this command.' - def reroll(self, minimum_contrast: float = 4.65) -> str: + def reroll(self, minimum_contrast: float = constants.MINIMUM_CONTRAST) -> str: """ Randomly change the client's color to a different color. """ diff --git a/server/handler.py b/server/handler.py index 568d35f..ef586b9 100644 --- a/server/handler.py +++ b/server/handler.py @@ -26,7 +26,7 @@ class Client: self.id = str(uuid.uuid4()) self.nickname = self.id[:8] - self.color = random.choice(constants.Colors.ALL) + self.color = random.choice(constants.Colors.has_contrast(float(constants.MINIMUM_CONTRAST))) self.command = CommandHandler(self) self.first_seen = time.time()