| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 | 
							- /******************************************************************************
 
-     Copyright (C) 2014 by Hugh Bailey <[email protected]>
 
-     This program is free software: you can redistribute it and/or modify
 
-     it under the terms of the GNU General Public License as published by
 
-     the Free Software Foundation, either version 2 of the License, or
 
-     (at your option) any later version.
 
-     This program is distributed in the hope that it will be useful,
 
-     but WITHOUT ANY WARRANTY; without even the implied warranty of
 
-     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
-     GNU General Public License for more details.
 
-     You should have received a copy of the GNU General Public License
 
-     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
- ******************************************************************************/
 
- #include <QLabel>
 
- #include "window-permissions.hpp"
 
- #include "obs-app.hpp"
 
- OBSPermissions::OBSPermissions(QWidget *parent, MacPermissionStatus capture,
 
- 			       MacPermissionStatus video,
 
- 			       MacPermissionStatus audio,
 
- 			       MacPermissionStatus accessibility)
 
- 	: QDialog(parent), ui(new Ui::OBSPermissions)
 
- {
 
- 	ui->setupUi(this);
 
- 	SetStatus(ui->capturePermissionButton, capture,
 
- 		  QTStr("MacPermissions.Item.ScreenRecording"));
 
- 	SetStatus(ui->videoPermissionButton, video,
 
- 		  QTStr("MacPermissions.Item.Camera"));
 
- 	SetStatus(ui->audioPermissionButton, audio,
 
- 		  QTStr("MacPermissions.Item.Microphone"));
 
- 	SetStatus(ui->accessibilityPermissionButton, accessibility,
 
- 		  QTStr("MacPermissions.Item.Accessibility"));
 
- }
 
- void OBSPermissions::SetStatus(QPushButton *btn, MacPermissionStatus status,
 
- 			       const QString &preference)
 
- {
 
- 	if (status == kPermissionAuthorized) {
 
- 		btn->setText(QTStr("MacPermissions.AccessGranted"));
 
- 	} else if (status == kPermissionNotDetermined) {
 
- 		btn->setText(QTStr("MacPermissions.RequestAccess"));
 
- 	} else {
 
- 		btn->setText(
 
- 			QTStr("MacPermissions.OpenPreferences").arg(preference));
 
- 	}
 
- 	btn->setEnabled(status != kPermissionAuthorized);
 
- 	btn->setProperty("status", status);
 
- }
 
- void OBSPermissions::on_capturePermissionButton_clicked()
 
- {
 
- 	OpenMacOSPrivacyPreferences("ScreenCapture");
 
- 	RequestPermission(kScreenCapture);
 
- }
 
- void OBSPermissions::on_videoPermissionButton_clicked()
 
- {
 
- 	MacPermissionStatus status =
 
- 		(MacPermissionStatus)ui->videoPermissionButton
 
- 			->property("status")
 
- 			.toInt();
 
- 	if (status == kPermissionNotDetermined) {
 
- 		status = RequestPermission(kVideoDeviceAccess);
 
- 		SetStatus(ui->videoPermissionButton, status,
 
- 			  QTStr("MacPermissions.Item.Camera"));
 
- 	} else {
 
- 		OpenMacOSPrivacyPreferences("Camera");
 
- 	}
 
- }
 
- void OBSPermissions::on_audioPermissionButton_clicked()
 
- {
 
- 	MacPermissionStatus status =
 
- 		(MacPermissionStatus)ui->audioPermissionButton
 
- 			->property("status")
 
- 			.toInt();
 
- 	if (status == kPermissionNotDetermined) {
 
- 		status = RequestPermission(kAudioDeviceAccess);
 
- 		SetStatus(ui->audioPermissionButton, status,
 
- 			  QTStr("MacPermissions.Item.Microphone"));
 
- 	} else {
 
- 		OpenMacOSPrivacyPreferences("Microphone");
 
- 	}
 
- }
 
- void OBSPermissions::on_accessibilityPermissionButton_clicked()
 
- {
 
- 	OpenMacOSPrivacyPreferences("Accessibility");
 
- 	RequestPermission(kAccessibility);
 
- }
 
- void OBSPermissions::on_continueButton_clicked()
 
- {
 
- 	config_set_int(GetGlobalConfig(), "General",
 
- 		       "MacOSPermissionsDialogLastShown",
 
- 		       MACOS_PERMISSIONS_DIALOG_VERSION);
 
- 	close();
 
- }
 
 
  |