Auto fill room ID from clip board upon interacting with input
This commit is contained in:
@@ -1,10 +1,25 @@
|
||||
import os
|
||||
import re
|
||||
from PyQt6.QtWidgets import (
|
||||
QWidget, QVBoxLayout, QHBoxLayout, QLabel, QLineEdit, QPushButton,
|
||||
QFileDialog, QFrame
|
||||
QFileDialog, QFrame, QApplication
|
||||
)
|
||||
from PyQt6.QtCore import Qt, pyqtSignal
|
||||
|
||||
class RoomCodeInput(QLineEdit):
|
||||
"""QLineEdit that auto-fills from clipboard if it looks like a room code."""
|
||||
def focusInEvent(self, event):
|
||||
super().focusInEvent(event)
|
||||
if not self.text().strip():
|
||||
self._try_paste_room_code()
|
||||
|
||||
def _try_paste_room_code(self):
|
||||
clipboard = QApplication.clipboard()
|
||||
text = (clipboard.text() or "").strip().upper()
|
||||
if re.match(r'^[A-Z0-9]{4,8}$', text):
|
||||
self.setText(text)
|
||||
self.selectAll()
|
||||
|
||||
class LobbyWidget(QWidget):
|
||||
# Signals to communicate to VlcSyncApp
|
||||
create_requested = pyqtSignal(str, str, str, object) # username, path, filename, size
|
||||
@@ -80,7 +95,7 @@ class LobbyWidget(QWidget):
|
||||
# Join Room Panel
|
||||
join_panel = QVBoxLayout()
|
||||
join_panel.addWidget(QLabel("Join a Room"))
|
||||
self.room_code_input = QLineEdit()
|
||||
self.room_code_input = RoomCodeInput()
|
||||
self.room_code_input.setPlaceholderText("e.g. ABC123")
|
||||
self.join_room_btn = QPushButton("Join Room")
|
||||
self.join_room_btn.setObjectName("secondaryBtn")
|
||||
|
||||
Reference in New Issue
Block a user