Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove obsolete #if Qt version checks #5900

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
168 changes: 4 additions & 164 deletions src/core/platforms/android/androidplatformutilities.cpp

Large diffs are not rendered by default.

13 changes: 2 additions & 11 deletions src/core/platforms/android/androidplatformutilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@

#include "platformutilities.h"

#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
#include <QAndroidJniObject>
#else
#include <QJniObject>
nirvn marked this conversation as resolved.
Show resolved Hide resolved
#endif

class AndroidPlatformUtilities : public PlatformUtilities
{
Expand Down Expand Up @@ -93,17 +89,12 @@ class AndroidPlatformUtilities : public PlatformUtilities
bool checkAndAcquirePermissions( const QString &permissions ) const;
ResourceSource *processCameraActivity( const QString &prefix, const QString &filePath, const QString &suffix, bool isVideo, QObject *parent = nullptr );
ResourceSource *processGalleryActivity( const QString &prefix, const QString &filePath, const QString &mimeType, QObject *parent = nullptr );
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
QString getIntentExtra( const QString &, QAndroidJniObject = nullptr ) const;
QAndroidJniObject getNativeIntent() const;
QAndroidJniObject getNativeExtras() const;
QAndroidJniObject mActivity;
#else

QString getIntentExtra( const QString &, QJniObject = nullptr ) const;

QJniObject getNativeIntent() const;
QJniObject getNativeExtras() const;
QJniObject mActivity;
#endif
QString mSystemGenericDataLocation;
};

Expand Down
20 changes: 1 addition & 19 deletions src/core/platforms/android/androidprojectsource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,22 @@
#include "qgsmessagelog.h"

#include <QFile>

#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
#include <QtAndroid>
#else
#include <QtCore/private/qandroidextras_p.h>
#endif


AndroidProjectSource::AndroidProjectSource( QObject *parent )
: ProjectSource( parent )
, QAndroidActivityResultReceiver()
{
}

#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
void AndroidProjectSource::handleActivityResult( int receiverRequestCode, int resultCode, const QAndroidJniObject &data )
#else
void AndroidProjectSource::handleActivityResult( int receiverRequestCode, int resultCode, const QJniObject &data )
#endif
{
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
jint RESULT_OK = QAndroidJniObject::getStaticField<jint>( "android/app/Activity", "RESULT_OK" );
#else
jint RESULT_OK = QJniObject::getStaticField<jint>( "android/app/Activity", "RESULT_OK" );
#endif
if ( receiverRequestCode == 103 && resultCode == RESULT_OK )
{
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
QAndroidJniObject uri = data.callObjectMethod( "getData", "()Landroid/net/Uri;" );
#else
QJniObject uri = data.callObjectMethod( "getData", "()Landroid/net/Uri;" );
#endif

QString path = uri.callObjectMethod( "getPath", "()Ljava/lang/String;" ).toString();

if ( !QFile( path ).exists() )
{
QgsMessageLog::logMessage( tr( "File %1 does not exist" ).arg( path ), QStringLiteral( "QField" ), Qgis::Warning );
Expand Down
8 changes: 0 additions & 8 deletions src/core/platforms/android/androidprojectsource.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@

#include "projectsource.h"

#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
#include <QAndroidActivityResultReceiver>
#else
#include <QtCore/private/qandroidextras_p.h>
nirvn marked this conversation as resolved.
Show resolved Hide resolved
#endif

class AndroidProjectSource : public ProjectSource, public QAndroidActivityResultReceiver
{
Expand All @@ -33,11 +29,7 @@ class AndroidProjectSource : public ProjectSource, public QAndroidActivityResult
public:
explicit AndroidProjectSource( QObject *parent = nullptr );

#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
void handleActivityResult( int receiverRequestCode, int resultCode, const QAndroidJniObject &data ) override;
#else
void handleActivityResult( int receiverRequestCode, int resultCode, const QJniObject &data ) override;
#endif
};

#endif // ANDROIDPROJECTSOURCE_H
2 changes: 0 additions & 2 deletions src/core/platforms/ios/iosplatformutilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,10 @@ class IosPlatformUtilities : public PlatformUtilities
double systemFontPointSize() const override { return 16.0; }
bool isSystemDarkTheme() const override;

#if QT_VERSION >= QT_VERSION_CHECK( 6, 5, 0 )
Qt::PermissionStatus checkCameraPermission() const override;
void requestCameraPermission( std::function<void( Qt::PermissionStatus )> func ) override;
virtual Qt::PermissionStatus checkMicrophonePermission() const override;
virtual void requestMicrophonePermission( std::function<void( Qt::PermissionStatus )> func ) override;
#endif
};

#endif
2 changes: 0 additions & 2 deletions src/core/platforms/ios/iosplatformutilities.mm
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ - (void)documentInteractionControllerDidEndPreview:
return false;
}

#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
Qt::PermissionStatus IosPlatformUtilities::checkCameraPermission() const {
switch ([AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo]) {
case AVAuthorizationStatusNotDetermined: {
Expand Down Expand Up @@ -242,4 +241,3 @@ - (void)documentInteractionControllerDidEndPreview:
: Qt::PermissionStatus::Denied);
}];
}
#endif
2 changes: 1 addition & 1 deletion src/core/qgismobileapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ QgisMobileapp::QgisMobileapp( QgsApplication *app, QObject *parent )

void QgisMobileapp::initDeclarative( QQmlEngine *engine )
{
#if defined( Q_OS_ANDROID ) && QT_VERSION >= QT_VERSION_CHECK( 5, 14, 0 )
#if defined( Q_OS_ANDROID )
QResource::registerResource( QStringLiteral( "assets:/android_rcc_bundle.rcc" ) );
#endif
engine->addImportPath( QStringLiteral( "qrc:/qml/imports" ) );
Expand Down
25 changes: 3 additions & 22 deletions src/sentry/sentry_classic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,14 @@
#include <QtGlobal>

#include <sentry.h>
#ifdef ANDROID
#include <android/log.h>

#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
#include <QAndroidJniEnvironment>
#include <QAndroidJniObject>
#include <QtAndroid>

inline QAndroidJniObject qtAndroidContext()
{
auto result = QtAndroid::androidActivity();
if ( result.isValid() )
return result;
return QtAndroid::androidService();
}

inline void runOnAndroidMainThread( const QtAndroid::Runnable &runnable )
{
QtAndroid::runOnAndroidThread( runnable );
}

#else
#ifdef ANDROID
#include <QJniEnvironment>
#include <QJniObject>
#include <QtCore/private/qandroidextras_p.h>

#include <android/log.h>

inline QJniObject qtAndroidContext()
{
return QJniObject( QCoreApplication::instance()->nativeInterface<QNativeInterface::QAndroidApplication>()->context() );
Expand All @@ -61,7 +43,6 @@ inline void runOnAndroidMainThread( const std::function<void()> &runnable )
} );
}
#endif
#endif

namespace sentry_wrapper
{
Expand Down
7 changes: 1 addition & 6 deletions src/service/qfieldservice.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,8 @@

#include "qfield_service_export.h"
nirvn marked this conversation as resolved.
Show resolved Hide resolved

#include <QtGlobal>
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
#include <QAndroidService>
#include <QtAndroid>
#else
#include <QtCore/private/qandroidextras_p.h>
#endif
#include <QtGlobal>

class QFIELD_SERVICE_EXPORT QFieldService : public QAndroidService
{
Expand Down
Loading