Skip to content

Commit dd1a789

Browse files
Camera app: improve cleanup after QR scan
1 parent 1240a9f commit dd1a789

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

internal_filesystem/lib/mpos/ui/camera_activity.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,13 @@ def qrdecode_one(self):
262262
result = self.remove_bom(result)
263263
result = self.print_qr_buffer(result)
264264
print(f"QR decoding found: {result}")
265-
self.stop_qr_decoding()
266265
if self.scanqr_intent:
266+
self.stop_qr_decoding(activate_non_qr_mode=False)
267267
self.setResult(True, result)
268268
self.finish()
269269
else:
270270
self.status_label.set_text(result) # in the future, the status_label text should be copy-paste-able
271+
self.stop_qr_decoding()
271272

272273
def snap_button_click(self, e):
273274
print("Taking picture...")
@@ -323,23 +324,20 @@ def start_qr_decoding(self):
323324
self.status_label_cont.remove_flag(lv.obj.FLAG.HIDDEN)
324325
self.status_label.set_text(self.STATUS_SEARCHING_QR)
325326

326-
def stop_qr_decoding(self):
327+
def stop_qr_decoding(self, activate_non_qr_mode=True):
327328
print("Deactivating live QR decoding...")
328329
self.scanqr_mode = False
329330
self.qr_label.set_text(lv.SYMBOL.EYE_OPEN)
330331
status_label_text = self.status_label.get_text()
331332
if status_label_text in (self.STATUS_NO_CAMERA, self.STATUS_SEARCHING_QR, self.STATUS_FOUND_QR): # if it found a QR code, leave it
332333
self.status_label_cont.add_flag(lv.obj.FLAG.HIDDEN)
333334
# Check if it's necessary to restart the camera:
334-
oldwidth = self.width
335-
oldheight = self.height
336-
oldcolormode = self.colormode
337-
# Activate non-QR mode settings
335+
if activate_non_qr_mode is False:
336+
return
337+
# Instead of checking if any setting changed, just reload and restart the camera:
338338
self.load_settings_cached()
339-
# Check if it's necessary to restart the camera:
340-
if self.width != oldwidth or self.height != oldheight or self.colormode != oldcolormode:
341-
self.stop_cam()
342-
self.start_cam()
339+
self.stop_cam()
340+
self.start_cam()
343341

344342
def qr_button_click(self, e):
345343
if not self.scanqr_mode:

0 commit comments

Comments
 (0)