Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show differences when local and remote paramters do not match #400

Merged
merged 5 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions linien-gui/linien_gui/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ def __init__(self, parent: QWidget, host: str):
self.setStandardButtons(QMessageBox.NoButton)
self.show()

def closeEvent(self, *args):
def closeEvent(self, *args) -> None:
self.aborted.emit()

def keyPressEvent(self, event):
def keyPressEvent(self, event) -> None:
key = event.key()
if key == QtCore.Qt.Key_Escape:
self.close()
Expand All @@ -110,7 +110,7 @@ def error_dialog(parent: QWidget, error):
return QMessageBox.question(parent, "Error", error, QMessageBox.Ok, QMessageBox.Ok)


def question_dialog(parent, question, title):
def question_dialog(parent, question: str, title: str) -> bool:
box = QMessageBox(parent)
box.setText(question)
box.setWindowTitle(title)
Expand All @@ -121,12 +121,11 @@ def question_dialog(parent, question, title):
return reply == QMessageBox.Yes


def ask_for_parameter_restore_dialog(parent, question, title):
def ask_for_parameter_restore_dialog(parent, question: str, title: str) -> bool:
box = QMessageBox(parent)
box.setText(question)
box.setWindowTitle(title)
# do_nothing_button
_ = box.addButton("Keep remote parameters", QMessageBox.NoRole)
_ = box.addButton("Keep remote parameters", QMessageBox.NoRole) # do nothing
upload_button = box.addButton("Upload local parameters", QMessageBox.YesRole)

box.exec_()
Expand Down
6 changes: 5 additions & 1 deletion linien-gui/linien_gui/ui/device_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,13 @@ def ask_for_parameter_restore(
"only saved if Linien server was shut down properly, not when "
"unplugging the power plug. In this case, you should update your local "
"parameters."
"\n"
"The following parameters changed (local ↔ remote):"
)
for param_name, (local_value, remote_value) in parameter_difference.items():
question += f"\n{param_name}:\n {local_value} ↔ {remote_value}"
should_restore = ask_for_parameter_restore_dialog(
self, question, "Restore parameters?"
self, question, title="Restore parameters?"
)
if should_restore:
self.connection_thread.restore_parameters(parameter_difference)
Expand Down