diff --git a/src/corelib/configure.cmake b/src/corelib/configure.cmake index dd89b8ac998..746ac8927ea 100644 --- a/src/corelib/configure.cmake +++ b/src/corelib/configure.cmake @@ -1016,7 +1016,6 @@ qt_feature("permissions" PUBLIC SECTION "Utilities" LABEL "Application permissions" PURPOSE "Provides support for requesting user permission to access restricted data or APIs" - CONDITION APPLE OR ANDROID OR WASM ) qt_configure_add_summary_section(NAME "Qt Core") diff --git a/src/corelib/kernel/qpermissions.cpp b/src/corelib/kernel/qpermissions.cpp index 0d15901948b..46b989c50c2 100644 --- a/src/corelib/kernel/qpermissions.cpp +++ b/src/corelib/kernel/qpermissions.cpp @@ -46,7 +46,6 @@ Q_LOGGING_CATEGORY(lcPermissions, "qt.permissions", QtWarningMsg); \code void VoiceMemoWidget::onRecordingInitiated() { - #if QT_CONFIG(permissions) QMicrophonePermission microphonePermission; switch (qApp->checkPermission(microphonePermission)) { case Qt::PermissionStatus::Undetermined: @@ -57,10 +56,8 @@ Q_LOGGING_CATEGORY(lcPermissions, "qt.permissions", QtWarningMsg); m_permissionInstructionsDialog->show(); return; case Qt::PermissionStatus::Granted: - break; // Proceed + m_microphone->startRecording(); } - #endif - m_microphone->startRecording(); } \endcode @@ -76,9 +73,6 @@ Q_LOGGING_CATEGORY(lcPermissions, "qt.permissions", QtWarningMsg); why we can not record voice memos at this time (if the permission was denied), or proceed to using the microphone (if permission was granted). - The use of the \c{QT_CONFIG(permissions)} macro ensures that the code - will work as before on platforms where permissions are not available. - \note On \macOS and iOS permissions can currently only be requested for GUI applications. @@ -672,6 +666,28 @@ QDebug operator<<(QDebug debug, const QPermission &permission) #undef QT_PERMISSION_IMPL_COMMON +#if !defined(Q_OS_DARWIN) && !defined(Q_OS_ANDROID) && !defined(Q_OS_WASM) +// Default backend for platforms without a permission implementation. +// Always returns Granted, to match behavior when not using permission APIs +// https://bugreports.qt.io/browse/QTBUG-90498?focusedCommentId=725085#comment-725085 +namespace QPermissions::Private +{ + Qt::PermissionStatus checkPermission(const QPermission &permission) + { + qCDebug(lcPermissions) << "No permission backend on this platform." + << "Optimistically returning Granted for" << permission; + return Qt::PermissionStatus::Granted; + } + + void requestPermission(const QPermission &permission, const PermissionCallback &callback) + { + qCDebug(lcPermissions) << "No permission backend on this platform." + << "Optimistically returning Granted for" << permission; + callback(Qt::PermissionStatus::Granted); + } +} +#endif + QT_END_NAMESPACE #include "moc_qpermissions.cpp"