Add ability to toggle and resize chat bar
This commit is contained in:
@@ -4,7 +4,7 @@ import html
|
||||
import re
|
||||
from PyQt6.QtWidgets import (
|
||||
QWidget, QVBoxLayout, QHBoxLayout, QLabel, QLineEdit,
|
||||
QPushButton, QFrame, QSlider, QTextEdit, QTextBrowser, QApplication, QToolTip
|
||||
QPushButton, QFrame, QSlider, QTextEdit, QTextBrowser, QApplication, QToolTip, QSplitter
|
||||
)
|
||||
from PyQt6.QtCore import Qt, pyqtSignal, QTimer
|
||||
from PyQt6.QtGui import QIcon, QCursor
|
||||
@@ -81,10 +81,21 @@ class RoomWidget(QWidget):
|
||||
self._setup_ui()
|
||||
|
||||
def _setup_ui(self):
|
||||
layout = QHBoxLayout(self)
|
||||
layout = QVBoxLayout(self)
|
||||
layout.setContentsMargins(0, 0, 0, 0)
|
||||
layout.setSpacing(0)
|
||||
|
||||
self.splitter = QSplitter(Qt.Orientation.Horizontal)
|
||||
self.splitter.setHandleWidth(3)
|
||||
self.splitter.setStyleSheet("""
|
||||
QSplitter::handle {
|
||||
background-color: #333;
|
||||
}
|
||||
QSplitter::handle:hover {
|
||||
background-color: #3ea6ff;
|
||||
}
|
||||
""")
|
||||
|
||||
# --- Left Side: Video ---
|
||||
video_container = QWidget()
|
||||
video_layout = QVBoxLayout(video_container)
|
||||
@@ -171,6 +182,14 @@ class RoomWidget(QWidget):
|
||||
controls_layout.addSpacing(10)
|
||||
controls_layout.addWidget(self.fullscreen_btn)
|
||||
|
||||
# Chat toggle
|
||||
self.chat_toggle_btn = QPushButton("💬")
|
||||
self.chat_toggle_btn.setFixedSize(40, 40)
|
||||
self.chat_toggle_btn.setObjectName("iconBtn")
|
||||
self.chat_toggle_btn.setToolTip("Toggle Chat")
|
||||
self.chat_toggle_btn.clicked.connect(self.toggle_chat)
|
||||
controls_layout.addWidget(self.chat_toggle_btn)
|
||||
|
||||
video_layout.addWidget(self.topbar)
|
||||
video_layout.addWidget(self.video_frame)
|
||||
video_layout.addWidget(self.controls_bar)
|
||||
@@ -178,7 +197,8 @@ class RoomWidget(QWidget):
|
||||
# --- Right Side: Chat ---
|
||||
self.chat_container = QFrame()
|
||||
self.chat_container.setObjectName("chatContainer")
|
||||
self.chat_container.setFixedWidth(320)
|
||||
self.chat_container.setMinimumWidth(200)
|
||||
self.chat_container.setMaximumWidth(500)
|
||||
chat_layout = QVBoxLayout(self.chat_container)
|
||||
|
||||
chat_header = QLabel("Live Chat")
|
||||
@@ -257,12 +277,17 @@ class RoomWidget(QWidget):
|
||||
chat_layout.addWidget(self.chat_messages, 1)
|
||||
chat_layout.addLayout(chat_input_layout)
|
||||
|
||||
layout.addWidget(video_container, 1)
|
||||
layout.addWidget(self.chat_container)
|
||||
self.splitter.addWidget(video_container)
|
||||
self.splitter.addWidget(self.chat_container)
|
||||
self.splitter.setStretchFactor(0, 1)
|
||||
self.splitter.setStretchFactor(1, 0)
|
||||
self.splitter.setSizes([700, 320])
|
||||
|
||||
layout.addWidget(self.splitter)
|
||||
|
||||
# Prevent UI components from stealing focus (which breaks spacebar shortcuts)
|
||||
for w in [self.copy_code_btn, self.leave_btn, self.play_btn, self.fullscreen_btn,
|
||||
self.chat_send_btn, self.seekbar, self.volume_slider, self.tags_header_btn]:
|
||||
self.chat_send_btn, self.seekbar, self.volume_slider, self.tags_header_btn, self.chat_toggle_btn]:
|
||||
w.setFocusPolicy(Qt.FocusPolicy.NoFocus)
|
||||
|
||||
# specifically for chat_messages, we allow clicking links, but avoid focus stealing
|
||||
@@ -326,6 +351,16 @@ class RoomWidget(QWidget):
|
||||
self.tags_list.hide()
|
||||
self.tags_header_btn.setText("▶ Highlights")
|
||||
|
||||
def toggle_chat(self):
|
||||
if self.chat_container.isVisible():
|
||||
self._saved_chat_width = self.chat_container.width()
|
||||
self.chat_container.hide()
|
||||
else:
|
||||
self.chat_container.show()
|
||||
w = getattr(self, '_saved_chat_width', 320)
|
||||
sizes = self.splitter.sizes()
|
||||
self.splitter.setSizes([sizes[0] - w, w])
|
||||
|
||||
def toggle_fullscreen(self):
|
||||
top_window = self.window()
|
||||
if top_window.isFullScreen():
|
||||
|
||||
Reference in New Issue
Block a user