Initial work on config update
This commit is contained in:
parent
7ce4586dd2
commit
2bab9c0a11
3 changed files with 31 additions and 3 deletions
|
@ -155,6 +155,7 @@ class State:
|
||||||
waiting_room: list[Entry] = field(default_factory=list)
|
waiting_room: list[Entry] = field(default_factory=list)
|
||||||
recent: list[Entry] = field(default_factory=list)
|
recent: list[Entry] = field(default_factory=list)
|
||||||
config: dict[str, Any] = field(default_factory=default_config)
|
config: dict[str, Any] = field(default_factory=default_config)
|
||||||
|
old_config: dict[str, Any] = field(default_factory=default_config)
|
||||||
|
|
||||||
|
|
||||||
class Client:
|
class Client:
|
||||||
|
@ -294,6 +295,23 @@ class Client:
|
||||||
"""
|
"""
|
||||||
self.state.config = default_config() | data
|
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:
|
async def handle_skip_current(self, data: dict[str, Any]) -> None:
|
||||||
"""
|
"""
|
||||||
Handle the "skip-current" message.
|
Handle the "skip-current" message.
|
||||||
|
@ -602,7 +620,7 @@ class Client:
|
||||||
|
|
||||||
async def kill_mpv(self) -> None:
|
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
|
See https://github.com/jaseg/python-mpv/issues/114#issuecomment-1214305952
|
||||||
|
|
||||||
:rtype: None
|
:rtype: None
|
||||||
|
|
12
syng/gui.py
12
syng/gui.py
|
@ -509,7 +509,6 @@ class GeneralConfig(OptionFrame):
|
||||||
["debug", "info", "warning", "error", "critical"],
|
["debug", "info", "warning", "error", "critical"],
|
||||||
config["log_level"],
|
config["log_level"],
|
||||||
)
|
)
|
||||||
# self.add_bool_option("show_advanced", "Show Advanced Options", config["show_advanced"])
|
|
||||||
|
|
||||||
self.simple_options = ["server", "room", "secret"]
|
self.simple_options = ["server", "room", "secret"]
|
||||||
|
|
||||||
|
@ -575,6 +574,10 @@ class SyngGui(QMainWindow):
|
||||||
)
|
)
|
||||||
self.buttons_layout.addWidget(self.print_background_tasks_button)
|
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 = QPushButton("Connect")
|
||||||
|
|
||||||
self.startbutton.clicked.connect(self.start_syng_client)
|
self.startbutton.clicked.connect(self.start_syng_client)
|
||||||
|
@ -897,9 +900,16 @@ class SyngGui(QMainWindow):
|
||||||
self.set_client_button_stop()
|
self.set_client_button_stop()
|
||||||
|
|
||||||
def set_client_button_stop(self) -> None:
|
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")
|
self.startbutton.setText("Disconnect")
|
||||||
|
|
||||||
def set_client_button_start(self) -> None:
|
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")
|
self.startbutton.setText("Connect")
|
||||||
|
|
||||||
def start_syng_client(self) -> None:
|
def start_syng_client(self) -> None:
|
||||||
|
|
|
@ -119,7 +119,7 @@ class Queue:
|
||||||
|
|
||||||
def find_by_name(self, name: str) -> Optional[Entry]:
|
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.
|
:param name: The name of the performer to search for.
|
||||||
:type name: str
|
:type name: str
|
||||||
|
|
Loading…
Add table
Reference in a new issue