From 53c64c134ab67bc4c8435b7ad631aaac19d9c4d6 Mon Sep 17 00:00:00 2001 From: Auric Vente Date: Sat, 20 Jul 2024 02:16:48 -0600 Subject: [PATCH] Mods --- cromulant/config.py | 4 ++++ cromulant/window.py | 35 +++++++++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/cromulant/config.py b/cromulant/config.py index f4eb3ef..9c55e37 100644 --- a/cromulant/config.py +++ b/cromulant/config.py @@ -47,6 +47,10 @@ class Config: message_box_button_hover_background_color: str = "rgb(66, 66, 66)" message_box_button_hover_text_color: str = "white" scrollbar_handle_color: str = "rgb(69, 69, 69)" + input_background_color: str = "rgb(111, 111, 111)" + input_text_color: str = "rgb(18, 18, 18)" + input_border_color: str = "rgb(140, 140, 140)" + input_caret_color: str = "rgb(18, 18, 18)" @staticmethod def prepare() -> None: diff --git a/cromulant/window.py b/cromulant/window.py index c2d57d2..89a60a7 100644 --- a/cromulant/window.py +++ b/cromulant/window.py @@ -16,6 +16,7 @@ from PySide6.QtWidgets import QComboBox from PySide6.QtWidgets import QLayout from PySide6.QtWidgets import QSizePolicy from PySide6.QtWidgets import QMessageBox +from PySide6.QtWidgets import QLineEdit from PySide6.QtGui import QFontDatabase # type: ignore from PySide6.QtGui import QMouseEvent from PySide6.QtGui import QIcon @@ -162,6 +163,12 @@ class Window: background: none; }} + QLineEdit {{ + background-color: {Config.input_background_color}; + color: {Config.input_text_color}; + border: 1px solid {Config.input_border_color}; + }} + """.strip() Window.app.setStyleSheet(style) @@ -199,15 +206,17 @@ class Window: Window.speed.setCurrentIndex(1) Window.speed.currentIndexChanged.connect(Game.update_speed) - btn_top = SpecialButton("Top") - btn_top.setToolTip("Scroll to the top\nMiddle Click to scroll to the bottom") - btn_top.clicked.connect(Window.to_top) - btn_top.middleClicked.connect(Window.to_bottom) + + filter_input = QLineEdit() + filter_input.setToolTip("Filter the updates\nClick to scroll to the top") + filter_input.setFixedWidth(120) + filter_input.setPlaceholderText("Filter") + filter_input.mousePressEvent = lambda e: Window.to_top() container.addWidget(btn_hatch) container.addWidget(btn_terminate) container.addWidget(Window.speed) - container.addWidget(btn_top) + container.addWidget(filter_input) root.setLayout(container) Window.root.addWidget(root) @@ -285,17 +294,27 @@ class Window: Window.scroll_area.verticalScrollBar().maximum() ) + @staticmethod + def toggle_scroll() -> None: + maxim = Window.scroll_area.verticalScrollBar().maximum() + + if Window.scroll_area.verticalScrollBar().value() == maxim: + Window.to_top() + else: + Window.to_bottom() + @staticmethod def add_footer() -> None: root = QWidget() root.setContentsMargins(0, 0, 0, 0) container = QHBoxLayout() Window.info = SpecialButton("---") + Window.info.setToolTip( - "Scroll to the bottom\nMiddle Click to scroll to the top" + "Click to scroll to the bottom or top" ) - Window.info.clicked.connect(Window.to_bottom) - Window.info.middleClicked.connect(Window.to_top) + + Window.info.clicked.connect(Window.toggle_scroll) Window.info.setMinimumSize(35, 35) container.addWidget(Window.info) root.setLayout(container)