From 92907bd1221ecaab9007fe11e75c8700184b648c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20Gro=C3=9F?= Date: Sat, 19 Feb 2022 13:05:02 +0100 Subject: [PATCH] Clean up Qt compatibility code --- .../src/audio/AvatarAudioStream.h | 5 - assignment-client/src/avatars/AvatarMixer.cpp | 7 +- interface/src/Application.cpp | 33 ++----- interface/src/Application.h | 14 +-- interface/src/avatar/MyHead.h | 5 - interface/src/graphics/GraphicsEngine.h | 9 +- interface/src/ui/overlays/Overlays.h | 8 +- libraries/animation/src/AnimNodeLoader.h | 5 - libraries/animation/src/AnimRandomSwitch.h | 5 - libraries/animation/src/AnimStateMachine.h | 10 -- libraries/audio/src/AudioInjectorManager.h | 5 - libraries/audio/src/InjectedAudioStream.h | 5 - libraries/avatars/src/AvatarData.h | 5 - libraries/avatars/src/HeadData.h | 5 - .../src/controllers/UserInputMapper.cpp | 24 ++--- .../src/display-plugins/CompositorHelper.h | 8 +- libraries/entities/src/EntitySimulation.h | 8 +- libraries/entities/src/EntityTree.cpp | 9 +- libraries/networking/src/AccountManager.h | 5 - .../networking/src/AssetResourceRequest.cpp | 8 +- libraries/networking/src/HMACAuth.h | 8 +- libraries/networking/src/NLPacketList.h | 8 -- libraries/networking/src/Node.h | 5 - libraries/networking/src/NodeList.h | 9 -- .../networking/src/udt/CongestionControl.h | 5 - libraries/networking/src/udt/ControlPacket.h | 10 -- libraries/networking/src/udt/PacketList.h | 5 - libraries/networking/src/udt/SendQueue.h | 7 +- libraries/octree/src/OctreeEditPacketSender.h | 9 +- .../physics/src/PhysicalEntitySimulation.h | 9 +- libraries/render-utils/src/Model.cpp | 9 +- libraries/render-utils/src/Model.h | 8 +- libraries/script-engine/src/ScriptEngine.cpp | 21 ++-- libraries/shared/src/DependencyManager.h | 8 +- libraries/shared/src/QtCompatibility.h | 60 ++++++++++++ libraries/shared/src/shared/FileUtils.cpp | 12 +-- libraries/shared/src/shared/FileUtils.h | 8 +- libraries/ui/src/VrMenu.cpp | 4 - tools/ac-client/src/ACClientApp.cpp | 8 +- tools/atp-client/src/ATPClientApp.cpp | 8 +- tools/ice-client/src/ICEClientApp.cpp | 8 +- tools/nitpick/src/TestCreator.cpp | 97 +++++-------------- tools/skeleton-dump/src/SkeletonDumpApp.cpp | 8 +- tools/vhacd-util/src/VHACDUtilApp.cpp | 8 +- 44 files changed, 177 insertions(+), 348 deletions(-) create mode 100644 libraries/shared/src/QtCompatibility.h diff --git a/assignment-client/src/audio/AvatarAudioStream.h b/assignment-client/src/audio/AvatarAudioStream.h index b7d310377f..e445dafa5c 100644 --- a/assignment-client/src/audio/AvatarAudioStream.h +++ b/assignment-client/src/audio/AvatarAudioStream.h @@ -23,12 +23,7 @@ public: AvatarAudioStream(bool isStereo, int numStaticJitterFrames = -1); private: -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - AvatarAudioStream(const AvatarAudioStream&); - AvatarAudioStream& operator= (const AvatarAudioStream&); -#else Q_DISABLE_COPY(AvatarAudioStream) -#endif int parseStreamProperties(PacketType type, const QByteArray& packetAfterSeqNum, int& numAudioSamples) override; }; diff --git a/assignment-client/src/avatars/AvatarMixer.cpp b/assignment-client/src/avatars/AvatarMixer.cpp index 607b7d6b7c..ee8f3f7ade 100644 --- a/assignment-client/src/avatars/AvatarMixer.cpp +++ b/assignment-client/src/avatars/AvatarMixer.cpp @@ -5,6 +5,7 @@ // Created by Stephen Birarda on 9/5/13. // Copyright 2013 High Fidelity, Inc. // Copyright 2021 Vircadia contributors. +// Copyright 2022 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -1062,11 +1063,7 @@ void AvatarMixer::parseDomainServerSettings(const QJsonObject& domainSettings) { static const QString AVATAR_WHITELIST_OPTION = "avatar_whitelist"; _slaveSharedData.skeletonURLWhitelist = avatarMixerGroupObject[AVATAR_WHITELIST_OPTION] -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - .toString().split(',', QString::KeepEmptyParts); -#else - .toString().split(',', Qt::KeepEmptyParts); -#endif + .toString().split(',', QTCOMPAT_KEEP_EMPTY_PARTS); static const QString REPLACEMENT_AVATAR_OPTION = "replacement_avatar"; _slaveSharedData.skeletonReplacementURL = avatarMixerGroupObject[REPLACEMENT_AVATAR_OPTION] diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ddbcf08724..e7023d6ac3 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5,6 +5,7 @@ // Created by Andrzej Kapolka on 5/10/13. // Copyright 2013 High Fidelity, Inc. // Copyright 2020 Vircadia contributors. +// Copyright 2022 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -24,6 +25,8 @@ #include +#include "QtCompatibility.h" + #include #include #include @@ -3261,20 +3264,12 @@ void Application::initializeUi() { auto newValidator = [=](const QUrl& url) -> bool { QString whitelistPrefix = "[WHITELIST ENTITY SCRIPTS]"; QList safeURLS = { "" }; -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - safeURLS += qEnvironmentVariable("EXTRA_WHITELIST").trimmed().split(QRegExp("\\s*,\\s*"), QString::SkipEmptyParts); -#else - safeURLS += qEnvironmentVariable("EXTRA_WHITELIST").trimmed().split(QRegExp("\\s*,\\s*"), Qt::SkipEmptyParts); -#endif + safeURLS += qEnvironmentVariable("EXTRA_WHITELIST").trimmed().split(QRegExp("\\s*,\\s*"), QTCOMPAT_SKIP_EMPTY_PARTS); // PULL SAFEURLS FROM INTERFACE.JSON Settings QVariant raw = Setting::Handle("private/settingsSafeURLS").get(); -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - QStringList settingsSafeURLS = raw.toString().trimmed().split(QRegExp("\\s*[,\r\n]+\\s*"), QString::SkipEmptyParts); -#else - QStringList settingsSafeURLS = raw.toString().trimmed().split(QRegExp("\\s*[,\r\n]+\\s*"), Qt::SkipEmptyParts); -#endif + QStringList settingsSafeURLS = raw.toString().trimmed().split(QRegExp("\\s*[,\r\n]+\\s*"), QTCOMPAT_SKIP_EMPTY_PARTS); safeURLS += settingsSafeURLS; // END PULL SAFEURLS FROM INTERFACE.JSON Settings @@ -8851,31 +8846,19 @@ void Application::initPlugins(const QStringList& arguments) { parser.parse(arguments); if (parser.isSet(display)) { -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - auto preferredDisplays = parser.value(display).split(',', QString::SkipEmptyParts); -#else - auto preferredDisplays = parser.value(display).split(',', Qt::SkipEmptyParts); -#endif + auto preferredDisplays = parser.value(display).split(',', QTCOMPAT_SKIP_EMPTY_PARTS); qInfo() << "Setting prefered display plugins:" << preferredDisplays; PluginManager::getInstance()->setPreferredDisplayPlugins(preferredDisplays); } if (parser.isSet(disableDisplays)) { -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - auto disabledDisplays = parser.value(disableDisplays).split(',', QString::SkipEmptyParts); -#else - auto disabledDisplays = parser.value(disableDisplays).split(',', Qt::SkipEmptyParts); -#endif + auto disabledDisplays = parser.value(disableDisplays).split(',', QTCOMPAT_SKIP_EMPTY_PARTS); qInfo() << "Disabling following display plugins:" << disabledDisplays; PluginManager::getInstance()->disableDisplays(disabledDisplays); } if (parser.isSet(disableInputs)) { -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - auto disabledInputs = parser.value(disableInputs).split(',', QString::SkipEmptyParts); -#else - auto disabledInputs = parser.value(disableInputs).split(',', Qt::SkipEmptyParts); -#endif + auto disabledInputs = parser.value(disableInputs).split(',', QTCOMPAT_SKIP_EMPTY_PARTS); qInfo() << "Disabling following input plugins:" << disabledInputs; PluginManager::getInstance()->disableInputs(disabledInputs); } diff --git a/interface/src/Application.h b/interface/src/Application.h index 0a7d9faebf..853eae708d 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -5,6 +5,7 @@ // Created by Andrzej Kapolka on 5/10/13. // Copyright 2013 High Fidelity, Inc. // Copyright 2020 Vircadia contributors. +// Copyright 2022 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -15,6 +16,7 @@ #include +#include "QtCompatibility.h" #include #include #include @@ -648,11 +650,7 @@ private: EntityTreePointer _entityClipboard; -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - mutable QMutex _viewMutex { QMutex::Recursive }; -#else - mutable QRecursiveMutex _viewMutex; -#endif + mutable QTCOMPAT_DECLARE_RECURSIVE_MUTEX(_viewMutex); ViewFrustum _viewFrustum; // current state of view frustum, perspective, orientation, etc. ViewFrustum _displayViewFrustum; @@ -778,11 +776,7 @@ private: bool _isMissingSequenceNumbers { false }; void checkChangeCursor(); -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - mutable QMutex _changeCursorLock { QMutex::Recursive }; -#else - mutable QRecursiveMutex _changeCursorLock; -#endif + mutable QTCOMPAT_DECLARE_RECURSIVE_MUTEX(_changeCursorLock); Qt::CursorShape _desiredCursor{ Qt::BlankCursor }; bool _cursorNeedsChanging { false }; diff --git a/interface/src/avatar/MyHead.h b/interface/src/avatar/MyHead.h index c39d600e11..31543ccf5c 100644 --- a/interface/src/avatar/MyHead.h +++ b/interface/src/avatar/MyHead.h @@ -22,12 +22,7 @@ public: void simulate(float deltaTime) override; private: -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - MyHead(const Head&); - MyHead& operator= (const MyHead&); -#else Q_DISABLE_COPY(MyHead) -#endif }; #endif // hifi_MyHead_h diff --git a/interface/src/graphics/GraphicsEngine.h b/interface/src/graphics/GraphicsEngine.h index a106492516..caed3066cf 100644 --- a/interface/src/graphics/GraphicsEngine.h +++ b/interface/src/graphics/GraphicsEngine.h @@ -3,6 +3,7 @@ // // Created by Sam Gateau on 29/6/2018. // Copyright 2018 High Fidelity, Inc. +// Copyright 2022 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -12,6 +13,7 @@ #include #include +#include "QtCompatibility.h" #include #include @@ -68,12 +70,7 @@ private: void render_runRenderFrame(RenderArgs* renderArgs); protected: - -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - mutable QMutex _renderArgsMutex{ QMutex::Recursive }; -#else - mutable QRecursiveMutex _renderArgsMutex; -#endif + mutable QTCOMPAT_DECLARE_RECURSIVE_MUTEX(_renderArgsMutex); AppRenderArgs _appRenderArgs; RateCounter<500> _renderLoopCounter; diff --git a/interface/src/ui/overlays/Overlays.h b/interface/src/ui/overlays/Overlays.h index 94132ad554..4ccd4f93fb 100644 --- a/interface/src/ui/overlays/Overlays.h +++ b/interface/src/ui/overlays/Overlays.h @@ -4,6 +4,7 @@ // // Modified by Zander Otavka on 7/15/15 // Copyright 2014 High Fidelity, Inc. +// Copyright 2022 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -18,6 +19,7 @@ #ifndef hifi_Overlays_h #define hifi_Overlays_h +#include "QtCompatibility.h" #include #include #include @@ -746,11 +748,7 @@ signals: private: void cleanupOverlaysToDelete(); -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - mutable QMutex _mutex { QMutex::Recursive }; -#else - mutable QRecursiveMutex _mutex; -#endif + mutable QTCOMPAT_DECLARE_RECURSIVE_MUTEX(_mutex); QMap _overlays; QList _overlaysToDelete; diff --git a/libraries/animation/src/AnimNodeLoader.h b/libraries/animation/src/AnimNodeLoader.h index 537735789a..ac27402cf7 100644 --- a/libraries/animation/src/AnimNodeLoader.h +++ b/libraries/animation/src/AnimNodeLoader.h @@ -45,12 +45,7 @@ protected: QSharedPointer _resource; private: -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - AnimNodeLoader(const AnimNodeLoader&) = delete; - AnimNodeLoader& operator=(const AnimNodeLoader&) = delete; -#else Q_DISABLE_COPY(AnimNodeLoader) -#endif }; #endif // hifi_AnimNodeLoader diff --git a/libraries/animation/src/AnimRandomSwitch.h b/libraries/animation/src/AnimRandomSwitch.h index 65cfb75afe..99a3f94d9b 100644 --- a/libraries/animation/src/AnimRandomSwitch.h +++ b/libraries/animation/src/AnimRandomSwitch.h @@ -184,12 +184,7 @@ protected: QString _lastPlayedState; private: -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - AnimRandomSwitch(const AnimRandomSwitch&) = delete; - AnimRandomSwitch& operator=(const AnimRandomSwitch&) = delete; -#else Q_DISABLE_COPY(AnimRandomSwitch) -#endif }; #endif // hifi_AnimRandomSwitch_h diff --git a/libraries/animation/src/AnimStateMachine.h b/libraries/animation/src/AnimStateMachine.h index b8991f4178..0a34fc4ebc 100644 --- a/libraries/animation/src/AnimStateMachine.h +++ b/libraries/animation/src/AnimStateMachine.h @@ -107,12 +107,7 @@ protected: std::vector _transitions; private: -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - State(const State&) = delete; - State& operator=(const State&) = delete; -#else Q_DISABLE_COPY(State) -#endif }; public: @@ -155,12 +150,7 @@ protected: QString _currentStateVar; private: -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - AnimStateMachine(const AnimStateMachine&) = delete; - AnimStateMachine& operator=(const AnimStateMachine&) = delete; -#else Q_DISABLE_COPY(AnimStateMachine) -#endif }; #endif // hifi_AnimStateMachine_h diff --git a/libraries/audio/src/AudioInjectorManager.h b/libraries/audio/src/AudioInjectorManager.h index cf8aa4e674..8fac2b37f2 100644 --- a/libraries/audio/src/AudioInjectorManager.h +++ b/libraries/audio/src/AudioInjectorManager.h @@ -72,12 +72,7 @@ private: bool wouldExceedLimits(); AudioInjectorManager() { createThread(); } -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - AudioInjectorManager(const AudioInjectorManager&) = delete; - AudioInjectorManager& operator=(const AudioInjectorManager&) = delete; -#else Q_DISABLE_COPY(AudioInjectorManager) -#endif void createThread(); diff --git a/libraries/audio/src/InjectedAudioStream.h b/libraries/audio/src/InjectedAudioStream.h index 421a993ca7..467c499fa6 100644 --- a/libraries/audio/src/InjectedAudioStream.h +++ b/libraries/audio/src/InjectedAudioStream.h @@ -28,12 +28,7 @@ public: virtual const QUuid& getStreamIdentifier() const override { return _streamIdentifier; } private: -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - InjectedAudioStream(const InjectedAudioStream&); - InjectedAudioStream& operator= (const InjectedAudioStream&); -#else Q_DISABLE_COPY(InjectedAudioStream) -#endif AudioStreamStats getAudioStreamStats() const override; int parseStreamProperties(PacketType type, const QByteArray& packetAfterSeqNum, int& numAudioSamples) override; diff --git a/libraries/avatars/src/AvatarData.h b/libraries/avatars/src/AvatarData.h index a791e46132..70f20caa26 100644 --- a/libraries/avatars/src/AvatarData.h +++ b/libraries/avatars/src/AvatarData.h @@ -1887,12 +1887,7 @@ protected: virtual void clearAvatarGrabData(const QUuid& grabID); private: -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - AvatarData(const AvatarData&); - AvatarData& operator= (const AvatarData&); -#else Q_DISABLE_COPY(AvatarData) -#endif friend void avatarStateFromFrame(const QByteArray& frameData, AvatarData* _avatar); static QUrl _defaultFullAvatarModelUrl; diff --git a/libraries/avatars/src/HeadData.h b/libraries/avatars/src/HeadData.h index 94b3ea04f8..3ab756ce42 100644 --- a/libraries/avatars/src/HeadData.h +++ b/libraries/avatars/src/HeadData.h @@ -128,12 +128,7 @@ protected: AvatarData* _owningAvatar; private: -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - HeadData(const HeadData&); - HeadData& operator= (const HeadData&); -#else Q_DISABLE_COPY(HeadData) -#endif void setHeadOrientation(const glm::quat& orientation); }; diff --git a/libraries/controllers/src/controllers/UserInputMapper.cpp b/libraries/controllers/src/controllers/UserInputMapper.cpp index 573a4e9a73..385a5d12b0 100644 --- a/libraries/controllers/src/controllers/UserInputMapper.cpp +++ b/libraries/controllers/src/controllers/UserInputMapper.cpp @@ -1,6 +1,7 @@ // // Created by Sam Gateau on 4/27/15. // Copyright 2015 High Fidelity, Inc. +// Copyright 2022 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -10,6 +11,8 @@ #include +#include "QtCompatibility.h" + #include #include @@ -738,11 +741,7 @@ Mapping::Pointer UserInputMapper::newMapping(const QString& mappingName) { // if (request->getResult() == ResourceRequest::Success) { // result = parseMapping(QString(request->getData())); // } else { -// #if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) -// qCWarning(controllers) << "Failed to load mapping url <" << jsonUrl << ">" << endl; -// #else -// qCWarning(controllers) << "Failed to load mapping url <" << jsonUrl << ">" << Qt::endl; -// #endif +// qCWarning(controllers) << "Failed to load mapping url <" << jsonUrl << ">" << QTCOMPAT_ENDL; // } // request->deleteLater(); // } @@ -1181,22 +1180,13 @@ Mapping::Pointer UserInputMapper::parseMapping(const QString& json) { if (doc.isNull()) { qCDebug(controllers) << "Invalid JSON...\n"; qCDebug(controllers) << error.errorString(); -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - qCDebug(controllers) << "JSON was:\n" << json << endl; -#else - qCDebug(controllers) << "JSON was:\n" << json << Qt::endl; -#endif + qCDebug(controllers) << "JSON was:\n" << json << QTCOMPAT_ENDL; return Mapping::Pointer(); } if (!doc.isObject()) { -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - qWarning() << "Mapping json Document is not an object" << endl; - qCDebug(controllers) << "JSON was:\n" << json << endl; -#else - qWarning() << "Mapping json Document is not an object" << Qt::endl; - qCDebug(controllers) << "JSON was:\n" << json << Qt::endl; -#endif + qWarning() << "Mapping json Document is not an object" << QTCOMPAT_ENDL; + qCDebug(controllers) << "JSON was:\n" << json << QTCOMPAT_ENDL; return Mapping::Pointer(); } return parseMapping(doc.object()); diff --git a/libraries/display-plugins/src/display-plugins/CompositorHelper.h b/libraries/display-plugins/src/display-plugins/CompositorHelper.h index 5e05b8a090..3da9072821 100644 --- a/libraries/display-plugins/src/display-plugins/CompositorHelper.h +++ b/libraries/display-plugins/src/display-plugins/CompositorHelper.h @@ -2,6 +2,7 @@ // Created by Bradley Austin Davis Arnold on 2015/06/13 // Copyright 2015 High Fidelity, Inc. // Copyright 2020 Vircadia contributors. +// Copyright 2022 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -13,6 +14,7 @@ #include #include +#include "QtCompatibility.h" #include #include #include @@ -161,11 +163,7 @@ private: // application specific position, when it's in desktop mode, the reticle position will simply move // the system mouse. glm::vec2 _reticlePositionInHMD { 0.0f, 0.0f }; -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - mutable QMutex _reticleLock { QMutex::Recursive }; -#else - mutable QRecursiveMutex _reticleLock; -#endif + mutable QTCOMPAT_DECLARE_RECURSIVE_MUTEX(_reticleLock); QPointF _lastKnownRealMouse; bool _ignoreMouseMove { false }; diff --git a/libraries/entities/src/EntitySimulation.h b/libraries/entities/src/EntitySimulation.h index f4b290e5c0..a96542b80b 100644 --- a/libraries/entities/src/EntitySimulation.h +++ b/libraries/entities/src/EntitySimulation.h @@ -4,6 +4,7 @@ // // Created by Andrew Meadows on 2014.11.24 // Copyright 2014 High Fidelity, Inc. +// Copyright 2022 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -15,6 +16,7 @@ #include #include +#include "QtCompatibility.h" #include #include @@ -94,11 +96,7 @@ protected: void callUpdateOnEntitiesThatNeedIt(uint64_t now); virtual void sortEntitiesThatMoved(); -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - QMutex _mutex{ QMutex::Recursive }; -#else - QRecursiveMutex _mutex; -#endif + QTCOMPAT_DECLARE_RECURSIVE_MUTEX(_mutex); SetOfEntities _entitiesToSort; // entities moved by simulation (and might need resort in EntityTree) SetOfEntities _simpleKinematicEntities; // entities undergoing non-colliding kinematic motion diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 09d97e311a..3fd2f00f52 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -5,12 +5,15 @@ // Created by Brad Hefta-Gaub on 12/4/13. // Copyright 2013 High Fidelity, Inc. // Copyright 2020 Vircadia contributors. +// Copyright 2020 Vircadia contributors. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "EntityTree.h" + +#include "QtCompatibility.h" #include #include #include @@ -68,11 +71,7 @@ EntityTree::~EntityTree() { } void EntityTree::setEntityScriptSourceWhitelist(const QString& entityScriptSourceWhitelist) { -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - _entityScriptSourceWhitelist = entityScriptSourceWhitelist.split(',', QString::SkipEmptyParts); -#else - _entityScriptSourceWhitelist = entityScriptSourceWhitelist.split(',', Qt::SkipEmptyParts); -#endif + _entityScriptSourceWhitelist = entityScriptSourceWhitelist.split(',', QTCOMPAT_SKIP_EMPTY_PARTS); } diff --git a/libraries/networking/src/AccountManager.h b/libraries/networking/src/AccountManager.h index 0e318e244e..bd318e3af5 100644 --- a/libraries/networking/src/AccountManager.h +++ b/libraries/networking/src/AccountManager.h @@ -163,12 +163,7 @@ private slots: void postAccountSettingsError(QNetworkReply::NetworkError error); private: -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - AccountManager(AccountManager const& other) = delete; - void operator=(AccountManager const& other) = delete; -#else Q_DISABLE_COPY(AccountManager); -#endif void persistAccountToFile(); diff --git a/libraries/networking/src/AssetResourceRequest.cpp b/libraries/networking/src/AssetResourceRequest.cpp index fb5b79ad84..fc1bfcb287 100644 --- a/libraries/networking/src/AssetResourceRequest.cpp +++ b/libraries/networking/src/AssetResourceRequest.cpp @@ -4,6 +4,7 @@ // // Created by Ryan Huffman on 2015/07/23 // Copyright 2015 High Fidelity, Inc. +// Copyright 2022 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -11,6 +12,7 @@ #include "AssetResourceRequest.h" +#include "QtCompatibility.h" #include #include @@ -59,11 +61,7 @@ void AssetResourceRequest::doSend() { // We'll either have a hash or an ATP path to a file (that maps to a hash) if (urlIsAssetHash(_url)) { // We've detected that this is a hash - simply use AssetClient to request that asset -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - auto parts = _url.path().split(".", QString::SkipEmptyParts); -#else - auto parts = _url.path().split(".", Qt::SkipEmptyParts); -#endif + auto parts = _url.path().split(".", QTCOMPAT_SKIP_EMPTY_PARTS); auto hash = parts.length() > 0 ? parts[0] : ""; requestHash(hash); diff --git a/libraries/networking/src/HMACAuth.h b/libraries/networking/src/HMACAuth.h index 69eaffd52b..9b959e6009 100644 --- a/libraries/networking/src/HMACAuth.h +++ b/libraries/networking/src/HMACAuth.h @@ -4,6 +4,7 @@ // // Created by Simon Walton on 3/19/2018. // Copyright 2018 High Fidelity, Inc. +// Copyright 2022 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -14,6 +15,7 @@ #include #include +#include "QtCompatibility.h" #include class QUuid; @@ -39,11 +41,7 @@ public: HMACHash result(); private: -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - QMutex _lock { QMutex::Recursive }; -#else - QRecursiveMutex _lock; -#endif + QTCOMPAT_DECLARE_RECURSIVE_MUTEX(_lock); struct hmac_ctx_st* _hmacContext; AuthMethod _authMethod; }; diff --git a/libraries/networking/src/NLPacketList.h b/libraries/networking/src/NLPacketList.h index f367befab5..fb2a9f1d7e 100644 --- a/libraries/networking/src/NLPacketList.h +++ b/libraries/networking/src/NLPacketList.h @@ -28,18 +28,10 @@ public: qint64 getMaxSegmentSize() const override { return NLPacket::maxPayloadSize(_packetType, _isOrdered); } private: -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - NLPacketList(PacketType packetType, QByteArray extendedHeader = QByteArray(), bool isReliable = false, - bool isOrdered = false); - NLPacketList(udt::PacketList&& packetList); - NLPacketList(const NLPacketList& other) = delete; - NLPacketList& operator=(const NLPacketList& other) = delete; -#else Q_DISABLE_COPY(NLPacketList) NLPacketList(PacketType packetType, QByteArray extendedHeader = QByteArray(), bool isReliable = false, bool isOrdered = false); NLPacketList(udt::PacketList&& packetList); -#endif virtual std::unique_ptr createPacket() override; diff --git a/libraries/networking/src/Node.h b/libraries/networking/src/Node.h index a463d4d513..70473c678c 100644 --- a/libraries/networking/src/Node.h +++ b/libraries/networking/src/Node.h @@ -109,12 +109,7 @@ public: float getOutboundKbps() const; private: -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - Node(const Node &otherNode); - Node& operator=(Node otherNode); -#else Q_DISABLE_COPY(Node) -#endif NodeType_t _type; diff --git a/libraries/networking/src/NodeList.h b/libraries/networking/src/NodeList.h index fc6bd0c40d..f6ada6fce0 100644 --- a/libraries/networking/src/NodeList.h +++ b/libraries/networking/src/NodeList.h @@ -156,20 +156,11 @@ private slots: void maybeSendIgnoreSetToNode(SharedNodePointer node); private: -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - NodeList() : LimitedNodeList(INVALID_PORT, INVALID_PORT) { - assert(false); // Not implemented, needed for DependencyManager templates compile - } - NodeList(char ownerType, int socketListenPort = INVALID_PORT, int dtlsListenPort = INVALID_PORT); - NodeList(NodeList const&) = delete; // Don't implement, needed to avoid copies of singleton - void operator=(NodeList const&) = delete; // Don't implement, needed to avoid copies of singleton -#else Q_DISABLE_COPY(NodeList) NodeList() : LimitedNodeList(INVALID_PORT, INVALID_PORT) { assert(false); // Not implemented, needed for DependencyManager templates compile } NodeList(char ownerType, int socketListenPort = INVALID_PORT, int dtlsListenPort = INVALID_PORT); -#endif void processDomainServerAuthRequest(const QByteArray& packet); void requestAuthForDomainServer(); diff --git a/libraries/networking/src/udt/CongestionControl.h b/libraries/networking/src/udt/CongestionControl.h index 8c2ea3ae6a..4d3b225535 100644 --- a/libraries/networking/src/udt/CongestionControl.h +++ b/libraries/networking/src/udt/CongestionControl.h @@ -64,12 +64,7 @@ protected: SequenceNumber _sendCurrSeqNum; // current maximum seq num sent out private: -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - CongestionControl(const CongestionControl& other) = delete; - CongestionControl& operator=(const CongestionControl& other) = delete; -#else Q_DISABLE_COPY(CongestionControl); -#endif }; diff --git a/libraries/networking/src/udt/ControlPacket.h b/libraries/networking/src/udt/ControlPacket.h index ccc1afaf36..aa3878bbd5 100644 --- a/libraries/networking/src/udt/ControlPacket.h +++ b/libraries/networking/src/udt/ControlPacket.h @@ -48,22 +48,12 @@ public: void setType(Type type); private: -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - ControlPacket(Type type, qint64 size = -1); - ControlPacket(std::unique_ptr data, qint64 size, const SockAddr& senderSockAddr); - ControlPacket(ControlPacket&& other); - ControlPacket(const ControlPacket& other) = delete; - - ControlPacket& operator=(ControlPacket&& other); - ControlPacket& operator=(const ControlPacket& other) = delete; -#else Q_DISABLE_COPY(ControlPacket) ControlPacket(Type type, qint64 size = -1); ControlPacket(std::unique_ptr data, qint64 size, const SockAddr& senderSockAddr); ControlPacket(ControlPacket&& other); ControlPacket& operator=(ControlPacket&& other); -#endif // Header read/write void readType(); diff --git a/libraries/networking/src/udt/PacketList.h b/libraries/networking/src/udt/PacketList.h index 379ab97332..8339c0919c 100644 --- a/libraries/networking/src/udt/PacketList.h +++ b/libraries/networking/src/udt/PacketList.h @@ -85,12 +85,7 @@ private: friend class SendQueue; friend class Socket; -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - PacketList(const PacketList& other) = delete; - PacketList& operator=(const PacketList& other) = delete; -#else Q_DISABLE_COPY(PacketList) -#endif // Takes the first packet of the list and returns it. template std::unique_ptr takeFront(); diff --git a/libraries/networking/src/udt/SendQueue.h b/libraries/networking/src/udt/SendQueue.h index 20de294d8a..8029c056ba 100644 --- a/libraries/networking/src/udt/SendQueue.h +++ b/libraries/networking/src/udt/SendQueue.h @@ -5,6 +5,7 @@ // Created by Clement on 7/21/15. // Copyright 2015 High Fidelity, Inc. // Copyright 2021 Vircadia contributors. +// Copyright 2022 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -21,6 +22,7 @@ #include #include +#include "QtCompatibility.h" #include #include @@ -90,12 +92,7 @@ private slots: void run(); private: -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - SendQueue(SendQueue& other) = delete; - SendQueue(SendQueue&& other) = delete; -#else Q_DISABLE_COPY_MOVE(SendQueue) -#endif SendQueue(Socket* socket, SockAddr dest, SequenceNumber currentSequenceNumber, MessageNumber currentMessageNumber, bool hasReceivedHandshakeACK); diff --git a/libraries/octree/src/OctreeEditPacketSender.h b/libraries/octree/src/OctreeEditPacketSender.h index 40e1a3bb58..00ec5445d6 100644 --- a/libraries/octree/src/OctreeEditPacketSender.h +++ b/libraries/octree/src/OctreeEditPacketSender.h @@ -4,6 +4,7 @@ // // Created by Brad Hefta-Gaub on 8/12/13. // Copyright 2013 High Fidelity, Inc. +// Copyright 2022 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -14,6 +15,8 @@ #include +#include "QtCompatibility.h" + #include #include @@ -93,11 +96,7 @@ protected: int _maxPendingMessages; bool _releaseQueuedMessagesPending; QMutex _pendingPacketsLock; -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - QMutex _packetsQueueLock{ QMutex::Recursive }; -#else - QRecursiveMutex _packetsQueueLock; // don't let different threads release the queue while another thread is writing to it -#endif + QTCOMPAT_DECLARE_RECURSIVE_MUTEX(_packetsQueueLock); // don't let different threads release the queue while another thread is writing to it std::list _preServerEdits; // these will get packed into other larger packets std::list> _preServerSingleMessagePackets; // these will go out as is diff --git a/libraries/physics/src/PhysicalEntitySimulation.h b/libraries/physics/src/PhysicalEntitySimulation.h index 0fb3f4b2db..c4f064bf1a 100644 --- a/libraries/physics/src/PhysicalEntitySimulation.h +++ b/libraries/physics/src/PhysicalEntitySimulation.h @@ -4,6 +4,7 @@ // // Created by Andrew Meadows 2015.04.27 // Copyright 2015 High Fidelity, Inc. +// Copyright 2022 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -16,6 +17,8 @@ #include #include +#include "QtCompatibility.h" + #include #include @@ -129,11 +132,7 @@ private: QList _dynamicsToAdd; QSet _dynamicsToRemove; -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - QMutex _dynamicsMutex { QMutex::Recursive }; -#else - QRecursiveMutex _dynamicsMutex; -#endif + QTCOMPAT_DECLARE_RECURSIVE_MUTEX(_dynamicsMutex); workload::SpacePointer _space; uint64_t _nextBidExpiry; diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index 3b88c800b9..e5c5b27011 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -4,6 +4,7 @@ // // Created by Andrzej Kapolka on 10/18/13. // Copyright 2013 High Fidelity, Inc. +// Copyright 2022 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -11,6 +12,7 @@ #include "Model.h" +#include "QtCompatibility.h" #include #include #include @@ -1637,11 +1639,8 @@ std::set Model::getMeshIDsFromMaterialID(QString parentMaterialNam }; if (parentMaterialName.length() > 2 && parentMaterialName.startsWith("[") && parentMaterialName.endsWith("]")) { -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - QStringList list = parentMaterialName.split(",", QString::SkipEmptyParts); -#else - QStringList list = parentMaterialName.split(",", Qt::SkipEmptyParts); -#endif + QStringList list = parentMaterialName.split(",", QTCOMPAT_SKIP_EMPTY_PARTS); + for (int i = 0; i < list.length(); i++) { auto& target = list[i]; if (i == 0) { diff --git a/libraries/render-utils/src/Model.h b/libraries/render-utils/src/Model.h index e39a33f8d7..af33413a27 100644 --- a/libraries/render-utils/src/Model.h +++ b/libraries/render-utils/src/Model.h @@ -4,6 +4,7 @@ // // Created by Andrzej Kapolka on 10/18/13. // Copyright 2013 High Fidelity, Inc. +// Copyright 2022 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -12,6 +13,7 @@ #ifndef hifi_Model_h #define hifi_Model_h +#include "QtCompatibility.h" #include #include #include @@ -444,11 +446,7 @@ protected: QVector _blendedBlendshapeCoefficients; int _blendNumber { 0 }; -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - mutable QMutex _mutex{ QMutex::Recursive }; -#else - mutable QRecursiveMutex _mutex; -#endif + mutable QTCOMPAT_DECLARE_RECURSIVE_MUTEX(_mutex); bool _overrideModelTransform { false }; bool _triangleSetsValid { false }; diff --git a/libraries/script-engine/src/ScriptEngine.cpp b/libraries/script-engine/src/ScriptEngine.cpp index cae491ae48..47086834bb 100644 --- a/libraries/script-engine/src/ScriptEngine.cpp +++ b/libraries/script-engine/src/ScriptEngine.cpp @@ -4,6 +4,7 @@ // // Created by Brad Hefta-Gaub on 12/14/13. // Copyright 2013 High Fidelity, Inc. +// Copyright 2022 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -14,6 +15,7 @@ #include #include +#include "QtCompatibility.h" #include #include #include @@ -187,11 +189,8 @@ void inputControllerFromScriptValue(const QScriptValue &object, controller::Inpu // // Extract the url portion of a url that has been encoded with encodeEntityIdIntoEntityUrl(...) QString extractUrlFromEntityUrl(const QString& url) { -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - auto parts = url.split(' ', QString::SkipEmptyParts); -#else - auto parts = url.split(' ', Qt::SkipEmptyParts); -#endif + auto parts = url.split(' ', QTCOMPAT_SKIP_EMPTY_PARTS); + if (parts.length() > 0) { return parts[0]; } else { @@ -2390,11 +2389,7 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co bool passList = false; // assume unsafe QString whitelistPrefix = "[WHITELIST ENTITY SCRIPTS]"; QList safeURLPrefixes = { "file:///", "atp:", "cache:" }; -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - safeURLPrefixes += qEnvironmentVariable("EXTRA_WHITELIST").trimmed().split(QRegExp("\\s*,\\s*"), QString::SkipEmptyParts); -#else - safeURLPrefixes += qEnvironmentVariable("EXTRA_WHITELIST").trimmed().split(QRegExp("\\s*,\\s*"), Qt::SkipEmptyParts); -#endif + safeURLPrefixes += qEnvironmentVariable("EXTRA_WHITELIST").trimmed().split(QRegExp("\\s*,\\s*"), QTCOMPAT_SKIP_EMPTY_PARTS); // Entity Script Whitelist toggle check. Setting::Handle whitelistEnabled {"private/whitelistEnabled", false }; @@ -2405,11 +2400,7 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co // Pull SAFEURLS from the Interface.JSON settings. QVariant raw = Setting::Handle("private/settingsSafeURLS").get(); -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - QStringList settingsSafeURLS = raw.toString().trimmed().split(QRegExp("\\s*[,\r\n]+\\s*"), QString::SkipEmptyParts); -#else - QStringList settingsSafeURLS = raw.toString().trimmed().split(QRegExp("\\s*[,\r\n]+\\s*"), Qt::SkipEmptyParts); -#endif + QStringList settingsSafeURLS = raw.toString().trimmed().split(QRegExp("\\s*[,\r\n]+\\s*"), QTCOMPAT_SKIP_EMPTY_PARTS); safeURLPrefixes += settingsSafeURLS; // END Pull SAFEURLS from the Interface.JSON settings. diff --git a/libraries/shared/src/DependencyManager.h b/libraries/shared/src/DependencyManager.h index 79ba32db1e..91f1689961 100644 --- a/libraries/shared/src/DependencyManager.h +++ b/libraries/shared/src/DependencyManager.h @@ -4,6 +4,7 @@ // // Created by Clément Brisset on 12/10/14. // Copyright 2014 High Fidelity, Inc. +// Copyright 2022 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -12,6 +13,7 @@ #ifndef hifi_DependencyManager_h #define hifi_DependencyManager_h +#include "QtCompatibility.h" #include #include #include @@ -89,11 +91,7 @@ private: QHash> _instanceHash; QHash _inheritanceHash; -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - mutable QMutex _instanceHashMutex { QMutex::Recursive }; -#else - mutable QRecursiveMutex _instanceHashMutex; -#endif + mutable QTCOMPAT_DECLARE_RECURSIVE_MUTEX(_instanceHashMutex); mutable QMutex _inheritanceHashMutex; bool _exiting { false }; diff --git a/libraries/shared/src/QtCompatibility.h b/libraries/shared/src/QtCompatibility.h new file mode 100644 index 0000000000..cf19ce7565 --- /dev/null +++ b/libraries/shared/src/QtCompatibility.h @@ -0,0 +1,60 @@ +// +// QtCompatibility.h +// +// Created by Julian Groß on 2022-02-04 +// Copyright 2022 Overte e.V. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include + +// Compatibility with Qt < 5.13 +#ifndef Q_DISABLE_COPY + #define Q_DISABLE_COPY(className) \ + className(const className &) = delete;\ + className &operator=(const className &) = delete; +#endif + +// Compatibility with Qt < 5.13 +#ifndef Q_DISABLE_COPY_MOVE + #define Q_DISABLE_COPY_MOVE(className) \ + className(className & other) = delete;\ + className(className && other) = delete; +#endif + +// Compatibility with Qt < 5.15 +#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0)) + #define QTCOMPAT_ENDL endl +#else + #define QTCOMPAT_ENDL Qt::endl +#endif + +// Compatibility with Qt < 5.15 +#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0)) + #define QTCOMPAT_KEEP_EMPTY_PARTS QString::KeepEmptyParts +#else + #define QTCOMPAT_KEEP_EMPTY_PARTS Qt::KeepEmptyParts +#endif + +// Compatibility with Qt < 5.15 +#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0)) + #define QTCOMPAT_SPLIT_BEHAVIOR QString::SplitBehavior +#else + #define QTCOMPAT_SPLIT_BEHAVIOR Qt::SplitBehavior +#endif + +// Compatibility with Qt < 5.15 +#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0)) + #define QTCOMPAT_SKIP_EMPTY_PARTS QString::SkipEmptyParts +#else + #define QTCOMPAT_SKIP_EMPTY_PARTS Qt::SkipEmptyParts +#endif + +// Compatibility with Qt < 5.14 +#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) + #define QTCOMPAT_DECLARE_RECURSIVE_MUTEX(name) QMutex name { QMutex::Recursive } +#else + #define QTCOMPAT_DECLARE_RECURSIVE_MUTEX(name) QRecursiveMutex name +#endif diff --git a/libraries/shared/src/shared/FileUtils.cpp b/libraries/shared/src/shared/FileUtils.cpp index c23a262f68..983ead6a11 100644 --- a/libraries/shared/src/shared/FileUtils.cpp +++ b/libraries/shared/src/shared/FileUtils.cpp @@ -4,6 +4,7 @@ // // Created by Stojce Slavkovski on 12/23/13. // Copyright 2013 High Fidelity, Inc. +// Copyright 2022 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -14,6 +15,7 @@ #include +#include "../QtCompatibility.h" #include #include #include @@ -67,15 +69,9 @@ QString FileUtils::readFile(const QString& filename) { return result; } -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) -QStringList FileUtils::readLines(const QString& filename, QString::SplitBehavior splitBehavior) { - return readFile(filename).split(QRegularExpression("[\\r\\n]"), QString::SkipEmptyParts); +QStringList FileUtils::readLines(const QString& filename, QTCOMPAT_SPLIT_BEHAVIOR splitBehavior) { + return readFile(filename).split(QRegularExpression("[\\r\\n]"), QTCOMPAT_SKIP_EMPTY_PARTS); } -#else -QStringList FileUtils::readLines(const QString& filename, Qt::SplitBehavior splitBehavior) { - return readFile(filename).split(QRegularExpression("[\\r\\n]"), Qt::SkipEmptyParts); -} -#endif void FileUtils::locateFile(const QString& filePath) { diff --git a/libraries/shared/src/shared/FileUtils.h b/libraries/shared/src/shared/FileUtils.h index 9c0237456c..84d89ba4bb 100644 --- a/libraries/shared/src/shared/FileUtils.h +++ b/libraries/shared/src/shared/FileUtils.h @@ -4,6 +4,7 @@ // // Created by Stojce Slavkovski on 12/23/13. // Copyright 2013 High Fidelity, Inc. +// Copyright 2022 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -12,6 +13,7 @@ #ifndef hifi_FileUtils_h #define hifi_FileUtils_h +#include "../QtCompatibility.h" #include class FileUtils { @@ -24,11 +26,7 @@ public: static bool isRelative(const QString& fileName); static QString standardPath(QString subfolder); static QString readFile(const QString& filename); -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - static QStringList readLines(const QString& filename, QString::SplitBehavior splitBehavior = QString::KeepEmptyParts); -#else - static QStringList readLines(const QString& filename, Qt::SplitBehavior splitBehavior = Qt::KeepEmptyParts); -#endif + static QStringList readLines(const QString& filename, QTCOMPAT_SPLIT_BEHAVIOR splitBehavior = QTCOMPAT_KEEP_EMPTY_PARTS); static QString replaceDateTimeTokens(const QString& path); static QString computeDocumentPath(const QString& path); static bool canCreateFile(const QString& fullPath); diff --git a/libraries/ui/src/VrMenu.cpp b/libraries/ui/src/VrMenu.cpp index f7a2132aea..8003337eac 100644 --- a/libraries/ui/src/VrMenu.cpp +++ b/libraries/ui/src/VrMenu.cpp @@ -141,11 +141,7 @@ public: } private: -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - MenuUserData(const MenuUserData&); -#else Q_DISABLE_COPY(MenuUserData); -#endif QMetaObject::Connection _shutdownConnection; QMetaObject::Connection _changedConnection; diff --git a/tools/ac-client/src/ACClientApp.cpp b/tools/ac-client/src/ACClientApp.cpp index a709b150be..e2dfc390d5 100644 --- a/tools/ac-client/src/ACClientApp.cpp +++ b/tools/ac-client/src/ACClientApp.cpp @@ -4,6 +4,7 @@ // // Created by Seth Alves on 2016-10-5 // Copyright 2015 High Fidelity, Inc. +// Copyright 2022 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -11,6 +12,7 @@ #include "ACClientApp.h" +#include "QtCompatibility.h" #include #include #include @@ -49,11 +51,7 @@ ACClientApp::ACClientApp(int argc, char* argv[]) : parser.addOption(listenPortOption); if (!parser.parse(QCoreApplication::arguments())) { -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - qCritical() << parser.errorText() << endl; -#else - qCritical() << parser.errorText() << Qt::endl; -#endif + qCritical() << parser.errorText() << QTCOMPAT_ENDL; parser.showHelp(); Q_UNREACHABLE(); } diff --git a/tools/atp-client/src/ATPClientApp.cpp b/tools/atp-client/src/ATPClientApp.cpp index 8682a77eda..b900f9bec8 100644 --- a/tools/atp-client/src/ATPClientApp.cpp +++ b/tools/atp-client/src/ATPClientApp.cpp @@ -4,6 +4,7 @@ // // Created by Seth Alves on 2017-3-15 // Copyright 2017 High Fidelity, Inc. +// Copyright 2022 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -11,6 +12,7 @@ #include "ATPClientApp.h" +#include "QtCompatibility.h" #include #include #include @@ -59,11 +61,7 @@ ATPClientApp::ATPClientApp(int argc, char* argv[]) : parser.addOption(listenPortOption); if (!parser.parse(QCoreApplication::arguments())) { -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - qCritical() << parser.errorText() << endl; -#else - qCritical() << parser.errorText() << Qt::endl; -#endif + qCritical() << parser.errorText() << QTCOMPAT_ENDL; parser.showHelp(); Q_UNREACHABLE(); } diff --git a/tools/ice-client/src/ICEClientApp.cpp b/tools/ice-client/src/ICEClientApp.cpp index 6e842c7979..84d743e895 100644 --- a/tools/ice-client/src/ICEClientApp.cpp +++ b/tools/ice-client/src/ICEClientApp.cpp @@ -5,6 +5,7 @@ // Created by Seth Alves on 3/5/15. // Copyright 2015 High Fidelity, Inc. // Copyright 2021 Vircadia contributors. +// Copyright 2022 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -12,6 +13,7 @@ #include "ICEClientApp.h" +#include "QtCompatibility.h" #include #include #include @@ -47,11 +49,7 @@ ICEClientApp::ICEClientApp(int argc, char* argv[]) : parser.addOption(cacheSTUNOption); if (!parser.parse(QCoreApplication::arguments())) { -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - qCritical() << parser.errorText() << endl; -#else - qCritical() << parser.errorText() << Qt::endl; -#endif + qCritical() << parser.errorText() << QTCOMPAT_ENDL; parser.showHelp(); Q_UNREACHABLE(); } diff --git a/tools/nitpick/src/TestCreator.cpp b/tools/nitpick/src/TestCreator.cpp index d3cdb0a686..c16b7f46f1 100644 --- a/tools/nitpick/src/TestCreator.cpp +++ b/tools/nitpick/src/TestCreator.cpp @@ -3,6 +3,7 @@ // // Created by Nissim Hadar on 2 Nov 2017. // Copyright 2013 High Fidelity, Inc. +// Copyright 2022 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -10,6 +11,7 @@ #include "TestCreator.h" #include +#include "QtCompatibility.h" #include #include #include @@ -207,20 +209,11 @@ void TestCreator::appendTestResultsToFile(const TestResult& testResult, const QP // Create text file describing the failure QTextStream stream(&descriptionFile); -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - stream << "TestCreator in folder " << testResult._pathname.left(testResult._pathname.length() - 1) << endl; // remove trailing '/' - stream << "Expected image was " << testResult._expectedImageFilename << endl; - stream << "Actual image was " << testResult._actualImageFilename << endl; - stream << "Similarity index was " << testResult._errorGlobal << endl; - stream << "Worst tile was " << testResult._errorLocal << endl; -#else - stream << "TestCreator in folder " << testResult._pathname.left(testResult._pathname.length() - 1) << Qt::endl; // remove trailing '/' - stream << "Expected image was " << testResult._expectedImageFilename << Qt::endl; - stream << "Actual image was " << testResult._actualImageFilename << Qt::endl; - stream << "Similarity index was " << testResult._errorGlobal << Qt::endl; - stream << "Worst tile was " << testResult._errorLocal << Qt::endl; -#endif - + stream << "TestCreator in folder " << testResult._pathname.left(testResult._pathname.length() - 1) << QTCOMPAT_ENDL; // remove trailing '/' + stream << "Expected image was " << testResult._expectedImageFilename << QTCOMPAT_ENDL; + stream << "Actual image was " << testResult._actualImageFilename << QTCOMPAT_ENDL; + stream << "Similarity index was " << testResult._errorGlobal << QTCOMPAT_ENDL; + stream << "Worst tile was " << testResult._errorLocal << QTCOMPAT_ENDL; descriptionFile.close(); @@ -424,11 +417,7 @@ void TestCreator::includeTest(QTextStream& textStream, const QString& testPathna QString partialPath = extractPathFromTestsDown(testPathname); QString partialPathWithoutTests = partialPath.right(partialPath.length() - 7); -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - textStream << "Script.include(testsRootPath + \"" << partialPathWithoutTests + "\");" << endl; -#else - textStream << "Script.include(testsRootPath + \"" << partialPathWithoutTests + "\");" << Qt::endl; -#endif + textStream << "Script.include(testsRootPath + \"" << partialPathWithoutTests + "\");" << QTCOMPAT_ENDL; } void TestCreator::createTests(const QString& clientProfile) { @@ -1007,73 +996,39 @@ void TestCreator::createRecursiveScript(const QString& directory, bool interacti QTextStream textStream(&recursiveTestsFile); -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - textStream << "// This is an automatically generated file, created by nitpick" << endl; -#else - textStream << "// This is an automatically generated file, created by nitpick" << Qt::endl; -#endif + textStream << "// This is an automatically generated file, created by nitpick" << QTCOMPAT_ENDL; // Include 'nitpick.js' QString branch = nitpick->getSelectedBranch(); QString user = nitpick->getSelectedUser(); -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) textStream << "PATH_TO_THE_REPO_PATH_UTILS_FILE = \"https://raw.githubusercontent.com/" + user + "/hifi_tests/" + branch + "/tests/utils/branchUtils.js\";" - << endl; - textStream << "Script.include(PATH_TO_THE_REPO_PATH_UTILS_FILE);" << endl << endl; + << QTCOMPAT_ENDL; + textStream << "Script.include(PATH_TO_THE_REPO_PATH_UTILS_FILE);" << QTCOMPAT_ENDL << QTCOMPAT_ENDL; // The 'depth' variable is used to signal when to start running the recursive scripts - textStream << "if (typeof depth === 'undefined') {" << endl; - textStream << " depth = 0;" << endl; - textStream << " nitpick = createNitpick(Script.resolvePath(\".\"));" << endl; - textStream << " testsRootPath = nitpick.getTestsRootPath();" << endl << endl; - textStream << " nitpick.enableRecursive();" << endl; - textStream << " nitpick.enableAuto();" << endl; - textStream << "} else {" << endl; - textStream << " depth++" << endl; - textStream << "}" << endl << endl; + textStream << "if (typeof depth === 'undefined') {" << QTCOMPAT_ENDL; + textStream << " depth = 0;" << QTCOMPAT_ENDL; + textStream << " nitpick = createNitpick(Script.resolvePath(\".\"));" << QTCOMPAT_ENDL; + textStream << " testsRootPath = nitpick.getTestsRootPath();" << QTCOMPAT_ENDL << QTCOMPAT_ENDL; + textStream << " nitpick.enableRecursive();" << QTCOMPAT_ENDL; + textStream << " nitpick.enableAuto();" << QTCOMPAT_ENDL; + textStream << "} else {" << QTCOMPAT_ENDL; + textStream << " depth++" << QTCOMPAT_ENDL; + textStream << "}" << QTCOMPAT_ENDL << QTCOMPAT_ENDL; // Now include the test scripts for (int i = 0; i < directories.length(); ++i) { includeTest(textStream, directories.at(i)); } - textStream << endl; - textStream << "if (depth > 0) {" << endl; - textStream << " depth--;" << endl; - textStream << "} else {" << endl; - textStream << " nitpick.runRecursive();" << endl; - textStream << "}" << endl << endl; -#else - textStream << "PATH_TO_THE_REPO_PATH_UTILS_FILE = \"https://raw.githubusercontent.com/" + user + "/hifi_tests/" + branch + - "/tests/utils/branchUtils.js\";" - << Qt::endl; - textStream << "Script.include(PATH_TO_THE_REPO_PATH_UTILS_FILE);" << Qt::endl << Qt::endl; - - // The 'depth' variable is used to signal when to start running the recursive scripts - textStream << "if (typeof depth === 'undefined') {" << Qt::endl; - textStream << " depth = 0;" << Qt::endl; - textStream << " nitpick = createNitpick(Script.resolvePath(\".\"));" << Qt::endl; - textStream << " testsRootPath = nitpick.getTestsRootPath();" << Qt::endl << Qt::endl; - textStream << " nitpick.enableRecursive();" << Qt::endl; - textStream << " nitpick.enableAuto();" << Qt::endl; - textStream << "} else {" << Qt::endl; - textStream << " depth++" << Qt::endl; - textStream << "}" << Qt::endl << Qt::endl; - - // Now include the test scripts - for (int i = 0; i < directories.length(); ++i) { - includeTest(textStream, directories.at(i)); - } - - textStream << Qt::endl; - textStream << "if (depth > 0) {" << Qt::endl; - textStream << " depth--;" << Qt::endl; - textStream << "} else {" << Qt::endl; - textStream << " nitpick.runRecursive();" << Qt::endl; - textStream << "}" << Qt::endl << Qt::endl; -#endif + textStream << QTCOMPAT_ENDL; + textStream << "if (depth > 0) {" << QTCOMPAT_ENDL; + textStream << " depth--;" << QTCOMPAT_ENDL; + textStream << "} else {" << QTCOMPAT_ENDL; + textStream << " nitpick.runRecursive();" << QTCOMPAT_ENDL; + textStream << "}" << QTCOMPAT_ENDL << QTCOMPAT_ENDL; recursiveTestsFile.close(); diff --git a/tools/skeleton-dump/src/SkeletonDumpApp.cpp b/tools/skeleton-dump/src/SkeletonDumpApp.cpp index 7445daf2c9..40267a440e 100644 --- a/tools/skeleton-dump/src/SkeletonDumpApp.cpp +++ b/tools/skeleton-dump/src/SkeletonDumpApp.cpp @@ -4,12 +4,14 @@ // // Created by Anthony Thibault on 11/4/16. // Copyright 2016 High Fidelity, Inc. +// Copyright 2022 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "SkeletonDumpApp.h" +#include "QtCompatibility.h" #include #include #include @@ -29,11 +31,7 @@ SkeletonDumpApp::SkeletonDumpApp(int argc, char* argv[]) : QCoreApplication(argc parser.addOption(inputFilenameOption); if (!parser.parse(QCoreApplication::arguments())) { -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - qCritical() << parser.errorText() << endl; -#else - qCritical() << parser.errorText() << Qt::endl; -#endif + qCritical() << parser.errorText() << QTCOMPAT_ENDL; parser.showHelp(); _returnCode = 1; return; diff --git a/tools/vhacd-util/src/VHACDUtilApp.cpp b/tools/vhacd-util/src/VHACDUtilApp.cpp index bc9e79c2f7..09ccf02329 100644 --- a/tools/vhacd-util/src/VHACDUtilApp.cpp +++ b/tools/vhacd-util/src/VHACDUtilApp.cpp @@ -4,6 +4,7 @@ // // Created by Seth Alves on 3/5/15. // Copyright 2015 High Fidelity, Inc. +// Copyright 2022 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -11,6 +12,7 @@ #include "VHACDUtilApp.h" +#include "QtCompatibility.h" #include #include @@ -188,11 +190,7 @@ VHACDUtilApp::VHACDUtilApp(int argc, char* argv[]) : if (!parser.parse(QCoreApplication::arguments())) { -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - qCritical() << parser.errorText() << endl; -#else - qCritical() << parser.errorText() << Qt::endl; -#endif + qCritical() << parser.errorText() << QTCOMPAT_ENDL; parser.showHelp(); Q_UNREACHABLE(); }