Added copy config menu option

This commit is contained in:
Artem30801
2020-02-05 14:37:36 +03:00
parent 0bb3fd1b72
commit a2b087fcd9
2 changed files with 22 additions and 3 deletions

View File

@@ -216,8 +216,10 @@ def _command_config_write(*args, **kwargs):
@messaging.request_callback("config")
def _response_config(*args, **kwargs):
response = {"config": active_client.config.full_dict(),
"configspec": dict(active_client.config.config.configspec)}
send_configspec = kwargs.get("send_configspec", False)
response = {"config": active_client.config.full_dict()}
if send_configspec:
response.update({"configspec": dict(active_client.config.config.configspec)})
return response
@messaging.request_callback("id")

View File

@@ -145,6 +145,10 @@ class CopterTableWidget(QTableView):
edit_config.triggered.connect(partial(self.edit_copter_config, item))
menu.addAction(edit_config)
copy_config = QAction("Copy config to selected")
copy_config.triggered.connect(partial(self.copy_config, item))
menu.addAction(copy_config)
if item is None:
edit_config.setDisabled(True)
@@ -153,7 +157,20 @@ class CopterTableWidget(QTableView):
@pyqtSlot()
def edit_copter_config(self, copter):
dialog = ConfigDialog()
copter.client.get_response("config", dialog.call_copter_dialog)
copter.client.get_response("config", dialog.call_copter_dialog, request_kwargs={'send_configspec': True})
@pyqtSlot()
def copy_config(self, copter):
def send_callback(client, value):
config = value["config"]
config.pop("PRIVATE", None) # delete private section
for _copter in self.model.user_selected():
if _copter.client is client:
continue # don't send config back to the same copter
_copter.client.send_message("config", kwargs={"config": config, "mode": "modify"})
copter.client.get_response("config", send_callback, request_kwargs={'send_configspec': False})
# def _selfcheck_shortener(self, data): # TODO!!!
# shortened = []