mirror of
https://github.com/feather-wallet/feather.git
synced 2024-12-22 11:39:25 +00:00
macos: warn if no permission to start camera
This commit is contained in:
parent
7971d0043f
commit
3c4b01d021
5 changed files with 32 additions and 1 deletions
|
@ -68,6 +68,7 @@ $(package)_config_opts += -DINPUT_libudev=no
|
|||
$(package)_config_opts += -DINPUT_mtdev=no
|
||||
$(package)_config_opts += -DINPUT_openssl=linked
|
||||
$(package)_config_opts += -DINPUT_openvg=no
|
||||
$(package)_config_opts += -DINPUT_permissions=yes
|
||||
$(package)_config_opts += -DINPUT_reduce_relocations=no
|
||||
$(package)_config_opts += -DINPUT_schannel=no
|
||||
$(package)_config_opts += -DINPUT_sctp=no
|
||||
|
|
|
@ -299,6 +299,10 @@ if (WITH_SCANNER)
|
|||
)
|
||||
endif()
|
||||
|
||||
if(STATIC AND APPLE)
|
||||
target_link_libraries(feather Qt6::QDarwinCameraPermissionPlugin)
|
||||
endif()
|
||||
|
||||
if(STATIC AND UNIX AND NOT APPLE)
|
||||
target_link_libraries(feather Qt6::QComposePlatformInputContextPlugin)
|
||||
endif()
|
||||
|
|
|
@ -34,6 +34,10 @@ Q_IMPORT_PLUGIN(QXcbIntegrationPlugin)
|
|||
Q_IMPORT_PLUGIN(QComposePlatformInputContextPlugin) // Needed for dead keys on Linux
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_MAC) && defined(STATIC)
|
||||
Q_IMPORT_PLUGIN(QDarwinCameraPermissionPlugin)
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_LINUX) && defined(STACK_TRACE)
|
||||
void signal_handler(int signum) {
|
||||
::signal(signum, SIG_DFL);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "QrCodeScanWidget.h"
|
||||
#include "ui_QrCodeScanWidget.h"
|
||||
|
||||
#include <QPermission>
|
||||
#include <QMediaDevices>
|
||||
#include <QComboBox>
|
||||
|
||||
|
@ -68,7 +69,13 @@ void QrCodeScanWidget::startCapture(bool scan_ur) {
|
|||
m_scan_ur = scan_ur;
|
||||
ui->progressBar_UR->setVisible(m_scan_ur);
|
||||
ui->progressBar_UR->setFormat("Progress: %v%");
|
||||
|
||||
|
||||
if (!getPermission()) {
|
||||
ui->frame_error->setText("No permission to start camera.");
|
||||
ui->frame_error->show();
|
||||
return;
|
||||
}
|
||||
|
||||
if (ui->combo_camera->count() < 1) {
|
||||
ui->frame_error->setText("No cameras found. Attach a camera and press 'Refresh'.");
|
||||
ui->frame_error->show();
|
||||
|
@ -82,6 +89,20 @@ void QrCodeScanWidget::startCapture(bool scan_ur) {
|
|||
}
|
||||
}
|
||||
|
||||
bool QrCodeScanWidget::getPermission() {
|
||||
QCameraPermission cameraPermission;
|
||||
switch (qApp->checkPermission(cameraPermission)) {
|
||||
case Qt::PermissionStatus::Undetermined:
|
||||
qApp->requestPermission(cameraPermission, this,
|
||||
&QrCodeScanWidget::getPermission);
|
||||
return false;
|
||||
case Qt::PermissionStatus::Denied:
|
||||
return false;
|
||||
case Qt::PermissionStatus::Granted:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void QrCodeScanWidget::reset() {
|
||||
this->decodedString = "";
|
||||
m_done = false;
|
||||
|
|
|
@ -49,6 +49,7 @@ private:
|
|||
void refreshCameraList();
|
||||
QImage videoFrameToImage(const QVideoFrame &videoFrame);
|
||||
void handleFrameCaptured(const QVideoFrame &videoFrame);
|
||||
bool getPermission();
|
||||
|
||||
QScopedPointer<Ui::QrCodeScanWidget> ui;
|
||||
|
||||
|
|
Loading…
Reference in a new issue