237
|
1 #include "sys/osx/permissions.h"
|
|
2
|
|
3 #include <ApplicationServices/ApplicationServices.h>
|
|
4
|
|
5 #include <QCoreApplication>
|
|
6 #include <QMessageBox>
|
|
7 #include <QDesktopServices>
|
|
8 #include <QUrl>
|
|
9
|
|
10 namespace osx {
|
|
11
|
|
12 bool AskForPermissions() {
|
|
13 if (::AXIsProcessTrusted())
|
|
14 return true;
|
|
15
|
|
16 QMessageBox msg;
|
|
17 msg.setIcon(QMessageBox::Information);
|
|
18 msg.setText(QCoreApplication::tr("Permissions needed!"));
|
|
19 msg.setInformativeText(QCoreApplication::tr("Minori needs access to accessibility features for certain features to work. Open System Preferences?"));
|
|
20 msg.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
|
21 msg.setDefaultButton(QMessageBox::Yes);
|
|
22 int ret = msg.exec();
|
|
23 if (ret != QMessageBox::Yes)
|
|
24 return false;
|
|
25
|
|
26 QDesktopServices::openUrl(QUrl("x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility"));
|
|
27 return true;
|
|
28 }
|
|
29
|
|
30 }
|