From 6acf92f22ab058527e6fae13e0ecb6d419b700ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Fri, 8 Aug 2025 09:49:48 +0200 Subject: [PATCH] elgato: Add Qt6 support --- elgato/aveabulb.cpp | 26 +++++++++++++++++++++++++- elgato/aveabulb.h | 8 ++++---- elgato/elgato.pro | 8 +++----- elgato/integrationpluginelgato.cpp | 8 ++++---- elgato/integrationpluginelgato.h | 9 +++++---- 5 files changed, 41 insertions(+), 18 deletions(-) diff --git a/elgato/aveabulb.cpp b/elgato/aveabulb.cpp index 8545a3c7..f9cf4077 100644 --- a/elgato/aveabulb.cpp +++ b/elgato/aveabulb.cpp @@ -1,6 +1,6 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright 2013 - 2020, nymea GmbH +* Copyright 2013 - 2025, nymea GmbH * Contact: contact@nymea.io * * This file is part of nymea. @@ -68,7 +68,11 @@ bool AveaBulb::setPower(bool power) // Power off QByteArray command; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QDataStream stream(&command, QDataStream::WriteOnly); +#else QDataStream stream(&command, QIODevice::WriteOnly); +#endif stream.setByteOrder(QDataStream::LittleEndian); quint8 commandId = static_cast(ColorMessageColor); @@ -108,7 +112,11 @@ bool AveaBulb::setColor(const QColor &color) // Convert rgb to wrgb QByteArray command; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QDataStream stream(&command, QDataStream::WriteOnly); +#else QDataStream stream(&command, QIODevice::WriteOnly); +#endif stream.setByteOrder(QDataStream::LittleEndian); m_red = scaleColorValueUp(color.red()); @@ -133,7 +141,11 @@ bool AveaBulb::setBrightness(int percentage) qCDebug(dcElgato()) << "Brightness value" << percentage << "% -->" << brightnessValue; QByteArray command; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QDataStream stream(&command, QDataStream::WriteOnly); +#else QDataStream stream(&command, QIODevice::WriteOnly); +#endif stream.setByteOrder(QDataStream::LittleEndian); stream << static_cast(ColorMessageBrightness); stream << brightnessValue; @@ -216,7 +228,11 @@ bool AveaBulb::syncColor() // Convert rgb to wrgb QByteArray command; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QDataStream stream(&command, QDataStream::WriteOnly); +#else QDataStream stream(&command, QIODevice::WriteOnly); +#endif stream.setByteOrder(QDataStream::LittleEndian); quint8 commandId = static_cast(ColorMessageColor); @@ -301,7 +317,11 @@ void AveaBulb::onColorServiceStateChanged(const QLowEnergyService::ServiceState } // Enable notifications +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QLowEnergyDescriptor notificationDescriptor = m_colorCharacteristic.descriptor(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration); +#else QLowEnergyDescriptor notificationDescriptor = m_colorCharacteristic.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration); +#endif m_colorService->writeDescriptor(notificationDescriptor, QByteArray::fromHex("0100")); // Load current configuration @@ -318,7 +338,11 @@ void AveaBulb::onColorServiceCharacteristicChanged(const QLowEnergyCharacteristi qCDebug(dcElgato()) << "Color characteristic changed" << characteristic.uuid().toString() << value.toHex(); QByteArray payload = value; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QDataStream stream(&payload, QDataStream::WriteOnly); +#else QDataStream stream(&payload, QIODevice::ReadOnly); +#endif quint16 messageType; stream.setByteOrder(QDataStream::LittleEndian); stream >> messageType; diff --git a/elgato/aveabulb.h b/elgato/aveabulb.h index f84d310b..9f4b02a6 100644 --- a/elgato/aveabulb.h +++ b/elgato/aveabulb.h @@ -1,6 +1,6 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright 2013 - 2020, nymea GmbH +* Copyright 2013 - 2025, nymea GmbH * Contact: contact@nymea.io * * This file is part of nymea. @@ -35,9 +35,9 @@ #include #include -#include "typeutils.h" -#include "integrations/thing.h" -#include "hardware/bluetoothlowenergy/bluetoothlowenergydevice.h" +#include +#include +#include static QBluetoothUuid colorServiceUuid = QBluetoothUuid(QUuid("f815e810-456c-6761-746f-4d756e696368")); static QBluetoothUuid colorCharacteristicUuid = QBluetoothUuid(QUuid("f815e811-456c-6761-746f-4d756e696368")); diff --git a/elgato/elgato.pro b/elgato/elgato.pro index 758abd4c..d2b3f4c2 100644 --- a/elgato/elgato.pro +++ b/elgato/elgato.pro @@ -1,16 +1,14 @@ include(../plugins.pri) -QT += bluetooth - -TARGET = $$qtLibraryTarget(nymea_integrationpluginelgato) +QT *= bluetooth gui SOURCES += \ integrationpluginelgato.cpp \ - aveabulb.cpp \ + aveabulb.cpp HEADERS += \ integrationpluginelgato.h \ - aveabulb.h \ + aveabulb.h diff --git a/elgato/integrationpluginelgato.cpp b/elgato/integrationpluginelgato.cpp index 65961388..b95320d7 100644 --- a/elgato/integrationpluginelgato.cpp +++ b/elgato/integrationpluginelgato.cpp @@ -1,6 +1,6 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright 2013 - 2020, nymea GmbH +* Copyright 2013 - 2025, nymea GmbH * Contact: contact@nymea.io * * This file is part of nymea. @@ -383,9 +383,9 @@ #include "integrationpluginelgato.h" -#include "integrations/thing.h" -#include "plugininfo.h" -#include "hardware/bluetoothlowenergy/bluetoothlowenergymanager.h" +#include +#include +#include IntegrationPluginElgato::IntegrationPluginElgato() { diff --git a/elgato/integrationpluginelgato.h b/elgato/integrationpluginelgato.h index e861fb63..bbf03893 100644 --- a/elgato/integrationpluginelgato.h +++ b/elgato/integrationpluginelgato.h @@ -1,6 +1,6 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright 2013 - 2020, nymea GmbH +* Copyright 2013 - 2025, nymea GmbH * Contact: contact@nymea.io * * This file is part of nymea. @@ -31,10 +31,11 @@ #ifndef INTEGRATIONPLUGINELGATO_H #define INTEGRATIONPLUGINELGATO_H +#include +#include +#include + #include "aveabulb.h" -#include "plugintimer.h" -#include "integrations/integrationplugin.h" -#include "hardware/bluetoothlowenergy/bluetoothlowenergydevice.h" class IntegrationPluginElgato : public IntegrationPlugin {