mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-20 22:05:12 +00:00
Move permissions to own file
This commit is contained in:
parent
3c576da42f
commit
4df1f9fb18
8 changed files with 93 additions and 65 deletions
66
rpcs3/rpcs3qt/permissions.cpp
Normal file
66
rpcs3/rpcs3qt/permissions.cpp
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
#include "stdafx.h"
|
||||
#include "permissions.h"
|
||||
|
||||
#include <qglobal.h>
|
||||
|
||||
#if QT_CONFIG(permissions)
|
||||
#include <QApplication>
|
||||
#include <QPermissions>
|
||||
#endif
|
||||
|
||||
LOG_CHANNEL(gui_log, "GUI");
|
||||
LOG_CHANNEL(camera_log, "Camera");
|
||||
|
||||
namespace gui
|
||||
{
|
||||
namespace utils
|
||||
{
|
||||
void check_microphone_permission()
|
||||
{
|
||||
#if QT_CONFIG(permissions)
|
||||
const QMicrophonePermission permission;
|
||||
switch (qApp->checkPermission(permission))
|
||||
{
|
||||
case Qt::PermissionStatus::Undetermined:
|
||||
gui_log.notice("Requesting microphone permission");
|
||||
qApp->requestPermission(permission, []()
|
||||
{
|
||||
check_microphone_permission();
|
||||
});
|
||||
break;
|
||||
case Qt::PermissionStatus::Denied:
|
||||
gui_log.error("RPCS3 has no permissions to access microphones on this device.");
|
||||
break;
|
||||
case Qt::PermissionStatus::Granted:
|
||||
gui_log.notice("Microphone permission granted");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool check_camera_permission(void* obj, std::function<void()> repeat_callback, std::function<void()> denied_callback)
|
||||
{
|
||||
#if QT_CONFIG(permissions)
|
||||
const QCameraPermission permission;
|
||||
switch (qApp->checkPermission(permission))
|
||||
{
|
||||
case Qt::PermissionStatus::Undetermined:
|
||||
camera_log.notice("Requesting camera permission");
|
||||
qApp->requestPermission(permission, static_cast<QObject*>(obj), [repeat_callback]()
|
||||
{
|
||||
if (repeat_callback) repeat_callback();
|
||||
});
|
||||
return false;
|
||||
case Qt::PermissionStatus::Denied:
|
||||
camera_log.error("RPCS3 has no permissions to access cameras on this device.");
|
||||
if (denied_callback) denied_callback();
|
||||
return false;
|
||||
case Qt::PermissionStatus::Granted:
|
||||
camera_log.notice("Camera permission granted");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue