From 933c3c681220f2387b0102cb770a28588d3da701 Mon Sep 17 00:00:00 2001 From: falkTX Date: Sat, 6 May 2023 20:36:50 +0200 Subject: [PATCH] Fix frontend qt6 compat Signed-off-by: falkTX --- .../frontend/pluginlist/pluginlistdialog.cpp | 7 +++++ source/frontend/utils/qsafesettings.cpp | 28 +++++++++++-------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/source/frontend/pluginlist/pluginlistdialog.cpp b/source/frontend/pluginlist/pluginlistdialog.cpp index d40c5864b..f5e57dde9 100644 --- a/source/frontend/pluginlist/pluginlistdialog.cpp +++ b/source/frontend/pluginlist/pluginlistdialog.cpp @@ -455,6 +455,9 @@ public: */ return {}; + + // TODO + (void)key; } void setValue(const QString& key, const uint value) @@ -464,6 +467,10 @@ public: void setValue(const QString& key, const QPluginInfoList& value) { + return; + // TODO + (void)key; + (void)value; } }; diff --git a/source/frontend/utils/qsafesettings.cpp b/source/frontend/utils/qsafesettings.cpp index 04ef6f9ac..df00075f1 100644 --- a/source/frontend/utils/qsafesettings.cpp +++ b/source/frontend/utils/qsafesettings.cpp @@ -1,6 +1,6 @@ /* * Carla plugin host - * Copyright (C) 2011-2022 Filipe Coelho + * Copyright (C) 2011-2023 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -17,23 +17,29 @@ #include "qsafesettings.hpp" +#if QT_VERSION >= 0x60000 + #define QT6_COMPAT(type) QMetaType(type) +#else + #define QT6_COMPAT(type) type +#endif + //--------------------------------------------------------------------------------------------------------------------- bool QSafeSettings::valueBool(const QString& key, const bool defaultValue) const { QVariant var(value(key, defaultValue)); - if (!var.isNull() && var.convert(QVariant::Bool) && var.isValid()) + if (!var.isNull() && var.convert(QT6_COMPAT(QVariant::Bool)) && var.isValid()) return var.toBool(); - - return defaultValue; + + return defaultValue; } Qt::CheckState QSafeSettings::valueCheckState(const QString& key, const Qt::CheckState defaultValue) const { QVariant var(value(key, defaultValue)); - if (!var.isNull() && var.convert(QVariant::UInt) && var.isValid()) + if (!var.isNull() && var.convert(QT6_COMPAT(QVariant::UInt)) && var.isValid()) { const uint value = var.toUInt(); @@ -53,7 +59,7 @@ int QSafeSettings::valueIntPositive(const QString& key, const int defaultValue) { QVariant var(value(key, defaultValue)); - if (!var.isNull() && var.convert(QVariant::Int) && var.isValid()) + if (!var.isNull() && var.convert(QT6_COMPAT(QVariant::Int)) && var.isValid()) { const int value = var.toInt(); return value >= 0 ? value : defaultValue; @@ -66,7 +72,7 @@ uint QSafeSettings::valueUInt(const QString& key, const uint defaultValue) const { QVariant var(value(key, defaultValue)); - if (!var.isNull() && var.convert(QVariant::UInt) && var.isValid()) + if (!var.isNull() && var.convert(QT6_COMPAT(QVariant::UInt)) && var.isValid()) return var.toUInt(); return defaultValue; @@ -76,7 +82,7 @@ double QSafeSettings::valueDouble(const QString& key, const double defaultValue) { QVariant var(value(key, defaultValue)); - if (!var.isNull() && var.convert(QVariant::Double) && var.isValid()) + if (!var.isNull() && var.convert(QT6_COMPAT(QVariant::Double)) && var.isValid()) return var.toDouble(); return defaultValue; @@ -86,7 +92,7 @@ QString QSafeSettings::valueString(const QString& key, const QString& defaultVal { QVariant var(value(key, defaultValue)); - if (!var.isNull() && var.convert(QVariant::String) && var.isValid()) + if (!var.isNull() && var.convert(QT6_COMPAT(QVariant::String)) && var.isValid()) return var.toString(); return defaultValue; @@ -96,7 +102,7 @@ QByteArray QSafeSettings::valueByteArray(const QString& key, const QByteArray de { QVariant var(value(key, defaultValue)); - if (!var.isNull() && var.convert(QVariant::ByteArray) && var.isValid()) + if (!var.isNull() && var.convert(QT6_COMPAT(QVariant::ByteArray)) && var.isValid()) return var.toByteArray(); return defaultValue; @@ -106,7 +112,7 @@ QStringList QSafeSettings::valueStringList(const QString& key, const QStringList { QVariant var(value(key, defaultValue)); - if (!var.isNull() && var.convert(QVariant::StringList) && var.isValid()) + if (!var.isNull() && var.convert(QT6_COMPAT(QVariant::StringList)) && var.isValid()) return var.toStringList(); return defaultValue;