Qt6 support (#1363)

* Initial Qt6 config

* Change Package order to reingfence missing packages

* Update to QT 6.2.0

* Qt 6.2.0 updates

* macOS fix

* Simplify handling QT5 & Qt6 in parallel

* Updates for Windows

* Fix macos build

* macOS linker fix

* General support of QTDIR, update docu

* MaxOS add default qt directories

* Fix merge typo

* Update default CMakeSettings.json with installation path options

* Add additional libs required by Qt6 to CompileHowTo

* Fix Qt5 items

Co-authored-by: Paulchen-Panther <16664240+Paulchen-Panther@users.noreply.github.com>
This commit is contained in:
LordGrey
2021-11-16 17:12:56 +00:00
committed by GitHub
parent 3b1ca20b10
commit 25d79a9f3f
76 changed files with 645 additions and 541 deletions

View File

@@ -29,8 +29,8 @@ struct EffectCmdData
struct registerData
{
const hyperion::Components component;
const QString origin;
const QString owner;
const hyperion::Components callerComp;
hyperion::Components component;
QString origin;
QString owner;
hyperion::Components callerComp;
};

View File

@@ -127,7 +127,7 @@ namespace hyperion
// only test the topleft third of the image
int width = image.width() /3;
int height = image.height() / 3;
int maxSize = std::max(width, height);
int maxSize = qMax(width, height);
int firstNonBlackXPixelIndex = -1;
int firstNonBlackYPixelIndex = -1;
@@ -135,8 +135,8 @@ namespace hyperion
// find some pixel of the image
for (int i = 0; i < maxSize; ++i)
{
int x = std::min(i, width);
int y = std::min(i, height);
int x = qMin(i, width);
int y = qMin(i, height);
const Pixel_T & color = image(x, y);
if (!isBlack(color))

View File

@@ -55,7 +55,7 @@ public:
int minValue = 0;
int maxValue = 0;
int step = 0;
int default = 0;
int def = 0;
int currentValue = 0;
};

View File

@@ -79,7 +79,11 @@ public:
QJsonObject discover(const QJsonObject& params);
protected:
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
bool nativeEventFilter(const QByteArray & eventType, void * message, qintptr * result) override;
#else
bool nativeEventFilter(const QByteArray & eventType, void * message, long int * result) override;
#endif
private:

View File

@@ -49,7 +49,11 @@ public:
QJsonObject discover(const QJsonObject& params);
private:
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
bool nativeEventFilter(const QByteArray & eventType, void * message, qintptr * result) override;
#else
bool nativeEventFilter(const QByteArray & eventType, void * message, long int * result) override;
#endif
void freeResources();
void setupResources();
void setupRender();

View File

@@ -6,7 +6,11 @@
#include <utils/ColorRgb.h>
#include <utils/Components.h>
#include <QMutex>
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
#include <QRecursiveMutex>
#else
#include <QMutex>
#endif
class LedDevice;
class Hyperion;
@@ -124,8 +128,12 @@ private slots:
protected:
/// contains all available led device constructors
static LedDeviceRegistry _ledDeviceMap;
static QMutex _ledDeviceMapLock;
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
static QRecursiveMutex _ledDeviceMapLock;
#else
static QMutex _ledDeviceMapLock;
#endif
private:
///
/// @brief switchOff() the device and Stops the device thread

View File

@@ -2,7 +2,9 @@
#include <ssdp/SSDPServer.h>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QNetworkConfiguration>
#endif
// utils
#include <utils/settings.h>
@@ -89,12 +91,16 @@ private slots:
/// @brief Handle changes in the network configuration
/// @param conig New config
///
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
void handleNetworkConfigurationChanged(const QNetworkConfiguration &config);
#endif
private:
WebServer* _webserver;
QString _localAddress;
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QNetworkConfigurationManager* _NCA;
#endif
QString _uuid;
/// Targets for announcement
std::vector<QString> _deviceList;

View File

@@ -6,7 +6,12 @@
#include <QMap>
#include <QAtomicInteger>
#include <QList>
#include <QMutex>
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
#include <QRecursiveMutex>
#else
#include <QMutex>
#endif
// stl includes
#include <stdio.h>
@@ -81,7 +86,11 @@ protected:
private:
void write(const Logger::T_LOG_MESSAGE & message);
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
static QRecursiveMutex MapLock;
#else
static QMutex MapLock;
#endif
static QMap<QString,Logger*> LoggerMap;
static QAtomicInteger<int> GLOBAL_MIN_LOG_LEVEL;

View File

@@ -3,9 +3,15 @@
#include <QString>
#include <QStringList>
#include <QStringRef>
#include <QVector>
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
#include <QStringView>
#else
#include <QStringRef>
#endif
namespace QStringUtils {
enum class SplitBehavior {
@@ -31,42 +37,6 @@ inline QStringList split (const QString &string, QChar sep, SplitBehavior behavi
#endif
}
inline QStringList split (const QString &string, const QRegExp &rx, SplitBehavior behavior = SplitBehavior::KeepEmptyParts)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
return behavior == SplitBehavior::SkipEmptyParts ? string.split(rx, Qt::SkipEmptyParts) : string.split(rx, Qt::KeepEmptyParts);
#else
return behavior == SplitBehavior::SkipEmptyParts ? string.split(rx, QString::SkipEmptyParts) : string.split(rx, QString::KeepEmptyParts);
#endif
}
inline QVector<QStringRef> splitRef(const QString &string, const QString &sep, SplitBehavior behavior = SplitBehavior::KeepEmptyParts, Qt::CaseSensitivity cs = Qt::CaseSensitive)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
return string.splitRef(sep, behavior == SplitBehavior::SkipEmptyParts ? Qt::SkipEmptyParts : Qt::KeepEmptyParts , cs);
#else
return string.splitRef(sep, behavior == SplitBehavior::SkipEmptyParts ? QString::SkipEmptyParts : QString::KeepEmptyParts, cs);
#endif
}
inline QVector<QStringRef> splitRef(const QString &string, QChar sep, SplitBehavior behavior = SplitBehavior::KeepEmptyParts, Qt::CaseSensitivity cs = Qt::CaseSensitive)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
return string.splitRef(sep, behavior == SplitBehavior::SkipEmptyParts ? Qt::SkipEmptyParts : Qt::KeepEmptyParts, cs);
#else
return string.splitRef(sep, behavior == SplitBehavior::SkipEmptyParts ? QString::SkipEmptyParts : QString::KeepEmptyParts, cs);
#endif
}
inline QVector<QStringRef> splitRef(const QString &string, const QRegExp &rx, SplitBehavior behavior = SplitBehavior::KeepEmptyParts)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
return string.splitRef(rx,behavior == SplitBehavior::SkipEmptyParts ? Qt::SkipEmptyParts : Qt::KeepEmptyParts);
#else
return string.splitRef(rx, behavior == SplitBehavior::SkipEmptyParts ? QString::SkipEmptyParts : QString::KeepEmptyParts);
#endif
}
}
#endif // QSTRINGUTILS_H

