Browse Source

Fix frontend qt6 compat

Signed-off-by: falkTX <falktx@falktx.com>
pull/1775/head
falkTX 1 year ago
parent
commit
933c3c6812
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
2 changed files with 24 additions and 11 deletions
  1. +7
    -0
      source/frontend/pluginlist/pluginlistdialog.cpp
  2. +17
    -11
      source/frontend/utils/qsafesettings.cpp

+ 7
- 0
source/frontend/pluginlist/pluginlistdialog.cpp View File

@@ -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;
}
};



+ 17
- 11
source/frontend/utils/qsafesettings.cpp View File

@@ -1,6 +1,6 @@
/*
* Carla plugin host
* Copyright (C) 2011-2022 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2011-2023 Filipe Coelho <falktx@falktx.com>
*
* 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;


Loading…
Cancel
Save