Skip to content

Commit

Permalink
47 resetting captured after clicking scan again button added
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusz-fejcher committed Jul 1, 2024
1 parent 4a317d6 commit 4a50c86
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/QmlBarcodeReader/qml/Qt6ScannerPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ ApplicationWindow {

onClicked: {
resultScreen.visible = false
barcodeScanner.resetScanner()
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/SBarcodeDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,11 @@ void SBarcodeDecoder::setResolution(int w, int h)
m_resolution = QSize{w,h};
}

void SBarcodeDecoder::resetCaptured()
{
m_captured = "";
}

void SBarcodeDecoder::setResolution(const QSize& newRes)
{
m_resolution = newRes;
Expand Down
6 changes: 6 additions & 0 deletions src/SBarcodeDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ class SBarcodeDecoder : public QObject
void setResolution(const QSize&);
[[deprecated("Use QSize overload instead")]] void setResolution(int w, int h);

/*!
* \fn resetCaptured()
* \brief Sets captured to empty string.
*/
void resetCaptured();

public slots:
/*!
* \fn void process(const QImage capturedImage, ZXing::BarcodeFormats formats)
Expand Down
7 changes: 7 additions & 0 deletions src/SBarcodeScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,10 @@ void SBarcodeScanner::setForwardVideoSink(QVideoSink *newSink)
m_forwardVideoSink = newSink;
forwardVideoSinkChanged(m_forwardVideoSink);
}

void SBarcodeScanner::resetCaptured()
{
// Setting m_captured outside setCaptured to omit handling capturedChanged signal in QML.
m_captured = "";
m_decoder.resetCaptured();
}
1 change: 1 addition & 0 deletions src/SBarcodeScanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class SBarcodeScanner : public QVideoSink, public QQmlParserStatus
void setCamera(QCamera *newCamera);
void setForwardVideoSink(QVideoSink* sink);
public slots:
void resetCaptured();

signals:
void cameraChanged(QCamera *);
Expand Down

0 comments on commit 4a50c86

Please sign in to comment.