summaryrefslogtreecommitdiffstats
path: root/examples/corelib/permissions
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2023-06-26 13:26:40 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2023-06-26 18:45:25 +0200
commitf4a80552c2784eaa0659acd12df7a865aeb7ebec (patch)
tree3290d35994f8408d38627d3bff4de5fe7012ae10 /examples/corelib/permissions
parent69cc7f946a66527c3f2b7a28510dcb37459dc33a (diff)
Move permissions example to manual test
Pick-to: 6.5 6.6 Change-Id: If7482ff20079d91ddba26a1abcb06b3054cc72ad Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'examples/corelib/permissions')
-rw-r--r--examples/corelib/permissions/CMakeLists.txt47
-rw-r--r--examples/corelib/permissions/Info.plist59
-rw-r--r--examples/corelib/permissions/android/AndroidManifest.xml53
-rw-r--r--examples/corelib/permissions/main.cpp87
4 files changed, 0 insertions, 246 deletions
diff --git a/examples/corelib/permissions/CMakeLists.txt b/examples/corelib/permissions/CMakeLists.txt
deleted file mode 100644
index 39a207b1ce..0000000000
--- a/examples/corelib/permissions/CMakeLists.txt
+++ /dev/null
@@ -1,47 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(permissions LANGUAGES CXX)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/corelib/permissions")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_standard_project_setup()
-
-qt_add_executable(permissions
- MANUAL_FINALIZATION
- main.cpp
- android/AndroidManifest.xml
-)
-
-set_target_properties(permissions PROPERTIES
- MACOSX_BUNDLE TRUE
- MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist"
- MACOSX_BUNDLE_GUI_IDENTIFIER "io.qt.examples.permissions"
- QT_ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android"
-)
-
-target_link_libraries(permissions PRIVATE
- Qt6::Core
- Qt6::Gui
- Qt6::Widgets
-)
-
-install(TARGETS permissions
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
-
-if(APPLE AND NOT CMAKE_GENERATOR STREQUAL "Xcode")
- add_custom_command(TARGET permissions
- POST_BUILD COMMAND codesign -s - permissions.app)
-endif()
-
-qt_finalize_executable(permissions)
diff --git a/examples/corelib/permissions/Info.plist b/examples/corelib/permissions/Info.plist
deleted file mode 100644
index 57625d03dc..0000000000
--- a/examples/corelib/permissions/Info.plist
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>CFBundleInfoDictionaryVersion</key>
- <string>6.0</string>
- <key>CFBundlePackageType</key>
- <string>APPL</string>
-
- <key>CFBundleName</key>
- <string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
- <key>CFBundleIdentifier</key>
- <string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
- <key>CFBundleExecutable</key>
- <string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
-
- <key>CFBundleVersion</key>
- <string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
- <key>CFBundleShortVersionString</key>
- <string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
-
- <key>LSMinimumSystemVersion</key>
- <string>${CMAKE_OSX_DEPLOYMENT_TARGET}</string>
-
- <key>NSHumanReadableCopyright</key>
- <string>${MACOSX_BUNDLE_COPYRIGHT}</string>
-
- <key>CFBundleIconFile</key>
- <string>${MACOSX_BUNDLE_ICON_FILE}</string>
-
- <key>CFBundleDevelopmentRegion</key>
- <string>English</string>
-
- <key>NSSupportsAutomaticGraphicsSwitching</key>
- <true/>
-
- <key>NSBluetoothAlwaysUsageDescription</key>
- <string>Testing BluetoothAlways</string>
- <key>NSCalendarsUsageDescription</key>
- <string>Testing Calendars</string>
- <key>NSCameraUsageDescription</key>
- <string>Testing Camera</string>
- <key>NSContactsUsageDescription</key>
- <string>Testing Contacts</string>
- <key>NSHealthShareUsageDescription</key>
- <string>Testing HealthShare</string>
- <key>NSHealthUpdateUsageDescription</key>
- <string>Testing HealthUpdate</string>
- <key>NSLocationUsageDescription</key>
- <string>Testing Location on macOS</string>
- <key>NSLocationWhenInUseUsageDescription</key>
- <string>Testing Location when in use on iOS</string>
- <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
- <string>Testing Location always and when in use on iOS</string>
- <key>NSMicrophoneUsageDescription</key>
- <string>Testing Microphone</string>
-
-</dict>
-</plist>
diff --git a/examples/corelib/permissions/android/AndroidManifest.xml b/examples/corelib/permissions/android/AndroidManifest.xml
deleted file mode 100644
index 557ec8007e..0000000000
--- a/examples/corelib/permissions/android/AndroidManifest.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-<?xml version="1.0"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="org.qtproject.example"
- android:installLocation="auto"
- android:versionCode="-- %%INSERT_VERSION_CODE%% --"
- android:versionName="-- %%INSERT_VERSION_NAME%% --">
- <uses-permission android:name="android.permission.CAMERA" />
- <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
- <uses-permission android:name="android.permission.RECORD_AUDIO" />
- <uses-permission android:name="android.permission.BLUETOOTH" />
- <uses-permission android:name="android.permission.READ_CONTACTS" />
- <uses-permission android:name="android.permission.WRITE_CONTACTS" />
- <uses-permission android:name="android.permission.READ_CALENDAR" />
- <uses-permission android:name="android.permission.WRITE_CALENDAR" />
- <!-- %%INSERT_PERMISSIONS -->
- <!-- %%INSERT_FEATURES -->
- <supports-screens
- android:anyDensity="true"
- android:largeScreens="true"
- android:normalScreens="true"
- android:smallScreens="true" />
- <application
- android:name="org.qtproject.qt.android.bindings.QtApplication"
- android:hardwareAccelerated="true"
- android:label="-- %%INSERT_APP_NAME%% --"
- android:requestLegacyExternalStorage="true"
- android:allowNativeHeapPointerTagging="false"
- android:allowBackup="true"
- android:fullBackupOnly="false">
- <activity
- android:name="org.qtproject.qt.android.bindings.QtActivity"
- android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density"
- android:label="-- %%INSERT_APP_NAME%% --"
- android:launchMode="singleTop"
- android:screenOrientation="unspecified"
- android:exported="true">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
-
- <meta-data
- android:name="android.app.lib_name"
- android:value="-- %%INSERT_APP_LIB_NAME%% --" />
-
- <meta-data
- android:name="android.app.extract_android_style"
- android:value="minimal" />
- </activity>
- </application>
-</manifest>
diff --git a/examples/corelib/permissions/main.cpp b/examples/corelib/permissions/main.cpp
deleted file mode 100644
index 913aed2fec..0000000000
--- a/examples/corelib/permissions/main.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtCore/qmetaobject.h>
-#include <QtWidgets/qapplication.h>
-#include <QtWidgets/qwidget.h>
-#include <QtWidgets/qpushbutton.h>
-#include <QtWidgets/qlayout.h>
-#include <QtWidgets/qmessagebox.h>
-
-#if !QT_CONFIG(permissions)
-#error "This example requires the permissions feature, which is not enabled on this platform"
-#endif
-
-#include <QtCore/qpermissions.h>
-
-class PermissionWidget : public QWidget
-{
- Q_OBJECT
-public:
- explicit PermissionWidget(QWidget *parent = nullptr) : QWidget(parent)
- {
- QVBoxLayout *layout = new QVBoxLayout(this);
-
- static const QPermission permissions[] = {
- QCameraPermission{},
- QMicrophonePermission{},
- QBluetoothPermission{},
- QContactsPermission{},
- QCalendarPermission{},
- QLocationPermission{}
- };
-
- for (auto permission : permissions) {
- auto permissionName = QString::fromLatin1(permission.type().name());
- QPushButton *button = new QPushButton(permissionName.sliced(1, permissionName.length() - 11));
- connect(button, &QPushButton::clicked, this, &PermissionWidget::buttonClicked);
- button->setProperty("permission", QVariant::fromValue(permission));
- layout->addWidget(button);
- }
-
- QPalette pal = palette();
- pal.setBrush(QPalette::Window, QGradient(QGradient::HappyAcid));
- setPalette(pal);
- }
-
-private:
- void buttonClicked()
- {
- auto *button = static_cast<QPushButton*>(sender());
-
- auto permission = button->property("permission").value<QPermission>();
- Q_ASSERT(permission.type().isValid());
-
- switch (qApp->checkPermission(permission)) {
- case Qt::PermissionStatus::Undetermined:
- qApp->requestPermission(permission, this,
- [button](const QPermission &permission) {
- Q_UNUSED(permission);
- emit button->clicked(); // Try again
- }
- );
- return;
- case Qt::PermissionStatus::Denied:
- QMessageBox::warning(this, button->text(),
- tr("Permission is needed to use %1. Please grant permission "\
- "to this application in the system settings.").arg(button->text()));
- return;
- case Qt::PermissionStatus::Granted:
- break; // Proceed
- }
-
- // All good, can use the feature
- QMessageBox::information(this, button->text(),
- tr("Accessing %1").arg(button->text()));
- }
-};
-
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
- PermissionWidget widget;
- widget.show();
- return app.exec();
-}
-
-#include "main.moc"