diff --git a/tikka/slots/pyqt/windows/main.py b/tikka/slots/pyqt/windows/main.py index 7f10cd96cf8b13c9511b702846ac82cf2467cdc4..7f873a2aacf336bbe2aeda05085f2067225161e4 100644 --- a/tikka/slots/pyqt/windows/main.py +++ b/tikka/slots/pyqt/windows/main.py @@ -12,6 +12,7 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +import logging import sys from typing import TYPE_CHECKING, Any, List, Optional @@ -506,6 +507,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): :return: """ + logging.debug("create instance of ScanQRCodeWindow") ScanQRCodeWindow(self.application, self).exec_() def open_add_address_window(self) -> None: diff --git a/tikka/slots/pyqt/windows/scan_qr_code.py b/tikka/slots/pyqt/windows/scan_qr_code.py index f30643362fcdb117cacf36f0be8799f5d1c0ce7c..88e1dfbb00fbbabb3a52862062740f3016a29611 100644 --- a/tikka/slots/pyqt/windows/scan_qr_code.py +++ b/tikka/slots/pyqt/windows/scan_qr_code.py @@ -12,6 +12,7 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +import logging import sys from typing import List, Optional @@ -65,16 +66,21 @@ class QRCodeVideoSurface(QAbstractVideoSurface): self.video_label = video_label # initialize the OpenCV QRCode detector + logging.debug( + "Create OpenVC qrcode detector instance with cv2.QRCodeDetector()" + ) self.detector = cv2.QRCodeDetector() def supportedPixelFormats( self, type: QAbstractVideoBuffer.HandleType = QAbstractVideoBuffer.NoHandle ) -> List[QVideoFrame.PixelFormat]: result = [] + logging.debug("supportedPixelFormats Type = %s", type) if type == QtMultimedia.QAbstractVideoBuffer.NoHandle: - result = [ - QtMultimedia.QVideoFrame.Format_RGB32, - ] + logging.debug( + "supportedPixelFormats returns QtMultimedia.QVideoFrame.Format_RGB24" + ) + result = [QtMultimedia.QVideoFrame.Format_RGB24] return result @@ -178,19 +184,26 @@ class ScanQRCodeWindow(QDialog, Ui_ScanQRCodeDialog): self.addressValueLabel.setFont(monospace_font) # fill form - if self.check_camera_availability() is False: + camera_available = self.check_camera_availability() + if camera_available is False: self.errorLabel.setText(self._("No camera available")) else: + logging.debug("Create instance of QCamera()") self.camera = QCamera() + logging.debug("Create instance of QRCodeVideoSurface()") self.video_surface = QRCodeVideoSurface(self.videoLabel) + logging.debug( + "set VideoSurface instance as camera viewfinder with camera.setViewfinder(self.video_surface)" + ) self.camera.setViewfinder(self.video_surface) + logging.debug("Start camera with camera.start()") self.camera.start() # buttons self.buttonBox.button(self.buttonBox.Ok).setEnabled(False) # events - if self.check_camera_availability() is True: + if camera_available is True: self.video_surface.detected.connect(self.qrcode_detected) self.buttonBox.accepted.connect(self.on_accepted_button) self.buttonBox.rejected.connect(self.close) @@ -202,6 +215,7 @@ class ScanQRCodeWindow(QDialog, Ui_ScanQRCodeDialog): :return: """ + logging.debug("Check if there is a webcam : QCameraInfo.availableCameras()") return len(QCameraInfo.availableCameras()) > 0 def qrcode_detected(self, data: str): @@ -246,6 +260,7 @@ class ScanQRCodeWindow(QDialog, Ui_ScanQRCodeDialog): if __name__ == "__main__": + logging.basicConfig(level=logging.DEBUG) qapp = QApplication(sys.argv) application_ = Application(DATA_PATH) ScanQRCodeWindow(application_).exec_()