View File

@@ -5,6 +5,8 @@
#include <hyperion/ColorAdjustment.h>
#include <hyperion/MultiColorAdjustment.h>
#include <hyperion/LedString.h>
#include <QRegularExpression>
// fg effect
#include <hyperion/Hyperion.h>
#include <hyperion/PriorityMuxer.h>
@@ -107,7 +109,7 @@ namespace hyperion {
MultiColorAdjustment * adjustment = new MultiColorAdjustment(ledCnt);
const QJsonValue adjustmentConfig = colorConfig["channelAdjustment"];
const QRegExp overallExp("([0-9]+(\\-[0-9]+)?)(,[ ]*([0-9]+(\\-[0-9]+)?))*");
const QRegularExpression overallExp("([0-9]+(\\-[0-9]+)?)(,[ ]*([0-9]+(\\-[0-9]+)?))*");
const QJsonArray & adjustmentConfigArray = adjustmentConfig.toArray();
for (signed i = 0; i < adjustmentConfigArray.size(); ++i)
@@ -125,7 +127,7 @@ namespace hyperion {
continue;
}
if (!overallExp.exactMatch(ledIndicesStr))
if (!overallExp.match(ledIndicesStr).hasMatch())
{
//Error(Logger::getInstance("HYPERION"), "Given led indices %d not correct format: %s", i, QSTRING_CSTR(ledIndicesStr));
continue;

View File

@@ -35,7 +35,7 @@ public:
/// @param schema The schema to use
/// @return true upon succes
///
bool setSchema(const QJsonObject & schema);
bool setSchema(const QJsonObject& schema);
///
/// @brief Validate a JSON structure
@@ -44,7 +44,7 @@ public:
/// @return The first boolean is true when the arguments is valid according to the schema. The second is true when the schema contains no errors
/// @return TODO: Check the Schema in SetSchema() function and remove the QPair result
///
QPair<bool, bool> validate(const QJsonObject & value, bool ignoreRequired = false);
QPair<bool, bool> validate(const QJsonObject& value, bool ignoreRequired = false);
///
/// @brief Auto correct a JSON structure
@@ -52,7 +52,7 @@ public:
/// @param ignoreRequired Ignore the "required" keyword in hyperion schema. Default is false
/// @return The corrected JSON structure
///
QJsonObject getAutoCorrectedConfig(const QJsonObject & value, bool ignoreRequired = false);
QJsonObject getAutoCorrectedConfig(const QJsonObject& value, bool ignoreRequired = false);
///
/// @return A list of error messages
@@ -67,14 +67,14 @@ private:
/// @param[in] value The value to validate
/// @param[in] schema The schema against which the value is validated
///
void validate(const QJsonValue &value, const QJsonObject & schema);
void validate(const QJsonValue& value, const QJsonObject& schema);
///
/// Adds the given message to the message-queue (with reference to current line-number)
///
/// @param[in] message The message to add to the queue
///
void setMessage(const QString & message);
void setMessage(const QString& message);
private:
// attribute check functions
@@ -85,7 +85,7 @@ private:
/// @param[in] value The given value
/// @param[in] schema The specified type (as json-value)
///
void checkType(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue);
void checkType(const QJsonValue& value, const QJsonValue& schema, const QJsonValue& defaultValue);
///
/// Checks is required properties of an json-object exist and if all properties are of the
@@ -95,7 +95,9 @@ private:
/// @param[in] value The given json-object
/// @param[in] schema The schema of the json-object
///
void checkProperties(const QJsonObject & value, const QJsonObject & schema);
void checkProperties(const QJsonObject& value, const QJsonObject& schema);
bool verifyDeps(const QString& property, const QJsonObject& value, const QJsonObject& schema);
///
/// Checks whether certain properties of a JSON object exist under certain dependencies and are the same.
@@ -105,7 +107,7 @@ private:
/// @param[in] value The given json-object
/// @param[in] schema The schema of the json-object
///
void checkDependencies(const QJsonObject & value, const QJsonObject & schema);
void checkDependencies(const QJsonObject& value, const QJsonObject& schema);
///
/// Verifies the additional configured properties of an json-object. If this is not the case
@@ -115,7 +117,7 @@ private:
/// @param schema The schema for the json-object
/// @param ignoredProperties The properties that were ignored
///
void checkAdditionalProperties(const QJsonObject & value, const QJsonValue & schema, const QStringList & ignoredProperties);
void checkAdditionalProperties(const QJsonObject& value, const QJsonValue& schema, const QStringList& ignoredProperties);
///
/// Checks if the given value is larger or equal to the specified value. If this is not the case
@@ -124,7 +126,7 @@ private:
/// @param[in] value The given value
/// @param[in] schema The minimum value (as json-value)
///
void checkMinimum(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue);
void checkMinimum(const QJsonValue& value, const QJsonValue& schema, const QJsonValue& defaultValue);
///
/// Checks if the given value is smaller or equal to the specified value. If this is not the
@@ -133,7 +135,7 @@ private:
/// @param[in] value The given value
/// @param[in] schema The maximum value (as json-value)
///
void checkMaximum(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue);
void checkMaximum(const QJsonValue& value, const QJsonValue& schema, const QJsonValue& defaultValue);
///
/// Checks if the given value is hugher than the specified value. If this is the
@@ -142,7 +144,7 @@ private:
/// @param value The given value
/// @param schema The minimum size specification (as json-value)
///
void checkMinLength(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue);
void checkMinLength(const QJsonValue& value, const QJsonValue& schema, const QJsonValue& defaultValue);
///
/// Checks if the given value is smaller than the specified value. If this is the
@@ -151,7 +153,7 @@ private:
/// @param value The given value
/// @param schema The maximum size specification (as json-value)
///
void checkMaxLength(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue);
void checkMaxLength(const QJsonValue& value, const QJsonValue& schema, const QJsonValue& defaultValue);
///
/// Validates all the items of an array.
@@ -159,7 +161,7 @@ private:
/// @param value The json-array
/// @param schema The schema for the items in the array
///
void checkItems(const QJsonValue & value, const QJsonObject & schema);
void checkItems(const QJsonValue& value, const QJsonObject& schema);
///
/// Checks if a given array has at least a minimum number of items. If this is not the case
@@ -168,7 +170,7 @@ private:
/// @param value The json-array
/// @param schema The minimum size specification (as json-value)
///
void checkMinItems(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue);
void checkMinItems(const QJsonValue& value, const QJsonValue& schema, const QJsonValue& defaultValue);
///
/// Checks if a given array has at most a maximum number of items. If this is not the case
@@ -177,7 +179,7 @@ private:
/// @param value The json-array
/// @param schema The maximum size specification (as json-value)
///
void checkMaxItems(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue);
void checkMaxItems(const QJsonValue& value, const QJsonValue& schema, const QJsonValue& defaultValue);
///
/// Checks if a given array contains only unique items. If this is not the case
@@ -186,7 +188,7 @@ private:
/// @param value The json-array
/// @param schema Bool to enable the check (as json-value)
///
void checkUniqueItems(const QJsonValue & value, const QJsonValue & schema);
void checkUniqueItems(const QJsonValue& value, const QJsonValue& schema);
///
/// Checks if an enum value is actually a valid value for that enum. If this is not the case
@@ -195,15 +197,7 @@ private:
/// @param value The enum value
/// @param schema The enum schema definition
///
void checkEnum(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue);
///
/// @brief Return the "default" value as string. If not found, an empty string is output
///
/// @param value The JSON value to search
/// @return The "default" value as string
///
QString getDefaultValue(const QJsonValue & value);
void checkEnum(const QJsonValue& value, const QJsonValue& schema, const QJsonValue& defaultValue);
private:
/// The schema of the entire json-configuration