Skip to content
Snippets Groups Projects
Commit 05ea62a8 authored by Vincent Texier's avatar Vincent Texier
Browse files

[enh] #798 source automatically checked when opening transfer dialog

parent 5d2df929
No related branches found
No related tags found
1 merge request!778Release 0.51.0
...@@ -53,7 +53,7 @@ class TransferController(QObject): ...@@ -53,7 +53,7 @@ class TransferController(QObject):
) )
self.view.spinbox_amount.valueChanged.connect(self.handle_amount_change) self.view.spinbox_amount.valueChanged.connect(self.handle_amount_change)
self.view.spinbox_relative.valueChanged.connect(self.handle_relative_change) self.view.spinbox_relative.valueChanged.connect(self.handle_relative_change)
self.view.button_source_check.clicked.connect(self.check_source) self.view.button_source_check.clicked.connect(self.check_source_dialog)
@classmethod @classmethod
def create(cls, parent, app): def create(cls, parent, app):
...@@ -117,7 +117,11 @@ class TransferController(QObject): ...@@ -117,7 +117,11 @@ class TransferController(QObject):
controller.set_amount_value(source.amount, source.base) controller.set_amount_value(source.amount, source.base)
controller.view.spinbox_amount.setDisabled(True) controller.view.spinbox_amount.setDisabled(True)
controller.view.spinbox_relative.setDisabled(True) controller.view.spinbox_relative.setDisabled(True)
controller.view.button_source_check.setEnabled(True) result, _ = controller.check_source(source)
# by default, source is unlocked, if not...
if not result:
# enabled the check button to open the errors dialog
controller.view.button_source_check.setEnabled(True)
else: else:
controller.view.widget_source.hide() controller.view.widget_source.hide()
...@@ -326,9 +330,19 @@ class TransferController(QObject): ...@@ -326,9 +330,19 @@ class TransferController(QObject):
self.password_input.set_connection(self.model.connection) self.password_input.set_connection(self.model.connection)
self.refresh() self.refresh()
def check_source(self): def check_source(self, source):
"""
Check source conditions lock status
Return a tupple with :
result: bool,
errors: list of tuples
[(condition: str, message: str, info: int|str),...]
:param source:
:return tuple:
"""
# evaluate condition # evaluate condition
source = self.model.current_source
condition = pypeg2.parse(source.conditions, Condition) condition = pypeg2.parse(source.conditions, Condition)
result, _errors = self.model.app.sources_service.evaluate_condition( result, _errors = self.model.app.sources_service.evaluate_condition(
self.model.app.currency, self.model.app.currency,
...@@ -337,6 +351,17 @@ class TransferController(QObject): ...@@ -337,6 +351,17 @@ class TransferController(QObject):
[], [],
source.identifier, source.identifier,
) )
return result, _errors
def check_source_dialog(self):
"""
Open check source result and errors dialog
:return:
"""
source = self.model.current_source
result, _errors = self.check_source(source)
# if success... # if success...
if result: if result:
message = QCoreApplication.translate( message = QCoreApplication.translate(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment