Initial work on config update

This commit is contained in:
Christoph Stahl 2025-05-25 10:40:06 +02:00
parent 7ce4586dd2
commit 2bab9c0a11
3 changed files with 31 additions and 3 deletions

View file

@ -155,6 +155,7 @@ class State:
waiting_room: list[Entry] = field(default_factory=list)
recent: list[Entry] = field(default_factory=list)
config: dict[str, Any] = field(default_factory=default_config)
old_config: dict[str, Any] = field(default_factory=default_config)
class Client:
@ -294,6 +295,23 @@ class Client:
"""
self.state.config = default_config() | data
async def send_update_config(self) -> None:
"""
Send the current configuration to the server.
This is used to update the server with the current configuration of the
client. This is done by sending a "update_config" message to the server.
:rtype: None
"""
changes = dict()
for key, value in self.state.config.items():
if key in default_config() and default_config()[key] != value:
changes[key] = value
await self.sio.emit("update_config", self.state.config)
async def handle_skip_current(self, data: dict[str, Any]) -> None:
"""
Handle the "skip-current" message.
@ -602,7 +620,7 @@ class Client:
async def kill_mpv(self) -> None:
"""
Kill the mpv process. Needs to be called in a thread, because of mpv...
Kill the mpv process. Needs to be called in a seperate thread, because of mpv...
See https://github.com/jaseg/python-mpv/issues/114#issuecomment-1214305952
:rtype: None

View file

@ -509,7 +509,6 @@ class GeneralConfig(OptionFrame):
["debug", "info", "warning", "error", "critical"],
config["log_level"],
)
# self.add_bool_option("show_advanced", "Show Advanced Options", config["show_advanced"])
self.simple_options = ["server", "room", "secret"]
@ -575,6 +574,10 @@ class SyngGui(QMainWindow):
)
self.buttons_layout.addWidget(self.print_background_tasks_button)
self.update_config_button = QPushButton("Update Config")
self.update_config_button.clicked.connect(self.update_config)
self.update_config_button.setVisible(False)
self.buttons_layout.addWidget(self.update_config_button)
self.startbutton = QPushButton("Connect")
self.startbutton.clicked.connect(self.start_syng_client)
@ -897,9 +900,16 @@ class SyngGui(QMainWindow):
self.set_client_button_stop()
def set_client_button_stop(self) -> None:
self.update_config_button.setVisible(True)
self.general_config.string_options["server"].setEnabled(False)
self.general_config.string_options["room"].setEnabled(False)
self.startbutton.setText("Disconnect")
def set_client_button_start(self) -> None:
self.general_config.string_options["server"].setEnabled(True)
self.general_config.string_options["room"].setEnabled(True)
self.update_config_button.setVisible(False)
self.startbutton.setText("Connect")
def start_syng_client(self) -> None:

View file

@ -119,7 +119,7 @@ class Queue:
def find_by_name(self, name: str) -> Optional[Entry]:
"""
Find an entry by its performer and return it.
Find the first entry by its performer and return it.
:param name: The name of the performer to search for.
:type name: str