From 029ff8999a5d3c1613302b805228cd6927b4dddb Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Mon, 3 Aug 2026 18:22:04 +0800 Subject: qml: reset component when current state broke via new input --- qml_plugin/src/launcher/smartcalc.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'qml_plugin/src/launcher/smartcalc.rs') diff --git a/qml_plugin/src/launcher/smartcalc.rs b/qml_plugin/src/launcher/smartcalc.rs index eee975d..9e94f77 100644 --- a/qml_plugin/src/launcher/smartcalc.rs +++ b/qml_plugin/src/launcher/smartcalc.rs @@ -35,6 +35,9 @@ mod qobject { #[qinvokable] fn reset(self: Pin<&mut SmartCalc>); + + #[qinvokable] + fn reset_result(self: Pin<&mut SmartCalc>); } impl cxx_qt::Threading for SmartCalc {} @@ -127,11 +130,15 @@ impl qobject::SmartCalc { } fn reset(mut self: Pin<&mut Self>) { + self.as_mut() + .set_cached_query(QVariant::default()); + self.reset_result(); + } + + fn reset_result(mut self: Pin<&mut Self>) { self.as_mut() .set_result(QVariant::default()); self.as_mut() .set_result_type(qobject::ResultType::Unset); - self.as_mut() - .set_cached_query(QVariant::default()); } } -- cgit v1.2.3