Skip to content

Commit

Permalink
Merge pull request #14 from jmlich/master
Browse files Browse the repository at this point in the history
Fix build with Qt6
  • Loading branch information
rainemak authored Sep 19, 2023
2 parents 68eae38 + 2dcadbf commit 4db4a98
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/nemo-dbus/dbus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ QVariant demarshallDBusArgument(const QVariant &val, int depth)
for (int i = 0; i < arr.size(); ++i)
lst << QVariant::fromValue(static_cast<quint8>(arr[i]));
res = QVariant::fromValue(lst);
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
} else if (type == val.typeId()) {
#else
} else if (type == val.type()) {
#endif
/* Already is built-in qt type, use as is */
res = val;
} else if (type == qMetaTypeId<QDBusVariant>()) {
Expand Down
4 changes: 4 additions & 0 deletions src/plugin/declarativedbusadaptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,11 @@ QString DeclarativeDBusAdaptor::introspect(const QString &) const

QDBusArgument &operator << (QDBusArgument &argument, const QVariant &value)
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
switch (value.typeId()) {
#else
switch (value.type()) {
#endif
case QVariant::String:
return argument << value.toString();
case QVariant::StringList:
Expand Down
16 changes: 16 additions & 0 deletions src/plugin/declarativedbusinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,10 +470,18 @@ static void flattenVariantArrayGuessType(QVariant &var)
/* If all items in the list do not share the same type:
* use as is -> each value will be wrapped in variant
* container */
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
int t = arr[0].typeId();
#else
int t = arr[0].type();
#endif
int n = arr.size();
for (int i = 1; i < n; ++i) {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
if (arr[i].typeId() != t)
#else
if (arr[i].type() != t)
#endif
return;
}

Expand All @@ -494,7 +502,11 @@ static void flattenVariantArrayGuessType(QVariant &var)
/* Unhandled types are encoded as variant:array:variant:val
* instead of variant:array:val what we actually want.
*/
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
qWarning("unhandled array type: %d (%s)", t, QMetaType(t).name());
#else
qWarning("unhandled array type: %d (%s)", t, QVariant::typeToName(t));
#endif
break;
}
}
Expand Down Expand Up @@ -870,7 +882,11 @@ void DeclarativeDBusInterface::signalHandler(const QDBusMessage &message)

for (int i = 0; i < normalized.count(); ++i) {
const QVariant &arg = normalized.at(i);
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
args[i] = QGenericArgument(QMetaType(arg.metaType()).name(), arg.data());
#else
args[i] = Q_ARG(QVariant, arg);
#endif
}

QMetaMethod method = m_signals.value(message.member());
Expand Down

0 comments on commit 4db4a98

Please sign in to comment.