Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Qt6, because Qt5 will be EOL after 26.05.2025. #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

find_package(Qt5 COMPONENTS Core Gui SerialPort REQUIRED)
find_package(Qt6 COMPONENTS Core Gui SerialPort REQUIRED)

if (UNIX)
include(FindPkgConfig)
Expand Down Expand Up @@ -194,9 +194,9 @@ target_compile_definitions(${PROJECT_NAME}
)

target_link_libraries(${PROJECT_NAME}
PRIVATE Qt${QT_VERSION_MAJOR}::Core
PRIVATE Qt${QT_VERSION_MAJOR}::Gui
PRIVATE Qt${QT_VERSION_MAJOR}::SerialPort
PRIVATE Qt${QT_VERSION_MAJOR}::Core
PRIVATE Qt${QT_VERSION_MAJOR}::Gui
PRIVATE Qt${QT_VERSION_MAJOR}::SerialPort
)

set_target_properties(${PROJECT_NAME}
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ Previously the library was a fixed part of deCONZ and build via QMake. The goal
```
apt-get install --no-install-recommends \
build-essential \
qt5-default \
libqt5serialport5-dev \
libqt5websockets5-dev \
qtdeclarative5-dev \
qt6-default \
libqt6serialport5-dev \
libqt6websockets5-dev \
qtdeclarative6-dev \
sqlite3 \
libsqlite3-dev \
libssl-dev \
Expand All @@ -38,10 +38,10 @@ cmake --build build

## Building on Windows

1. Qt5 for MSVC and Visual Studio 2019 needs to be installed
1. Qt6 for MSVC and Visual Studio 2019 needs to be installed

2. Configure and compile

```
cmake -DCMAKE_PREFIX_PATH=C:\Qt\5.15.2\msvc2019\lib\cmake\Qt5 -A Win32 -S . -B build
cmake -DCMAKE_PREFIX_PATH=C:\Qt\6.8.1\msvc2019\lib\cmake\Qt6 -A Win32 -S . -B build
```
2 changes: 1 addition & 1 deletion device_enumerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ bool tryCreateDeviceFile(const QString &path)

int ret = -2; // mknod returns -1 on error
bool ok = false;
int minor = path.rightRef(1).toInt(&ok);
int minor = QStringView(path).last(1).toInt(&ok);
const mode_t mode = S_IFCHR | 0660;

QFile devicesList(QLatin1String("/sys/fs/cgroup/devices/devices.list"));
Expand Down
20 changes: 10 additions & 10 deletions qhttprequest_compat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "deconz/qhttprequest_compat.h"

static constexpr char nullByte = '\0';
static constexpr QLatin1String emptyString{&nullByte, 0};
static constexpr QLatin1StringView emptyString{};

enum
{
Expand Down Expand Up @@ -49,25 +49,25 @@ class UrlDescriptor
std::array<Component, MaxComponents> m_comp{};

public:
QLatin1String path() const;
QLatin1String component(size_t i) const;
QLatin1StringView path() const;
QLatin1StringView component(size_t i) const;
Http::HttpStatus parseUrl(const char *buf, size_t length);
size_t componentCount() const { return m_compCount; }
};

QLatin1String UrlDescriptor::path() const
QLatin1StringView UrlDescriptor::path() const
{
if (m_length == 0)
{
return emptyString;
}
else if (m_query < m_length)
{
return QLatin1String(m_buf, m_query);
return QLatin1StringView(m_buf, m_query);
}
else
{
return QLatin1String(m_buf, m_length);
return QLatin1StringView(m_buf, m_length);
}
}

Expand Down Expand Up @@ -155,10 +155,10 @@ class QHttpRequestHeaderPrivate
};

UrlDescriptor urlDescriptor;
QLatin1String cMethod{emptyString};
QLatin1String cUrl{emptyString};
QLatin1String lastKey{emptyString};
QLatin1String lastKeyVal{emptyString};
QLatin1StringView cMethod{emptyString};
QLatin1StringView cUrl{emptyString};
QLatin1StringView lastKey{emptyString};
QLatin1StringView lastKeyVal{emptyString};

Http::HttpStatus parseStatus = Http::HttpStatusBadRequest;
uint16_t rawSize = 0;
Expand Down
3 changes: 2 additions & 1 deletion util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <QDir>
#include <QDesktopServices>
#include <QProcessEnvironment>
#include <QStandardPaths>
#include <limits.h>
#include <stdlib.h>
#include <memory>
Expand Down Expand Up @@ -242,7 +243,7 @@ QString getStorageLocation(StorageLocation location)

if (!found)
{
loc = QStandardPaths::standardLocations(QStandardPaths::DataLocation);
loc = QStandardPaths::standardLocations(QStandardPaths::AppLocalDataLocation);
if (!loc.isEmpty())
{
path = loc.first();
Expand Down
18 changes: 9 additions & 9 deletions zcl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ bool ZclAttribute::writeToStream(QDataStream &stream) const

case ZclOctedString:
{
if (d->m_value.isValid() && d->m_value.type() == QVariant::ByteArray)
if (d->m_value.isValid() && d->m_value.typeId() == QMetaType::QByteArray)
{
const QByteArray data = d->m_value.toByteArray();

Expand Down Expand Up @@ -3515,23 +3515,23 @@ void ZclDataBase::load(const QString &dbfile)
}
}

if (xmlAttributes.hasAttribute(QLatin1String("showas")))
if (xmlAttributes.hasAttribute(QLatin1StringView("showas")))
{
QStringRef showas = xmlAttributes.value(QLatin1String("showas"));
QStringView showas = xmlAttributes.value(QLatin1StringView("showas"));

if (showas == QLatin1String("hex"))
if (showas == QLatin1StringView("hex"))
{
attr.setNumericBase(16);
}
else if (showas == QLatin1String("bin"))
else if (showas == QLatin1StringView("bin"))
{
attr.setNumericBase(2);
}
else if (showas == QLatin1String("dec"))
else if (showas == QLatin1StringView("dec"))
{
attr.setNumericBase(10);
}
else if (showas == QLatin1String("slider"))
else if (showas == QLatin1StringView("slider"))
{
attr.setFormatHint(ZclAttribute::SliderFormat);
}
Expand Down Expand Up @@ -3594,9 +3594,9 @@ void ZclDataBase::load(const QString &dbfile)
}
}

if (xmlAttributes.hasAttribute(QLatin1String("listSize")))
if (xmlAttributes.hasAttribute(QLatin1StringView("listSize")))
{
QStringRef listSize = xmlAttributes.value(QLatin1String("listSize"));
QStringView listSize = xmlAttributes.value(QLatin1StringView("listSize"));
uint16_t attrId = listSize.toUShort(&ok, 16);

if (ok)
Expand Down