Add permissions feature example and manual test to the build

And add license headers and some minor fixes for warnings in the
example and test.

Task-number: QTBUG-90498
Change-Id: I34592f7f2844c92c25a6a676c8ac1ffca9e03c6d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
Assam Boudjelthia 2022-11-07 16:26:12 +02:00
parent 12a74666b7
commit e4125863f0
6 changed files with 15 additions and 3 deletions

View File

@ -6,6 +6,9 @@ add_subdirectory(mimetypes)
add_subdirectory(serialization)
add_subdirectory(tools)
add_subdirectory(platform)
if(QT_FEATURE_permissions)
add_subdirectory(permissions)
endif()
if(QT_FEATURE_thread)
add_subdirectory(threads)
endif()

View File

@ -1,3 +1,6 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(permissions LANGUAGES CXX)

View File

@ -29,7 +29,7 @@ public:
};
for (auto permission : permissions) {
auto permissionName = QString::fromLatin1(permission.name());
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));
@ -52,7 +52,8 @@ private:
switch (qApp->checkPermission(permission)) {
case Qt::PermissionStatus::Undetermined:
qApp->requestPermission(permission, this,
[this, button](const QPermission &permission) {
[button](const QPermission &permission) {
Q_UNUSED(permission);
emit button->clicked(); // Try again
}
);

View File

@ -40,6 +40,9 @@ if (QT_FEATURE_openssl AND UNIX)
add_subdirectory(qnetworkreply)
endif()
#special case end
if(QT_FEATURE_permissions)
add_subdirectory(permissions)
endif()
add_subdirectory(qstorageinfo)
add_subdirectory(qscreen)
add_subdirectory(qscreen_xrandr)

View File

@ -1,3 +1,5 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
qt_internal_add_test(tst_qpermissions
SOURCES

View File

@ -82,7 +82,7 @@ void tst_QPermissions::checkPermissionInNonMainThread()
void tst_QPermissions::requestPermission()
{
QFETCH_GLOBAL(QPermission, permission);
QTimer::singleShot(0, [=] {
QTimer::singleShot(0, this, [=] {
qApp->requestPermission(permission, [=](auto result) {
qDebug() << result;
Q_ASSERT(QThread::currentThread() == thread());