mirror of
https://github.com/feather-wallet/feather.git
synced 2024-12-22 19:49:28 +00:00
macOS: fix camera permissions
This commit is contained in:
parent
195fc00e6c
commit
b83015b22c
4 changed files with 39 additions and 41 deletions
|
@ -302,19 +302,6 @@ add_subdirectory(src)
|
||||||
|
|
||||||
configure_file("${CMAKE_SOURCE_DIR}/contrib/installers/windows/setup.nsi.in" "${CMAKE_SOURCE_DIR}/contrib/installers/windows/setup.nsi" @ONLY)
|
configure_file("${CMAKE_SOURCE_DIR}/contrib/installers/windows/setup.nsi.in" "${CMAKE_SOURCE_DIR}/contrib/installers/windows/setup.nsi" @ONLY)
|
||||||
|
|
||||||
if(APPLE)
|
|
||||||
configure_file(${CMAKE_SOURCE_DIR}/contrib/macdeploy/Info.plist.in ${CMAKE_SOURCE_DIR}/contrib/macdeploy/Info.plist @ONLY)
|
|
||||||
|
|
||||||
set_target_properties(feather PROPERTIES
|
|
||||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
|
|
||||||
MACOSX_BUNDLE TRUE
|
|
||||||
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_SOURCE_DIR}/contrib/macdeploy/Info.plist"
|
|
||||||
LINK_FLAGS_RELEASE -s
|
|
||||||
)
|
|
||||||
|
|
||||||
file(COPY "${CMAKE_SOURCE_DIR}/src/assets/images/appicons/appicon.icns" DESTINATION "${CMAKE_SOURCE_DIR}/installed/feather.app/Contents/Resources/" )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#### Summary ####
|
#### Summary ####
|
||||||
|
|
||||||
message("\n")
|
message("\n")
|
||||||
|
|
|
@ -251,7 +251,7 @@ if (DEPENDS)
|
||||||
target_link_directories(feather PRIVATE "${LIB_DIR}")
|
target_link_directories(feather PRIVATE "${LIB_DIR}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(feather
|
target_link_libraries(feather PRIVATE
|
||||||
wallet_merged
|
wallet_merged
|
||||||
${LMDB_LIBRARY}
|
${LMDB_LIBRARY}
|
||||||
epee
|
epee
|
||||||
|
@ -280,19 +280,19 @@ target_link_libraries(feather
|
||||||
)
|
)
|
||||||
|
|
||||||
if(CHECK_UPDATES)
|
if(CHECK_UPDATES)
|
||||||
target_link_libraries(feather openpgp)
|
target_link_libraries(feather PRIVATE openpgp)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(DEPENDS)
|
if(DEPENDS)
|
||||||
target_link_libraries(feather ${ICONV_LIBRARIES})
|
target_link_libraries(feather PRIVATE ${ICONV_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(DEVICE_TREZOR_READY)
|
if(DEVICE_TREZOR_READY)
|
||||||
target_link_libraries(feather ${TREZOR_DEP_LIBS})
|
target_link_libraries(feather PRIVATE ${TREZOR_DEP_LIBS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (WITH_SCANNER)
|
if (WITH_SCANNER)
|
||||||
target_link_libraries(feather
|
target_link_libraries(feather PRIVATE
|
||||||
Qt::Multimedia
|
Qt::Multimedia
|
||||||
Qt::MultimediaWidgets
|
Qt::MultimediaWidgets
|
||||||
${ZXING_LIBRARIES}
|
${ZXING_LIBRARIES}
|
||||||
|
@ -300,16 +300,16 @@ if (WITH_SCANNER)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(STATIC AND APPLE)
|
if(STATIC AND APPLE)
|
||||||
target_link_libraries(feather Qt6::QDarwinCameraPermissionPlugin)
|
target_link_libraries(feather PRIVATE Qt6::QDarwinCameraPermissionPlugin)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(STATIC AND UNIX AND NOT APPLE)
|
if(STATIC AND UNIX AND NOT APPLE)
|
||||||
target_link_libraries(feather Qt6::QComposePlatformInputContextPlugin)
|
target_link_libraries(feather PRIVATE Qt6::QComposePlatformInputContextPlugin)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(DEPENDS AND APPLE)
|
if(DEPENDS AND APPLE)
|
||||||
# TODO: Needed for ___isOSVersionAtLeast
|
# TODO: Needed for ___isOSVersionAtLeast
|
||||||
target_link_libraries(feather
|
target_link_libraries(feather PRIVATE
|
||||||
${CMAKE_OSX_SYSROOT}/lib/darwin/libclang_rt.osx.a)
|
${CMAKE_OSX_SYSROOT}/lib/darwin/libclang_rt.osx.a)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -334,4 +334,19 @@ else()
|
||||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/assets/feather.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications)
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/assets/feather.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications)
|
||||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/assets/images/appicons/256x256.png DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/256x256/apps RENAME "feather.png")
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/assets/images/appicons/256x256.png DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/256x256/apps RENAME "feather.png")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(APPLE)
|
||||||
|
configure_file(${CMAKE_SOURCE_DIR}/contrib/macdeploy/Info.plist.in ${CMAKE_SOURCE_DIR}/contrib/macdeploy/Info.plist @ONLY)
|
||||||
|
|
||||||
|
set_target_properties(feather PROPERTIES
|
||||||
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
|
||||||
|
MACOSX_BUNDLE TRUE
|
||||||
|
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_SOURCE_DIR}/contrib/macdeploy/Info.plist"
|
||||||
|
LINK_FLAGS_RELEASE -s
|
||||||
|
)
|
||||||
|
|
||||||
|
file(COPY "${CMAKE_SOURCE_DIR}/src/assets/images/appicons/appicon.icns" DESTINATION "${CMAKE_SOURCE_DIR}/installed/feather.app/Contents/Resources/" )
|
||||||
|
endif()
|
||||||
|
|
||||||
|
qt_finalize_executable(feather)
|
|
@ -70,10 +70,21 @@ void QrCodeScanWidget::startCapture(bool scan_ur) {
|
||||||
ui->progressBar_UR->setVisible(m_scan_ur);
|
ui->progressBar_UR->setVisible(m_scan_ur);
|
||||||
ui->progressBar_UR->setFormat("Progress: %v%");
|
ui->progressBar_UR->setFormat("Progress: %v%");
|
||||||
|
|
||||||
if (!getPermission()) {
|
QCameraPermission cameraPermission;
|
||||||
ui->frame_error->setText("No permission to start camera.");
|
switch (qApp->checkPermission(cameraPermission)) {
|
||||||
ui->frame_error->show();
|
case Qt::PermissionStatus::Undetermined:
|
||||||
return;
|
qDebug() << "Camera permission undetermined";
|
||||||
|
qApp->requestPermission(cameraPermission, [this] {
|
||||||
|
startCapture(m_scan_ur);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
case Qt::PermissionStatus::Denied:
|
||||||
|
ui->frame_error->setText("No permission to start camera.");
|
||||||
|
ui->frame_error->show();
|
||||||
|
return;
|
||||||
|
case Qt::PermissionStatus::Granted:
|
||||||
|
qDebug() << "Camera permission granted";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ui->combo_camera->count() < 1) {
|
if (ui->combo_camera->count() < 1) {
|
||||||
|
@ -89,20 +100,6 @@ 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() {
|
void QrCodeScanWidget::reset() {
|
||||||
this->decodedString = "";
|
this->decodedString = "";
|
||||||
m_done = false;
|
m_done = false;
|
||||||
|
|
|
@ -49,7 +49,6 @@ private:
|
||||||
void refreshCameraList();
|
void refreshCameraList();
|
||||||
QImage videoFrameToImage(const QVideoFrame &videoFrame);
|
QImage videoFrameToImage(const QVideoFrame &videoFrame);
|
||||||
void handleFrameCaptured(const QVideoFrame &videoFrame);
|
void handleFrameCaptured(const QVideoFrame &videoFrame);
|
||||||
bool getPermission();
|
|
||||||
|
|
||||||
QScopedPointer<Ui::QrCodeScanWidget> ui;
|
QScopedPointer<Ui::QrCodeScanWidget> ui;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue