Browse Source

better qt6 compat

Signed-off-by: falkTX <falktx@falktx.com>
pull/1775/head
falkTX 1 year ago
parent
commit
955b1bb88c
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
2 changed files with 42 additions and 15 deletions
  1. +2
    -1
      source/frontend/pluginlist/pluginlistdialog.cpp
  2. +40
    -14
      source/frontend/utils/qsafesettings.cpp

+ 2
- 1
source/frontend/pluginlist/pluginlistdialog.cpp View File

@@ -1015,7 +1015,8 @@ struct PluginListDialog::Self {
// ------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------
// AU (extra non-cached) // AU (extra non-cached)


QList<QPluginInfoList> auPlugins32 = settingsDB.valuePluginInfoList("Plugins/AU_posix32");
QList<QPluginInfoList> auPlugins32;
auPlugins32 += settingsDB.valuePluginInfoList("Plugins/AU_posix32");
#endif #endif


// ------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------


+ 40
- 14
source/frontend/utils/qsafesettings.cpp View File

@@ -17,19 +17,17 @@


#include "qsafesettings.hpp" #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 bool QSafeSettings::valueBool(const QString& key, const bool defaultValue) const
{ {
QVariant var(value(key, defaultValue)); QVariant var(value(key, defaultValue));


if (!var.isNull() && var.convert(QT6_COMPAT(QVariant::Bool)) && var.isValid())
#if QT_VERSION >= 0x60000
if (!var.isNull() && var.convert(QMetaType(QMetaType::Bool)) && var.isValid())
#else
if (!var.isNull() && var.convert(QVariant::Bool) && var.isValid())
#endif
return var.toBool(); return var.toBool();


return defaultValue; return defaultValue;
@@ -39,7 +37,11 @@ Qt::CheckState QSafeSettings::valueCheckState(const QString& key, const Qt::Chec
{ {
QVariant var(value(key, defaultValue)); QVariant var(value(key, defaultValue));


if (!var.isNull() && var.convert(QT6_COMPAT(QVariant::UInt)) && var.isValid())
#if QT_VERSION >= 0x60000
if (!var.isNull() && var.convert(QMetaType(QMetaType::UInt)) && var.isValid())
#else
if (!var.isNull() && var.convert(QVariant::UInt) && var.isValid())
#endif
{ {
const uint value = var.toUInt(); const uint value = var.toUInt();


@@ -59,7 +61,11 @@ int QSafeSettings::valueIntPositive(const QString& key, const int defaultValue)
{ {
QVariant var(value(key, defaultValue)); QVariant var(value(key, defaultValue));


if (!var.isNull() && var.convert(QT6_COMPAT(QVariant::Int)) && var.isValid())
#if QT_VERSION >= 0x60000
if (!var.isNull() && var.convert(QMetaType(QMetaType::Int)) && var.isValid())
#else
if (!var.isNull() && var.convert(QVariant::Int) && var.isValid())
#endif
{ {
const int value = var.toInt(); const int value = var.toInt();
return value >= 0 ? value : defaultValue; return value >= 0 ? value : defaultValue;
@@ -72,7 +78,11 @@ uint QSafeSettings::valueUInt(const QString& key, const uint defaultValue) const
{ {
QVariant var(value(key, defaultValue)); QVariant var(value(key, defaultValue));


if (!var.isNull() && var.convert(QT6_COMPAT(QVariant::UInt)) && var.isValid())
#if QT_VERSION >= 0x60000
if (!var.isNull() && var.convert(QMetaType(QMetaType::UInt)) && var.isValid())
#else
if (!var.isNull() && var.convert(QVariant::UInt) && var.isValid())
#endif
return var.toUInt(); return var.toUInt();


return defaultValue; return defaultValue;
@@ -82,7 +92,11 @@ double QSafeSettings::valueDouble(const QString& key, const double defaultValue)
{ {
QVariant var(value(key, defaultValue)); QVariant var(value(key, defaultValue));


if (!var.isNull() && var.convert(QT6_COMPAT(QVariant::Double)) && var.isValid())
#if QT_VERSION >= 0x60000
if (!var.isNull() && var.convert(QMetaType(QMetaType::Double)) && var.isValid())
#else
if (!var.isNull() && var.convert(QVariant::Double) && var.isValid())
#endif
return var.toDouble(); return var.toDouble();


return defaultValue; return defaultValue;
@@ -92,7 +106,11 @@ QString QSafeSettings::valueString(const QString& key, const QString& defaultVal
{ {
QVariant var(value(key, defaultValue)); QVariant var(value(key, defaultValue));


if (!var.isNull() && var.convert(QT6_COMPAT(QVariant::String)) && var.isValid())
#if QT_VERSION >= 0x60000
if (!var.isNull() && var.convert(QMetaType(QMetaType::QString)) && var.isValid())
#else
if (!var.isNull() && var.convert(QVariant::String) && var.isValid())
#endif
return var.toString(); return var.toString();


return defaultValue; return defaultValue;
@@ -102,7 +120,11 @@ QByteArray QSafeSettings::valueByteArray(const QString& key, const QByteArray de
{ {
QVariant var(value(key, defaultValue)); QVariant var(value(key, defaultValue));


if (!var.isNull() && var.convert(QT6_COMPAT(QVariant::ByteArray)) && var.isValid())
#if QT_VERSION >= 0x60000
if (!var.isNull() && var.convert(QMetaType(QMetaType::QByteArray)) && var.isValid())
#else
if (!var.isNull() && var.convert(QVariant::ByteArray) && var.isValid())
#endif
return var.toByteArray(); return var.toByteArray();


return defaultValue; return defaultValue;
@@ -112,7 +134,11 @@ QStringList QSafeSettings::valueStringList(const QString& key, const QStringList
{ {
QVariant var(value(key, defaultValue)); QVariant var(value(key, defaultValue));


if (!var.isNull() && var.convert(QT6_COMPAT(QVariant::StringList)) && var.isValid())
#if QT_VERSION >= 0x60000
if (!var.isNull() && var.convert(QMetaType(QMetaType::QStringList)) && var.isValid())
#else
if (!var.isNull() && var.convert(QVariant::StringList) && var.isValid())
#endif
return var.toStringList(); return var.toStringList();


return defaultValue; return defaultValue;


Loading…
Cancel
Save