Enable webcam QR scanner

This commit is contained in:
tobtoht
2022-12-27 17:46:14 +01:00
parent 68e3f3aecd
commit 23d4b0cd1c
11 changed files with 334 additions and 56 deletions
+14
View File
@@ -14,6 +14,9 @@
#if defined(WITH_SCANNER) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include "qrcode_scanner/QrCodeScanDialog.h"
#include <QtMultimedia/QCameraInfo>
#elif defined(WITH_SCANNER)
#include "qrcode_scanner_qt6/QrCodeScanDialog.h"
#include <QMediaDevices>
#endif
SendWidget::SendWidget(QSharedPointer<AppContext> ctx, QWidget *parent)
@@ -123,6 +126,17 @@ void SendWidget::scanClicked() {
dialog->exec();
ui->lineAddress->setText(dialog->decodedString);
dialog->deleteLater();
#elif defined(WITH_SCANNER)
auto cameras = QMediaDevices::videoInputs();
if (cameras.empty()) {
QMessageBox::warning(this, "QR code scanner", "No available cameras found.");
return;
}
auto dialog = new QrCodeScanDialog(this);
dialog->exec();
ui->lineAddress->setText(dialog->decodedString);
dialog->deleteLater();
#else
QMessageBox::warning(this, "QR scanner", "Feather was built without webcam QR scanner support.");
#endif