Skip to content

Commit f4008aa

Browse files
committed
Support building with Qt6
1 parent bff5a8d commit f4008aa

File tree

6 files changed

+33
-9
lines changed

6 files changed

+33
-9
lines changed

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ include(AsteroidCMakeSettings)
1919

2020
set(ASTEROID_MODULES_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/asteroidapp/cmake)
2121

22-
find_package(Qt5 ${QT_MIN_VERSION} COMPONENTS DBus Qml Quick Svg REQUIRED)
22+
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} COMPONENTS DBus Qml Quick Svg REQUIRED)
2323
if (WITH_ASTEROIDAPP)
24-
find_package(Mlite5 MODULE REQUIRED)
25-
find_package(Mapplauncherd_qt5 MODULE REQUIRED)
24+
find_package(Mlite${QT_MAJOR_VERSION} MODULE REQUIRED)
25+
find_package(Mapplauncherd_qt${QT_MAJOR_VERSION} MODULE REQUIRED)
2626
endif()
2727

2828
ecm_find_qmlmodule(QtQuick.VirtualKeyboard 2.1)

src/controls/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ add_custom_command(
8787
)
8888

8989
target_link_libraries(asteroidcontrolsplugin
90-
Qt5::Qml
91-
Qt5::Quick
92-
Qt5::Svg)
90+
Qt::Qml
91+
Qt::Quick
92+
Qt::Svg)
9393

9494
install(TARGETS asteroidcontrolsplugin
9595
DESTINATION ${INSTALL_QML_IMPORT_DIR}/org/asteroid/controls)

src/controls/src/icon.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
#include <QPainter>
3333
#include <QIcon>
3434
#include <QSvgRenderer>
35+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
36+
#include <QFile>
37+
#endif
3538

3639
#define ICONS_DIRECTORY "/usr/share/icons/asteroid/"
3740

@@ -79,9 +82,18 @@ void Icon::paint(QPainter *painter)
7982
painter->drawPixmap(0, 0, width(), height(), m_pixmap);
8083
}
8184

85+
86+
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
8287
void Icon::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
88+
#else
89+
void Icon::geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry)
90+
#endif
8391
{
92+
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
8493
QQuickPaintedItem::geometryChanged(newGeometry, oldGeometry);
94+
#else
95+
QQuickPaintedItem::geometryChange(newGeometry, oldGeometry);
96+
#endif
8597
if(newGeometry.size() == oldGeometry.size() || newGeometry.width() == 0 || newGeometry.height() == 0)
8698
return;
8799
updateBasePixmap();

src/controls/src/icon.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ class Icon : public QQuickPaintedItem
5252

5353
void paint(QPainter *painter) override;
5454

55+
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
5556
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
57+
#else
58+
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
59+
#endif
5660

5761
signals:
5862
void nameChanged();

src/utils/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ set(HEADERS
1212
add_library(asteroidutilsplugin ${SRC} ${HEADERS})
1313

1414
target_link_libraries(asteroidutilsplugin
15-
Qt5::DBus
16-
Qt5::Qml
17-
Qt5::Quick)
15+
Qt::DBus
16+
Qt::Qml
17+
Qt::Quick)
1818

1919
install(TARGETS asteroidutilsplugin
2020
DESTINATION ${INSTALL_QML_IMPORT_DIR}/org/asteroid/utils)

src/utils/src/deviceinfo.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,23 @@ DeviceInfo::DeviceInfo()
3535
QFile host(HOST_FILE);
3636
if (host.open(QIODevice::ReadOnly | QIODevice::Text)) {
3737
QTextStream in(&host);
38+
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
3839
in.setCodec("UTF-8");
40+
#else
41+
in.setEncoding(QStringConverter::Utf8);
42+
#endif
3943
m_hostname = in.readLine();
4044
host.close();
4145
}
4246

4347
QFile release(OS_RELEASE_FILE);
4448
if (release.open(QIODevice::ReadOnly | QIODevice::Text)) {
4549
QTextStream in(&release);
50+
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
4651
in.setCodec("UTF-8");
52+
#else
53+
in.setEncoding(QStringConverter::Utf8);
54+
#endif
4755
QString line = in.readLine();
4856
for (bool searching{true}; searching && !in.atEnd(); line = in.readLine()) {
4957
if (line.startsWith("BUILD_ID")) {

0 commit comments

Comments
 (0)