Skip to content

Commit

Permalink
more stable partial fix for issue #6
Browse files Browse the repository at this point in the history
  • Loading branch information
arterialist committed May 26, 2018
1 parent 8c6abc5 commit 5af8dfd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
15 changes: 3 additions & 12 deletions callback/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,13 @@ def new_message_callback(packet, window):


def invalid_message_callback(reason, message):
client_base.invalid_message_callback = None
alert_box = QMessageBox()
alert_box.setWindowTitle("Invalid message received")
alert_box.setText("Reason:\n{}".format(reason))
alert_box.addButton("View", QMessageBox.ActionRole)
alert_box.setText("Reason:\n{}\n\nMessage:\n{}".format(reason, message))
alert_box.setStandardButtons(QMessageBox.Ok)
alert_box.buttonClicked.connect(lambda btn: view_button_clicked_callback(btn, message))
alert_box.exec_()


def view_button_clicked_callback(button, message):
if button.text() == "View":
alert_box = QMessageBox()
alert_box.setWindowTitle("Message")
alert_box.setText(message)
alert_box.addButton("Ok", QMessageBox.YesRole)
alert_box.exec_()
client_base.invalid_message_callback = invalid_message_callback


def delete_dialog_callback(peer_id):
Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def init_ui(self):

client_base.init_socket()
client_base.new_message_callback = lambda message: new_message_callback(message, window)
client_base.invalid_message_callback = lambda reason, message: invalid_message_callback(reason, message)
client_base.invalid_message_callback = invalid_message_callback

def closeEvent(self, a0: QCloseEvent):
client_base.finish()
Expand Down

0 comments on commit 5af8dfd

Please sign in to comment.