|
|
|
@ -30,44 +30,49 @@ class ScanQRTextEdit(ButtonsTextEdit, MessageBoxMixin): |
|
|
|
*, |
|
|
|
*, |
|
|
|
config: SimpleConfig, |
|
|
|
config: SimpleConfig, |
|
|
|
setText: Callable[[str], None] = None, |
|
|
|
setText: Callable[[str], None] = None, |
|
|
|
|
|
|
|
is_payto = False, |
|
|
|
): |
|
|
|
): |
|
|
|
ButtonsTextEdit.__init__(self, text) |
|
|
|
ButtonsTextEdit.__init__(self, text) |
|
|
|
self.setReadOnly(False) |
|
|
|
self.setReadOnly(False) |
|
|
|
|
|
|
|
self.on_qr_from_camera_input_btn = partial( |
|
|
|
input_qr_from_camera = partial( |
|
|
|
|
|
|
|
self.input_qr_from_camera, |
|
|
|
self.input_qr_from_camera, |
|
|
|
config=config, |
|
|
|
config=config, |
|
|
|
allow_multi=allow_multi, |
|
|
|
allow_multi=allow_multi, |
|
|
|
show_error=self.show_error, |
|
|
|
show_error=self.show_error, |
|
|
|
setText=setText, |
|
|
|
setText=setText, |
|
|
|
) |
|
|
|
) |
|
|
|
self.on_qr_from_camera_input_btn = input_qr_from_camera |
|
|
|
self.on_qr_from_screenshot_input_btn = partial( |
|
|
|
|
|
|
|
|
|
|
|
input_qr_from_screenshot = partial( |
|
|
|
|
|
|
|
self.input_qr_from_screenshot, |
|
|
|
self.input_qr_from_screenshot, |
|
|
|
allow_multi=allow_multi, |
|
|
|
allow_multi=allow_multi, |
|
|
|
show_error=self.show_error, |
|
|
|
show_error=self.show_error, |
|
|
|
setText=setText, |
|
|
|
setText=setText, |
|
|
|
) |
|
|
|
) |
|
|
|
self.on_qr_from_screenshot_input_btn = input_qr_from_screenshot |
|
|
|
self.on_input_file = partial( |
|
|
|
|
|
|
|
self.input_file, |
|
|
|
input_file = partial(self.input_file, config=config, show_error=self.show_error, setText=setText) |
|
|
|
config=config, |
|
|
|
|
|
|
|
show_error=self.show_error, |
|
|
|
|
|
|
|
setText=setText, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
# for send tab, buttons are available in the toolbar |
|
|
|
|
|
|
|
if not is_payto: |
|
|
|
|
|
|
|
self.add_input_buttons(config, allow_multi, setText) |
|
|
|
|
|
|
|
run_hook('scan_text_edit', self) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def add_input_buttons(self, config, allow_multi, setText): |
|
|
|
self.add_menu_button( |
|
|
|
self.add_menu_button( |
|
|
|
options=[ |
|
|
|
options=[ |
|
|
|
("picture_in_picture.png", _("Read QR code from screen"), input_qr_from_screenshot), |
|
|
|
("picture_in_picture.png", _("Read QR code from screen"), self.on_qr_from_screenshot_input_btn), |
|
|
|
("file.png", _("Read file"), input_file), |
|
|
|
("file.png", _("Read file"), self.on_input_file), |
|
|
|
], |
|
|
|
], |
|
|
|
) |
|
|
|
) |
|
|
|
self.add_qr_input_from_camera_button(config=config, show_error=self.show_error, allow_multi=allow_multi, setText=setText) |
|
|
|
self.add_qr_input_from_camera_button(config=config, show_error=self.show_error, allow_multi=allow_multi, setText=setText) |
|
|
|
|
|
|
|
|
|
|
|
run_hook('scan_text_edit', self) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def contextMenuEvent(self, e): |
|
|
|
def contextMenuEvent(self, e): |
|
|
|
m = self.createStandardContextMenu() |
|
|
|
m = self.createStandardContextMenu() |
|
|
|
m.addSeparator() |
|
|
|
m.addSeparator() |
|
|
|
m.addAction(read_QIcon(get_iconname_camera()), _("Read QR code from camera"), self.on_qr_from_camera_input_btn) |
|
|
|
m.addAction(read_QIcon(get_iconname_camera()), _("Read QR code with camera"), self.on_qr_from_camera_input_btn) |
|
|
|
m.addAction(read_QIcon("picture_in_picture.png"), _("Read QR code from screen"), self.on_qr_from_screenshot_input_btn) |
|
|
|
m.addAction(read_QIcon("picture_in_picture.png"), _("Read QR code from screen"), self.on_qr_from_screenshot_input_btn) |
|
|
|
|
|
|
|
m.addAction(read_QIcon("file.png"), _("Read file"), self.on_input_file) |
|
|
|
m.exec_(e.globalPos()) |
|
|
|
m.exec_(e.globalPos()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|