Commit d882e95a authored by Samuel GAIST's avatar Samuel GAIST

[widgets][assetwidget] Move load confirmation in own method

This allows to write tests more easily.
parent fbc0ff83
......@@ -394,6 +394,21 @@ class AssetWidget(QWidget):
asset = Asset.from_path(self.prefix_root_path, file_path)
asset.delete()
def confirm_loading(self, errors):
"""Request loading confirmation"""
message_box = QMessageBox(
QMessageBox.Critical,
self.tr("Invalid asset"),
self.tr(f"The asset you are trying to load is invalid."),
)
message_box.setDetailedText(f"{errors}")
message_box.addButton(QMessageBox.Cancel)
load_button = message_box.addButton(QMessageBox.Ignore)
load_button.setText(self.tr("Load anyway"))
return message_box.exec_()
@pyqtSlot(Asset)
def loadAsset(self, asset):
""" Load the content of the file given in parameter
......@@ -412,19 +427,8 @@ class AssetWidget(QWidget):
do_load = False
if not is_valid:
message_box = QMessageBox(
QMessageBox.Critical,
self.tr("Invalid asset"),
self.tr(f"The asset you are trying to load is invalid."),
)
message_box.setDetailedText(f"{errors}")
message_box.addButton(QMessageBox.Cancel)
load_button = message_box.addButton(QMessageBox.Ignore)
load_button.setText(self.tr("Load anyway"))
result = message_box.exec_()
result = self.confirm_loading(errors)
do_load = result == QMessageBox.Ignore
else:
do_load = True
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment