From 602ad7c3a2b073a304737fcb1894b2df3f0560d0 Mon Sep 17 00:00:00 2001 From: Jami Kettunen Date: Wed, 13 Nov 2024 02:15:48 +0200 Subject: [PATCH 01/15] org.controls.asteroid -> org.asteroid.controls This is a typo in all the existing docs. --- src/controls/qml/CircularSpinner.qml | 2 +- src/controls/qml/Dims.qml | 2 +- src/controls/qml/IconButton.qml | 2 +- src/controls/qml/IntSelector.qml | 2 +- src/controls/qml/Label.qml | 2 +- src/controls/qml/LabeledActionButton.qml | 2 +- src/controls/qml/LabeledSwitch.qml | 2 +- src/controls/qml/LayerStack.qml | 2 +- src/controls/qml/Marquee.qml | 2 +- src/controls/qml/PageDot.qml | 2 +- src/controls/qml/PageHeader.qml | 2 +- src/controls/qml/Spinner.qml | 2 +- src/controls/qml/StatusPage.qml | 2 +- src/controls/qml/Switch.qml | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/controls/qml/CircularSpinner.qml b/src/controls/qml/CircularSpinner.qml index 59fece4..b47548e 100644 --- a/src/controls/qml/CircularSpinner.qml +++ b/src/controls/qml/CircularSpinner.qml @@ -31,7 +31,7 @@ import org.asteroid.controls 1.0 \qml import QtQuick 2.9 - import org.controls.asteroid 1.0 + import org.asteroid.controls 1.0 CircularSpinner { id: rating diff --git a/src/controls/qml/Dims.qml b/src/controls/qml/Dims.qml index c4a79a6..1dc545f 100644 --- a/src/controls/qml/Dims.qml +++ b/src/controls/qml/Dims.qml @@ -41,7 +41,7 @@ pragma Singleton \qml import QtQuick 2.0 - import org.controls.asteroid 1.0 + import org.asteroid.controls 1.0 Rectangle { width: Dims.w(80) // 80 % of screen width diff --git a/src/controls/qml/IconButton.qml b/src/controls/qml/IconButton.qml index 75be41a..46eef27 100644 --- a/src/controls/qml/IconButton.qml +++ b/src/controls/qml/IconButton.qml @@ -21,7 +21,7 @@ import org.asteroid.controls 1.0 /*! \qmltype IconButton - \inqmlmodule org.controls.asteroid 1.0 + \inqmlmodule org.asteroid.controls 1.0 \brief Provides a virtual button with settable icon. diff --git a/src/controls/qml/IntSelector.qml b/src/controls/qml/IntSelector.qml index 16bb1cb..72ae390 100644 --- a/src/controls/qml/IntSelector.qml +++ b/src/controls/qml/IntSelector.qml @@ -40,7 +40,7 @@ import org.asteroid.controls 1.0 \qml import QtQuick 2.0 - import org.controls.asteroid 1.0 + import org.asteroid.controls 1.0 Item { IntSelector { diff --git a/src/controls/qml/Label.qml b/src/controls/qml/Label.qml index 77ce82a..ddfe7c8 100644 --- a/src/controls/qml/Label.qml +++ b/src/controls/qml/Label.qml @@ -20,7 +20,7 @@ import org.asteroid.controls 1.0 /*! \qmltype Label - \inqmlmodule org.controls.asteroid 1.0 + \inqmlmodule org.asteroid.controls 1.0 \brief Provides a way to get a text label sized for AsteroidOS. diff --git a/src/controls/qml/LabeledActionButton.qml b/src/controls/qml/LabeledActionButton.qml index 06c11ba..910ea38 100644 --- a/src/controls/qml/LabeledActionButton.qml +++ b/src/controls/qml/LabeledActionButton.qml @@ -35,7 +35,7 @@ import org.asteroid.controls 1.0 \qml import QtQuick 2.0 - import org.controls.asteroid 1.0 + import org.asteroid.controls 1.0 Item { LabeledActionButton { diff --git a/src/controls/qml/LabeledSwitch.qml b/src/controls/qml/LabeledSwitch.qml index eee6453..9b5d15d 100644 --- a/src/controls/qml/LabeledSwitch.qml +++ b/src/controls/qml/LabeledSwitch.qml @@ -23,7 +23,7 @@ import org.asteroid.controls 1.0 /*! \qmltype LabeledSwitch - \inqmlmodule org.controls.asteroid 1.0 + \inqmlmodule org.asteroid.controls 1.0 \brief This combines \l Label and \l Switch in a convenient package. diff --git a/src/controls/qml/LayerStack.qml b/src/controls/qml/LayerStack.qml index 8ca6234..382cb41 100644 --- a/src/controls/qml/LayerStack.qml +++ b/src/controls/qml/LayerStack.qml @@ -39,7 +39,7 @@ import QtQuick 2.9 \qml import QtQuick 2.0 - import org.controls.asteroid 1.0 + import org.asteroid.controls 1.0 Item { Component { diff --git a/src/controls/qml/Marquee.qml b/src/controls/qml/Marquee.qml index b48d054..e032a94 100644 --- a/src/controls/qml/Marquee.qml +++ b/src/controls/qml/Marquee.qml @@ -33,7 +33,7 @@ import org.asteroid.controls 1.0 \qml import QtQuick 2.0 - import org.controls.asteroid 1.0 + import org.asteroid.controls 1.0 Item { Marquee { diff --git a/src/controls/qml/PageDot.qml b/src/controls/qml/PageDot.qml index e295699..92b2947 100644 --- a/src/controls/qml/PageDot.qml +++ b/src/controls/qml/PageDot.qml @@ -36,7 +36,7 @@ import QtQuick 2.9 \qml import QtQuick 2.0 - import org.controls.asteroid 1.0 + import org.asteroid.controls 1.0 Item { IntSelector { diff --git a/src/controls/qml/PageHeader.qml b/src/controls/qml/PageHeader.qml index 23d9129..d1d6d11 100644 --- a/src/controls/qml/PageHeader.qml +++ b/src/controls/qml/PageHeader.qml @@ -22,7 +22,7 @@ import org.asteroid.utils 1.0 /*! \qmltype PageHeader - \inqmlmodule org.controls.asteroid 1.0 + \inqmlmodule org.asteroid.controls 1.0 \brief Provides a title on a page. diff --git a/src/controls/qml/Spinner.qml b/src/controls/qml/Spinner.qml index c748d7a..91e30c9 100644 --- a/src/controls/qml/Spinner.qml +++ b/src/controls/qml/Spinner.qml @@ -30,7 +30,7 @@ import org.asteroid.controls 1.0 \qml import QtQuick 2.0 - import org.controls.asteroid 1.0 + import org.asteroid.controls 1.0 Spinner { id: rating diff --git a/src/controls/qml/StatusPage.qml b/src/controls/qml/StatusPage.qml index 322b548..ca65826 100644 --- a/src/controls/qml/StatusPage.qml +++ b/src/controls/qml/StatusPage.qml @@ -35,7 +35,7 @@ import org.asteroid.controls 1.0 \qml import QtQuick 2.0 - import org.controls.asteroid 1.0 + import org.asteroid.controls 1.0 StatusPage { text: "On fire" diff --git a/src/controls/qml/Switch.qml b/src/controls/qml/Switch.qml index 029fdf0..a28ebfe 100644 --- a/src/controls/qml/Switch.qml +++ b/src/controls/qml/Switch.qml @@ -21,7 +21,7 @@ import org.asteroid.controls 1.0 /*! \qmltype Switch - \inqmlmodule org.controls.asteroid 1.0 + \inqmlmodule org.asteroid.controls 1.0 \brief Specializes \l IconButton to provide an on/off toggle. From d6a0410362bfba626fc407e9eddbaede6c232b10 Mon Sep 17 00:00:00 2001 From: Jami Kettunen Date: Mon, 25 Nov 2024 11:33:24 +0200 Subject: [PATCH 02/15] asteroidapp: qmake: Call generate-desktop.sh with sh instead of bash It's a POSIX sh script as indicated by its shebang. --- src/app/asteroidapp.prf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/asteroidapp.prf b/src/app/asteroidapp.prf index 9a9316a..debbd4e 100644 --- a/src/app/asteroidapp.prf +++ b/src/app/asteroidapp.prf @@ -34,7 +34,7 @@ QT += quick qml target.path = /usr/bin -desktop.commands = bash $$_PRO_FILE_PWD_/i18n/generate-desktop.sh $$_PRO_FILE_PWD_ $${TARGET}.desktop +desktop.commands = sh $$_PRO_FILE_PWD_/i18n/generate-desktop.sh $$_PRO_FILE_PWD_ $${TARGET}.desktop desktop.files = $$OUT_PWD/$${TARGET}.desktop desktop.path = /usr/share/applications desktop.CONFIG = no_check_exist From 2da3ccb5091e0d540cf3e738d05e9b6c04aa3f3f Mon Sep 17 00:00:00 2001 From: Jami Kettunen Date: Sun, 24 Nov 2024 20:10:10 +0200 Subject: [PATCH 03/15] cmake: Let's not pretend 3.6.0 is a minimum supported version src/controls/CMakeLists.txt already makes use of the following: https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html#list-transformations --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7071736..e053e04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.6.0) +cmake_minimum_required(VERSION 3.27.0) project(qml-asteroid VERSION 2.0.0 From 4636a3ac49b935814c00fe72848c0f476cfe855a Mon Sep 17 00:00:00 2001 From: Jami Kettunen Date: Mon, 25 Nov 2024 09:55:31 +0200 Subject: [PATCH 04/15] Warn on missing translations To fix the following observed build warning: src/app/asteroidapp.cpp:80:13: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result] 80 | translator->load(QLocale(), appName(), ".", "/usr/share/translations", ".qm"); | ^~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- src/app/asteroidapp.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app/asteroidapp.cpp b/src/app/asteroidapp.cpp index 73e0d0a..13ae7e8 100644 --- a/src/app/asteroidapp.cpp +++ b/src/app/asteroidapp.cpp @@ -67,7 +67,9 @@ namespace AsteroidApp { app->setApplicationName(appName()); QTranslator *translator = new QTranslator(); - translator->load(QLocale(), appName(), ".", "/usr/share/translations", ".qm"); + if (!translator->load(QLocale(), appName(), ".", "/usr/share/translations", ".qm")) { + qDebug() << "Failed to load" << QLocale().name() << "translations for" << appName(); + } app->installTranslator(translator); } else { qWarning("AsteroidApp::application() called multiple times"); From f85dd2eb1698e479d5149ceb36ba2a22331ece6d Mon Sep 17 00:00:00 2001 From: Jami Kettunen Date: Wed, 13 Nov 2024 02:07:10 +0200 Subject: [PATCH 05/15] [WIP] Generate asteroidcontrolsplugin qrc via cmake Re-use the already existing listing of controls used for documentation generation as well. WIP because this will be replaced by qt_add_qml_module() --- src/controls/CMakeLists.txt | 14 +++++++++++--- src/controls/resources.qrc | 29 ----------------------------- 2 files changed, 11 insertions(+), 32 deletions(-) delete mode 100644 src/controls/resources.qrc diff --git a/src/controls/CMakeLists.txt b/src/controls/CMakeLists.txt index d008466..2512bd9 100644 --- a/src/controls/CMakeLists.txt +++ b/src/controls/CMakeLists.txt @@ -11,9 +11,7 @@ set(HEADERS src/flatmeshnode.h src/icon.h) -add_library(asteroidcontrolsplugin ${SRC} ${HEADERS} resources.qrc) - -set(controls +set(controls Application BorderGestureArea CircularSpinner @@ -40,6 +38,16 @@ set(controls TextBase TextField ) +foreach(control ${controls}) + list(APPEND controls-qml "qml/${control}.qml") +endforeach() + +add_library(asteroidcontrolsplugin ${SRC} ${HEADERS}) + +qt_add_resources(asteroidcontrolsplugin "asteroidcontrolsplugin_qrc" + PREFIX "/org/asteroid/controls/" + FILES "${controls-qml}") + set(controls-docs "$,PREPEND,qml->,APPEND,.html>") set(doc-dir "${CMAKE_BINARY_DIR}/doc/html") set(full-controls-docs "$") diff --git a/src/controls/resources.qrc b/src/controls/resources.qrc deleted file mode 100644 index 7c19457..0000000 --- a/src/controls/resources.qrc +++ /dev/null @@ -1,29 +0,0 @@ - - - qml/Application.qml - qml/BorderGestureArea.qml - qml/CircularSpinner.qml - qml/Dims.qml - qml/ListItem.qml - qml/HandWritingKeyboard.qml - qml/HighlightBar.qml - qml/IconButton.qml - qml/Indicator.qml - qml/Label.qml - qml/LayerStack.qml - qml/Marquee.qml - qml/LabeledSwitch.qml - qml/LabeledActionButton.qml - qml/PageDot.qml - qml/PageHeader.qml - qml/IntSelector.qml - qml/SegmentedArc.qml - qml/SpinnerDelegate.qml - qml/Spinner.qml - qml/StatusPage.qml - qml/Switch.qml - qml/TextArea.qml - qml/TextBase.qml - qml/TextField.qml - - From a83eb1a45ff11ffd43def389de9beb8633cc4b3c Mon Sep 17 00:00:00 2001 From: Jami Kettunen Date: Wed, 13 Nov 2024 00:44:00 +0200 Subject: [PATCH 06/15] Adapt all QML to use JS functions with formal parameters Fixes runtime warnings such as: qt.qml.context: qrc:/org/asteroid/controls/qml/BorderGestureArea.qml:160:5 Parameter "mouse" is not declared. Injection of parameters into signal handlers is deprecated. Use JavaScript functions with formal parameters instead. As an alternative the following also would work: function onPressed(mouse) { ... } --- src/controls/qml/BorderGestureArea.qml | 8 ++++---- src/controls/qml/TextBase.qml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/controls/qml/BorderGestureArea.qml b/src/controls/qml/BorderGestureArea.qml index ab39990..ffece06 100644 --- a/src/controls/qml/BorderGestureArea.qml +++ b/src/controls/qml/BorderGestureArea.qml @@ -61,7 +61,7 @@ import org.asteroid.utils 1.0 acceptsRight: true acceptsLeft: true acceptsDown: true - onGestureFinished: { + onGestureFinished: (gesture) => { if (gesture == "right") { square.color = "red" } @@ -95,7 +95,7 @@ import org.asteroid.utils 1.0 anchors.fill: parent acceptsUp: true acceptsDown: true - onGestureFinished: { + onGestureFinished: (gesture) => { if (gesture == "up") { square.color = "green" } @@ -157,7 +157,7 @@ MouseArea { property int _mouseStart property variant _gestures: ["down", "left", "up", "right"] - onPressed: { + onPressed: (mouse) => { if (mouse.x < boundary && acceptsRight) { gesture = "right" max = width - mouse.x @@ -184,7 +184,7 @@ MouseArea { gestureStarted(gesture) } - onPositionChanged: { + onPositionChanged: (mouse) => { var p = horizontal ? mouse.x : mouse.y value = Math.max(Math.min(p - _mouseStart, max), -max) } diff --git a/src/controls/qml/TextBase.qml b/src/controls/qml/TextBase.qml index b435af0..4e4aa8f 100644 --- a/src/controls/qml/TextBase.qml +++ b/src/controls/qml/TextBase.qml @@ -45,7 +45,7 @@ FocusScope { signal enterKeyClicked - Keys.onReleased: { + Keys.onReleased: (event) => { if (event.key === Qt.Key_Return) enterKeyClicked() } From c5433e7c610c18dde6c69bc998bb12eb3b21f4dd Mon Sep 17 00:00:00 2001 From: Jami Kettunen Date: Mon, 25 Nov 2024 11:28:49 +0200 Subject: [PATCH 07/15] Start adding QML type annotations for AOT cachegen --- src/controls/qml/Dims.qml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/controls/qml/Dims.qml b/src/controls/qml/Dims.qml index 1dc545f..05ceb09 100644 --- a/src/controls/qml/Dims.qml +++ b/src/controls/qml/Dims.qml @@ -61,7 +61,7 @@ QtObject { \qmlmethod real w(real number) \brief Returns a dimension that is \a number percent of the screen width. */ - function w(number) { + function w(number: real): real { return (number/100)*Screen.desktopAvailableWidth } @@ -69,7 +69,7 @@ QtObject { \qmlmethod real h(real number) \brief Returns a dimension that is \a number percent of the screen height. */ - function h(number) { + function h(number: real): real { return (number/100)*(Screen.desktopAvailableHeight+DeviceInfo.flatTireHeight) } @@ -77,7 +77,7 @@ QtObject { \qmlmethod real l(real number) \brief Returns a dimension that is \a number percent of the screen width or height; whichever is smaller. */ - function l(number) { + function l(number: real): real { if(Screen.desktopAvailableWidth > (Screen.desktopAvailableHeight+DeviceInfo.flatTireHeight)) return h(number) else From 21a1d29bba6b1860dc5800bfa2bf3a2aba8a9feb Mon Sep 17 00:00:00 2001 From: Jami Kettunen Date: Wed, 13 Nov 2024 00:25:48 +0200 Subject: [PATCH 08/15] Fix building against Qt6 --- CMakeLists.txt | 6 +++--- src/controls/CMakeLists.txt | 6 +++--- src/controls/src/icon.cpp | 6 ++++-- src/controls/src/icon.h | 2 +- src/utils/CMakeLists.txt | 6 +++--- src/utils/src/deviceinfo.cpp | 4 ++-- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e053e04..3e06249 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,10 +19,10 @@ include(AsteroidCMakeSettings) set(ASTEROID_MODULES_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/asteroidapp/cmake) -find_package(Qt5 ${QT_MIN_VERSION} COMPONENTS DBus Qml Quick Svg REQUIRED) +find_package(Qt6 ${QT_MIN_VERSION} COMPONENTS DBus Qml Quick Svg ShaderTools REQUIRED) if (WITH_ASTEROIDAPP) - find_package(Mlite5 MODULE REQUIRED) - find_package(Mapplauncherd_qt5 MODULE REQUIRED) + find_package(Mlite6 MODULE REQUIRED) + find_package(Mapplauncherd_qt6 MODULE REQUIRED) endif() ecm_find_qmlmodule(QtQuick.VirtualKeyboard 2.1) diff --git a/src/controls/CMakeLists.txt b/src/controls/CMakeLists.txt index 2512bd9..67e025b 100644 --- a/src/controls/CMakeLists.txt +++ b/src/controls/CMakeLists.txt @@ -64,9 +64,9 @@ add_custom_command( ) target_link_libraries(asteroidcontrolsplugin - Qt5::Qml - Qt5::Quick - Qt5::Svg) + Qt::Qml + Qt::Quick + Qt::Svg) install(TARGETS asteroidcontrolsplugin DESTINATION ${INSTALL_QML_IMPORT_DIR}/org/asteroid/controls) diff --git a/src/controls/src/icon.cpp b/src/controls/src/icon.cpp index e26d2ec..6135323 100644 --- a/src/controls/src/icon.cpp +++ b/src/controls/src/icon.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #define ICONS_DIRECTORY "/usr/share/icons/asteroid/" @@ -79,9 +80,10 @@ void Icon::paint(QPainter *painter) painter->drawPixmap(0, 0, width(), height(), m_pixmap); } -void Icon::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) + +void Icon::geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) { - QQuickPaintedItem::geometryChanged(newGeometry, oldGeometry); + QQuickPaintedItem::geometryChange(newGeometry, oldGeometry); if(newGeometry.size() == oldGeometry.size() || newGeometry.width() == 0 || newGeometry.height() == 0) return; updateBasePixmap(); diff --git a/src/controls/src/icon.h b/src/controls/src/icon.h index a3f9e0a..0a44554 100644 --- a/src/controls/src/icon.h +++ b/src/controls/src/icon.h @@ -52,7 +52,7 @@ class Icon : public QQuickPaintedItem void paint(QPainter *painter) override; - void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; + void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override; signals: void nameChanged(); diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt index 5ca2119..12ce753 100644 --- a/src/utils/CMakeLists.txt +++ b/src/utils/CMakeLists.txt @@ -12,9 +12,9 @@ set(HEADERS add_library(asteroidutilsplugin ${SRC} ${HEADERS}) target_link_libraries(asteroidutilsplugin - Qt5::DBus - Qt5::Qml - Qt5::Quick) + Qt::DBus + Qt::Qml + Qt::Quick) install(TARGETS asteroidutilsplugin DESTINATION ${INSTALL_QML_IMPORT_DIR}/org/asteroid/utils) diff --git a/src/utils/src/deviceinfo.cpp b/src/utils/src/deviceinfo.cpp index ccaf766..45aea76 100644 --- a/src/utils/src/deviceinfo.cpp +++ b/src/utils/src/deviceinfo.cpp @@ -35,7 +35,7 @@ DeviceInfo::DeviceInfo() QFile host(HOST_FILE); if (host.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&host); - in.setCodec("UTF-8"); + in.setEncoding(QStringConverter::Utf8); m_hostname = in.readLine(); host.close(); } @@ -43,7 +43,7 @@ DeviceInfo::DeviceInfo() QFile release(OS_RELEASE_FILE); if (release.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&release); - in.setCodec("UTF-8"); + in.setEncoding(QStringConverter::Utf8); QString line = in.readLine(); for (bool searching{true}; searching && !in.atEnd(); line = in.readLine()) { if (line.startsWith("BUILD_ID")) { From cca6c314d75e9dcc9ce2cca6e7cdb904f4446048 Mon Sep 17 00:00:00 2001 From: Jami Kettunen Date: Wed, 13 Nov 2024 02:08:45 +0200 Subject: [PATCH 09/15] Port {Circular,}Spinner fragmentShader to Qt6 (qsb) --- src/controls/CMakeLists.txt | 7 +++++++ src/controls/qml/CircularSpinner.qml | 15 +-------------- src/controls/qml/Spinner.frag | 14 ++++++++++++++ src/controls/qml/Spinner.qml | 15 +-------------- 4 files changed, 23 insertions(+), 28 deletions(-) create mode 100644 src/controls/qml/Spinner.frag diff --git a/src/controls/CMakeLists.txt b/src/controls/CMakeLists.txt index 67e025b..e46a7c8 100644 --- a/src/controls/CMakeLists.txt +++ b/src/controls/CMakeLists.txt @@ -48,6 +48,13 @@ qt_add_resources(asteroidcontrolsplugin "asteroidcontrolsplugin_qrc" PREFIX "/org/asteroid/controls/" FILES "${controls-qml}") +qt6_add_shaders(asteroidcontrolsplugin "asteroidcontrolsplugin_shaders" + PREFIX "/org/asteroid/controls/" + FILES "qml/Spinner.frag" + BATCHABLE + PRECOMPILE + OPTIMIZED) + set(controls-docs "$,PREPEND,qml->,APPEND,.html>") set(doc-dir "${CMAKE_BINARY_DIR}/doc/html") set(full-controls-docs "$") diff --git a/src/controls/qml/CircularSpinner.qml b/src/controls/qml/CircularSpinner.qml index b47548e..6a8df90 100644 --- a/src/controls/qml/CircularSpinner.qml +++ b/src/controls/qml/CircularSpinner.qml @@ -93,19 +93,6 @@ PathView { layer.enabled: true layer.effect: ShaderEffect { - fragmentShader: " - precision mediump float; - varying highp vec2 qt_TexCoord0; - uniform sampler2D source; - void main(void) - { - vec4 sourceColor = texture2D(source, qt_TexCoord0); - float alpha = 1.0; - if(qt_TexCoord0.y < 0.2) - alpha = qt_TexCoord0.y*5.0; - if(qt_TexCoord0.y > 0.8) - alpha = (1.0-qt_TexCoord0.y)*5.0; - gl_FragColor = sourceColor * alpha; - }" + fragmentShader: "Spinner.frag.qsb" } } diff --git a/src/controls/qml/Spinner.frag b/src/controls/qml/Spinner.frag new file mode 100644 index 0000000..0b08898 --- /dev/null +++ b/src/controls/qml/Spinner.frag @@ -0,0 +1,14 @@ +#version 440 +layout(location = 0) in vec2 qt_TexCoord0; +layout(location = 0) out vec4 fragColor; +layout(binding = 1) uniform sampler2D source; +void main(void) +{ + vec4 sourceColor = texture(source, qt_TexCoord0); + float alpha = 1.0; + if(qt_TexCoord0.y < 0.2) + alpha = qt_TexCoord0.y*5.0; + if(qt_TexCoord0.y > 0.8) + alpha = (1.0-qt_TexCoord0.y)*5.0; + fragColor = sourceColor * alpha; +} diff --git a/src/controls/qml/Spinner.qml b/src/controls/qml/Spinner.qml index 91e30c9..c154d9f 100644 --- a/src/controls/qml/Spinner.qml +++ b/src/controls/qml/Spinner.qml @@ -72,19 +72,6 @@ ListView { layer.enabled: true layer.effect: ShaderEffect { - fragmentShader: " - precision mediump float; - varying highp vec2 qt_TexCoord0; - uniform sampler2D source; - void main(void) - { - vec4 sourceColor = texture2D(source, qt_TexCoord0); - float alpha = 1.0; - if(qt_TexCoord0.y < 0.2) - alpha = qt_TexCoord0.y*5.0; - if(qt_TexCoord0.y > 0.8) - alpha = (1.0-qt_TexCoord0.y)*5.0; - gl_FragColor = sourceColor * alpha; - }" + fragmentShader: "Spinner.frag.qsb" } } From 9361b4ba2b93a2ea22955e2549ec8f1ac562af0d Mon Sep 17 00:00:00 2001 From: Jami Kettunen Date: Sun, 24 Nov 2024 00:29:46 +0200 Subject: [PATCH 10/15] Port AsteroidApp to Qt6 --- cmake/AsteroidTranslations.cmake | 4 +-- cmake/FindMapplauncherd_qt5.cmake | 40 ------------------------------ cmake/FindMapplauncherd_qt6.cmake | 40 ++++++++++++++++++++++++++++++ cmake/FindMlite5.cmake | 40 ------------------------------ cmake/FindMlite6.cmake | 40 ++++++++++++++++++++++++++++++ src/app/AsteroidAppConfig.cmake.in | 3 +-- src/app/CMakeLists.txt | 10 ++++---- src/app/asteroidapp.cpp | 2 +- 8 files changed, 89 insertions(+), 90 deletions(-) delete mode 100644 cmake/FindMapplauncherd_qt5.cmake create mode 100644 cmake/FindMapplauncherd_qt6.cmake delete mode 100644 cmake/FindMlite5.cmake create mode 100644 cmake/FindMlite6.cmake diff --git a/cmake/AsteroidTranslations.cmake b/cmake/AsteroidTranslations.cmake index 7ea83f8..26404e6 100644 --- a/cmake/AsteroidTranslations.cmake +++ b/cmake/AsteroidTranslations.cmake @@ -4,11 +4,11 @@ function(BUILD_TRANSLATIONS directory) return() endif() - find_package(Qt5LinguistTools REQUIRED) + find_package(Qt6LinguistTools REQUIRED) file(GLOB LANGUAGE_FILES_TS ${directory}/*.ts) #set_source_files_properties(${LANGUAGE_FILES_TS} PROPERTIES OUTPUT_LOCATION "i18n") - qt5_add_translation(LANGUAGE_FILES_QM ${LANGUAGE_FILES_TS} OPTIONS "-idbased") + qt_add_translation(LANGUAGE_FILES_QM ${LANGUAGE_FILES_TS} OPTIONS "-idbased") add_custom_target(build-translations ALL COMMENT "Building translations in ${director}..." DEPENDS ${LANGUAGE_FILES_QM}) diff --git a/cmake/FindMapplauncherd_qt5.cmake b/cmake/FindMapplauncherd_qt5.cmake deleted file mode 100644 index 5919cef..0000000 --- a/cmake/FindMapplauncherd_qt5.cmake +++ /dev/null @@ -1,40 +0,0 @@ -# Try to find qdeclarative5-boostable -# Once done this will define -# MAPPLAUNCHERD_QT5_FOUND - System has qdeclarative -# MAPPLAUNCHERD_QT5_INCLUDE_DIRS - The qdeclarative include directories -# MAPPLAUNCHERD_QT5_LIBRARIES - The libraries needed to use qdeclarative -# MAPPLAUNCHERD_QT5_DEFINITIONS - Compiler switches required for using qdeclarative - -find_package(PkgConfig REQUIRED) -pkg_check_modules(PC_Mapplauncherd_qt5 QUIET qdeclarative5-boostable) -set(Mapplauncherd_qt5_DEFINITIONS ${PC_Mapplauncherd_qt5_CFLAGS_OTHER}) - -find_path(Mapplauncherd_qt5_INCLUDE_DIRS - NAMES mdeclarativecache.h - PATH_SUFFIXES mdeclarativecache5 - PATHS ${PC_Mapplauncherd_qt5_INCLUDEDIR} ${PC_Mapplauncherd_qt5_INCLUDE_DIRS}) - -find_library(Mapplauncherd_qt5_LIBRARIES - NAMES mdeclarativecache5 - PATHS ${PC_Mapplauncherd_qt5_LIBDIR} ${PC_Mapplauncherd_qt5_LIBRARY_DIRS}) - -set(Mapplauncherd_qt5_VERSION ${PC_Mapplauncherd_qt5_VERSION}) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Mapplauncherd_qt5 - FOUND_VAR - Mapplauncherd_qt5_FOUND - REQUIRED_VARS - Mapplauncherd_qt5_LIBRARIES - Mapplauncherd_qt5_INCLUDE_DIRS - VERSION_VAR - Mapplauncherd_qt5_VERSION) - -mark_as_advanced(Mapplauncherd_qt5_INCLUDE_DIR Mapplauncherd_qt5_LIBRARY Mapplauncherd_qt5_VERSION) - -if(Mapplauncherd_qt5_FOUND AND NOT TARGET Mapplauncherd_qt5::Mapplauncherd_qt5) - add_library(Mapplauncherd_qt5::Mapplauncherd_qt5 UNKNOWN IMPORTED) - set_target_properties(Mapplauncherd_qt5::Mapplauncherd_qt5 PROPERTIES - IMPORTED_LOCATION "${Mapplauncherd_qt5_LIBRARIES}" - INTERFACE_INCLUDE_DIRECTORIES "${Mapplauncherd_qt5_INCLUDE_DIRS}") -endif() diff --git a/cmake/FindMapplauncherd_qt6.cmake b/cmake/FindMapplauncherd_qt6.cmake new file mode 100644 index 0000000..d181245 --- /dev/null +++ b/cmake/FindMapplauncherd_qt6.cmake @@ -0,0 +1,40 @@ +# Try to find qdeclarative6-boostable +# Once done this will define +# MAPPLAUNCHERD_QT6_FOUND - System has qdeclarative +# MAPPLAUNCHERD_QT6_INCLUDE_DIRS - The qdeclarative include directories +# MAPPLAUNCHERD_QT6_LIBRARIES - The libraries needed to use qdeclarative +# MAPPLAUNCHERD_QT6_DEFINITIONS - Compiler switches required for using qdeclarative + +find_package(PkgConfig REQUIRED) +pkg_check_modules(PC_Mapplauncherd_qt6 QUIET qdeclarative6-boostable) +set(Mapplauncherd_qt6_DEFINITIONS ${PC_Mapplauncherd_qt6_CFLAGS_OTHER}) + +find_path(Mapplauncherd_qt6_INCLUDE_DIRS + NAMES mdeclarativecache.h + PATH_SUFFIXES mdeclarativecache6 + PATHS ${PC_Mapplauncherd_qt6_INCLUDEDIR} ${PC_Mapplauncherd_qt6_INCLUDE_DIRS}) + +find_library(Mapplauncherd_qt6_LIBRARIES + NAMES mdeclarativecache6 + PATHS ${PC_Mapplauncherd_qt6_LIBDIR} ${PC_Mapplauncherd_qt6_LIBRARY_DIRS}) + +set(Mapplauncherd_qt6_VERSION ${PC_Mapplauncherd_qt6_VERSION}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Mapplauncherd_qt6 + FOUND_VAR + Mapplauncherd_qt6_FOUND + REQUIRED_VARS + Mapplauncherd_qt6_LIBRARIES + Mapplauncherd_qt6_INCLUDE_DIRS + VERSION_VAR + Mapplauncherd_qt6_VERSION) + +mark_as_advanced(Mapplauncherd_qt6_INCLUDE_DIR Mapplauncherd_qt6_LIBRARY Mapplauncherd_qt6_VERSION) + +if(Mapplauncherd_qt6_FOUND AND NOT TARGET Mapplauncherd_qt6::Mapplauncherd_qt6) + add_library(Mapplauncherd_qt6::Mapplauncherd_qt6 UNKNOWN IMPORTED) + set_target_properties(Mapplauncherd_qt6::Mapplauncherd_qt6 PROPERTIES + IMPORTED_LOCATION "${Mapplauncherd_qt6_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${Mapplauncherd_qt6_INCLUDE_DIRS}") +endif() diff --git a/cmake/FindMlite5.cmake b/cmake/FindMlite5.cmake deleted file mode 100644 index 3558bbd..0000000 --- a/cmake/FindMlite5.cmake +++ /dev/null @@ -1,40 +0,0 @@ -# Try to find mlite5 -# Once done this will define -# MLITE5_FOUND - System has mlite5 -# MLITE5_INCLUDE_DIRS - The mlite5 include directories -# MLITE5_LIBRARIES - The libraries needed to use mlite5 -# MLITE5_DEFINITIONS - Compiler switches required for using mlite5 - -find_package(PkgConfig REQUIRED) -pkg_check_modules(PC_Mlite5 QUIET mlite5) -set(Mlite5_DEFINITIONS ${PC_Mlite5_CFLAGS_OTHER}) - -find_path(Mlite5_INCLUDE_DIRS - NAMES mlite-global.h - PATH_SUFFIXES mlite5 - PATHS ${PC_Mlite5_INCLUDEDIR} ${PC_Mlite5_INCLUDE_DIRS}) - -find_library(Mlite5_LIBRARIES - NAMES mlite5 - PATHS ${PC_Mlite5_LIBDIR} ${PC_Mlite5_LIBRARY_DIRS}) - -set(Mlite5_VERSION ${PC_Mlite5_VERSION}) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Mlite5 - FOUND_VAR - Mlite5_FOUND - REQUIRED_VARS - Mlite5_LIBRARIES - Mlite5_INCLUDE_DIRS - VERSION_VAR - Mlite5_VERSION) - -mark_as_advanced(Mlite5_INCLUDE_DIR Mlite5_LIBRARY Mlite5_VERSION) - -if(Mlite5_FOUND AND NOT TARGET Mlite5::Mlite5) - add_library(Mlite5::Mlite5 UNKNOWN IMPORTED) - set_target_properties(Mlite5::Mlite5 PROPERTIES - IMPORTED_LOCATION "${Mlite5_LIBRARIES}" - INTERFACE_INCLUDE_DIRECTORIES "${Mlite5_INCLUDE_DIRS}") -endif() diff --git a/cmake/FindMlite6.cmake b/cmake/FindMlite6.cmake new file mode 100644 index 0000000..e9eec54 --- /dev/null +++ b/cmake/FindMlite6.cmake @@ -0,0 +1,40 @@ +# Try to find mlite6 +# Once done this will define +# MLITE6_FOUND - System has mlite6 +# MLITE6_INCLUDE_DIRS - The mlite6 include directories +# MLITE6_LIBRARIES - The libraries needed to use mlite6 +# MLITE6_DEFINITIONS - Compiler switches required for using mlite6 + +find_package(PkgConfig REQUIRED) +pkg_check_modules(PC_Mlite6 QUIET mlite6) +set(Mlite6_DEFINITIONS ${PC_Mlite6_CFLAGS_OTHER}) + +find_path(Mlite6_INCLUDE_DIRS + NAMES mlite-global.h + PATH_SUFFIXES mlite6 + PATHS ${PC_Mlite6_INCLUDEDIR} ${PC_Mlite6_INCLUDE_DIRS}) + +find_library(Mlite6_LIBRARIES + NAMES mlite6 + PATHS ${PC_Mlite6_LIBDIR} ${PC_Mlite6_LIBRARY_DIRS}) + +set(Mlite6_VERSION ${PC_Mlite6_VERSION}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Mlite6 + FOUND_VAR + Mlite6_FOUND + REQUIRED_VARS + Mlite6_LIBRARIES + Mlite6_INCLUDE_DIRS + VERSION_VAR + Mlite6_VERSION) + +mark_as_advanced(Mlite6_INCLUDE_DIR Mlite6_LIBRARY Mlite6_VERSION) + +if(Mlite6_FOUND AND NOT TARGET Mlite6::Mlite6) + add_library(Mlite6::Mlite6 UNKNOWN IMPORTED) + set_target_properties(Mlite6::Mlite6 PROPERTIES + IMPORTED_LOCATION "${Mlite6_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${Mlite6_INCLUDE_DIRS}") +endif() diff --git a/src/app/AsteroidAppConfig.cmake.in b/src/app/AsteroidAppConfig.cmake.in index c1afb72..3cce629 100644 --- a/src/app/AsteroidAppConfig.cmake.in +++ b/src/app/AsteroidAppConfig.cmake.in @@ -1,8 +1,7 @@ @PACKAGE_INIT@ include(CMakeFindDependencyMacro) -find_dependency(Qt5Qml @QT_MIN_VERSION@) -find_dependency(Qt5Quick @QT_MIN_VERSION@) +find_package(Qt6 @QT_MIN_VERSION@ COMPONENTS Qml Quick REQUIRED) set(ASTEROID_MODULE_PATH "@PACKAGE_ASTEROID_MODULES_INSTALL_DIR@") diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 333ffc5..3d7d37d 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -5,11 +5,11 @@ add_library(asteroidapp ${SRC} ${HEADERS}) target_link_libraries(asteroidapp PUBLIC - Qt5::Qml - Qt5::Quick + Qt6::Qml + Qt6::Quick PRIVATE - Mlite5::Mlite5 - Mapplauncherd_qt5::Mapplauncherd_qt5) + Mlite6::Mlite6 + Mapplauncherd_qt6::Mapplauncherd_qt6) set_target_properties(asteroidapp PROPERTIES EXPORT_NAME AsteroidApp @@ -36,7 +36,7 @@ install(FILES asteroidapp.prf ecm_generate_pkgconfig_file( BASE_NAME asteroidapp - DEPS qdeclarative5-boostable + DEPS qdeclarative6-boostable FILENAME_VAR asteroidapp DESCRIPTION ${PROJECT_DESCRIPTION} INSTALL) diff --git a/src/app/asteroidapp.cpp b/src/app/asteroidapp.cpp index 13ae7e8..84b65ff 100644 --- a/src/app/asteroidapp.cpp +++ b/src/app/asteroidapp.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include static QString applicationPath() { From a0b48b859f05a1887e596e2e31576dd55db9de58 Mon Sep 17 00:00:00 2001 From: Jami Kettunen Date: Sun, 24 Nov 2024 00:29:59 +0200 Subject: [PATCH 11/15] generate-desktop.sh: Stop using unportable GNU grep -P This doesn't work on Chimera Linux which uses the FreeBSD grep(1); adds a new build-time dependency on xmllint which I'm not sure how to feel about yet. --- generate-desktop.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/generate-desktop.sh b/generate-desktop.sh index 91f550d..559cce5 100755 --- a/generate-desktop.sh +++ b/generate-desktop.sh @@ -47,7 +47,7 @@ if [ ! -f "${SRC_DIR}/i18n/${APPLICATION_NAME}.desktop.h" ]; then exit 2 fi -DEFAULT_NAME=$(grep -oP '//% "\K[^"]+(?=")' "${SRC_DIR}/i18n/${APPLICATION_NAME}.desktop.h") +DEFAULT_NAME=$(sed -n 's/\/\/% //p' "${SRC_DIR}/i18n/${APPLICATION_NAME}.desktop.h" | cut -d'"' -f2) if [ -z "$DEFAULT_NAME" ]; then echo "Default name can not be found in ${SRC_DIR}/i18n/${APPLICATION_NAME}.desktop.h" exit 3 @@ -59,7 +59,7 @@ echo "Name=$DEFAULT_NAME" >> "$OUTPUT_FILE" for FILE in "${SRC_DIR}"/i18n/*.ts; do echo "Processing $FILE..." - PROCESSED_LANG=$(grep -oP 'language="\K[^"]+(?=")' "$FILE") + PROCESSED_LANG=$(xmllint --xpath 'string(//TS/@language)' "$FILE") if [ -z "$PROCESSED_LANG" ]; then echo "> Couldn't find a corresponding language id, aborting" continue @@ -78,7 +78,7 @@ for FILE in "${SRC_DIR}"/i18n/*.ts; do continue fi - TRANSLATED_NAME=$(echo "$TRANSLATION_LINE" | grep -oP '>\K[^<]*(?=)') + TRANSLATED_NAME=$(echo "$TRANSLATION_LINE" | xmllint --xpath 'string(//translation)' -) # TODO: 2>/dev/null ? if [ -z "$TRANSLATED_NAME" ]; then echo "> Translation is empty, aborting" continue From 824e4bf78cdf0a4f67a0b731dde7047b12fc0500 Mon Sep 17 00:00:00 2001 From: Jami Kettunen Date: Sun, 24 Nov 2024 17:30:41 +0200 Subject: [PATCH 12/15] Make Mapplauncherd support optional It's worth revisiting if this makes sense to keep as a dependency with some repeatable benchmarks where a quantifiable difference may or may not be observed when running this on a watch. If this is to be removed cmake/FindMapplauncherd_qt*.cmake additionally should also be gone. --- CMakeLists.txt | 5 ++++- src/app/CMakeLists.txt | 10 +++++++--- src/app/asteroidapp.cpp | 14 ++++++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e06249..cae8606 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ find_package(ECM REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) option(WITH_ASTEROIDAPP "Build the AsteroidApp class" ON) +option(WITH_MAPPLAUNCHERD "Build the AsteroidApp class with Mapplauncherd booster support" ON) option(WITH_CMAKE_MODULES "Install AsteroidOS CMake modules" ON) include(FeatureSummary) @@ -22,7 +23,9 @@ set(ASTEROID_MODULES_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/asteroidapp/cmake) find_package(Qt6 ${QT_MIN_VERSION} COMPONENTS DBus Qml Quick Svg ShaderTools REQUIRED) if (WITH_ASTEROIDAPP) find_package(Mlite6 MODULE REQUIRED) - find_package(Mapplauncherd_qt6 MODULE REQUIRED) + if (WITH_MAPPLAUNCHERD) + find_package(Mapplauncherd_qt6 MODULE REQUIRED) + endif() endif() ecm_find_qmlmodule(QtQuick.VirtualKeyboard 2.1) diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 3d7d37d..be2cbfe 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -9,12 +9,13 @@ target_link_libraries(asteroidapp Qt6::Quick PRIVATE Mlite6::Mlite6 - Mapplauncherd_qt6::Mapplauncherd_qt6) + $<$:Mapplauncherd_qt6::Mapplauncherd_qt6>) set_target_properties(asteroidapp PROPERTIES EXPORT_NAME AsteroidApp SOVERSION ${PROJECT_VERSION_MAJOR} - VERSION ${PROJECT_VERSION}) + VERSION ${PROJECT_VERSION} + COMPILE_DEFINITIONS $<$:WITH_MAPPLAUNCHERD=1>) target_include_directories(asteroidapp PUBLIC $ @@ -34,9 +35,12 @@ install(FILES asteroidapp.prf DESTINATION ${CMAKE_INSTALL_LIBDIR}/mkspecs/features COMPONENT Devel) +if (WITH_MAPPLAUNCHERD) + set(ASTEROIDAPP_PKGCONF_DEPS "qdeclarative6-boostable") +endif() ecm_generate_pkgconfig_file( BASE_NAME asteroidapp - DEPS qdeclarative6-boostable + DEPS ${ASTEROIDAPP_PKGCONF_DEPS} FILENAME_VAR asteroidapp DESCRIPTION ${PROJECT_DESCRIPTION} INSTALL) diff --git a/src/app/asteroidapp.cpp b/src/app/asteroidapp.cpp index 84b65ff..9f840ed 100644 --- a/src/app/asteroidapp.cpp +++ b/src/app/asteroidapp.cpp @@ -33,6 +33,7 @@ #include #include #include +#if WITH_MAPPLAUNCHERD #include static QString applicationPath() @@ -47,11 +48,16 @@ static QString applicationPath() return QCoreApplication::applicationFilePath(); } } +#endif namespace AsteroidApp { QString appName() { +#if WITH_MAPPLAUNCHERD QFileInfo exe = QFileInfo(applicationPath()); +#else + QFileInfo exe = QFileInfo(QCoreApplication::applicationFilePath()); +#endif return exe.baseName(); } @@ -60,7 +66,11 @@ namespace AsteroidApp { static QGuiApplication *app = NULL; if (app == NULL) { +#if WITH_MAPPLAUNCHERD app = MDeclarativeCache::qApplication(argc, argv); +#else + app = new QGuiApplication(argc, argv); +#endif app->setOrganizationName(appName()); app->setOrganizationDomain(appName()); @@ -80,7 +90,11 @@ namespace AsteroidApp { QQuickView *createView() { +#if WITH_MAPPLAUNCHERD QQuickView *view = MDeclarativeCache::qQuickView(); +#else + QQuickView *view = new QQuickView; +#endif MDesktopEntry entry("/usr/share/applications/" + appName() + ".desktop"); if (entry.isValid()) { view->setTitle(entry.name()); From 823285555c52b4e79b1efa0b4dafc20d06a67ce1 Mon Sep 17 00:00:00 2001 From: Jami Kettunen Date: Mon, 25 Nov 2024 04:00:05 +0200 Subject: [PATCH 13/15] Adapt to modern Qt6 QML import path conventions Let's adopt QTP0001 already and move all per-application resources under qrc:/qt/qml/AsteroidApp/ --- cmake/AsteroidCMakeSettings.cmake | 3 ++- src/app/AsteroidAppConfig.cmake.in | 2 ++ src/app/asteroidapp.cpp | 2 +- src/app/asteroidapp.h | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cmake/AsteroidCMakeSettings.cmake b/cmake/AsteroidCMakeSettings.cmake index fe11c06..6e28ad5 100644 --- a/cmake/AsteroidCMakeSettings.cmake +++ b/cmake/AsteroidCMakeSettings.cmake @@ -34,5 +34,6 @@ if (NOT ASTEROID_SKIP_BUILD_SETTINGS) set(INSTALL_QML_IMPORT_DIR "${CMAKE_INSTALL_FULL_LIBDIR}/qml" CACHE PATH "Custom QML import installation directory") - set(QT_MIN_VERSION "5.12.0") + # Ensure availability of QTP0001 (https://doc.qt.io/qt-6/qt-cmake-policy-qtp0001.html) + set(QT_MIN_VERSION "6.5.0") endif() diff --git a/src/app/AsteroidAppConfig.cmake.in b/src/app/AsteroidAppConfig.cmake.in index 3cce629..dd39dd1 100644 --- a/src/app/AsteroidAppConfig.cmake.in +++ b/src/app/AsteroidAppConfig.cmake.in @@ -7,3 +7,5 @@ set(ASTEROID_MODULE_PATH "@PACKAGE_ASTEROID_MODULES_INSTALL_DIR@") include("${CMAKE_CURRENT_LIST_DIR}/AsteroidAppTargets.cmake") @PACKAGE_INCLUDE_QCHTARGETS@ + +qt_policy(SET QTP0001 NEW) diff --git a/src/app/asteroidapp.cpp b/src/app/asteroidapp.cpp index 9f840ed..0eeea38 100644 --- a/src/app/asteroidapp.cpp +++ b/src/app/asteroidapp.cpp @@ -110,7 +110,7 @@ namespace AsteroidApp { { QScopedPointer app(AsteroidApp::application(argc, argv)); QScopedPointer view(AsteroidApp::createView()); - view->setSource(QUrl("qrc:/main.qml")); + view->setSource(QUrl("qrc:/qt/qml/asteroidapp/main.qml")); view->resize(app->primaryScreen()->size()); view->show(); return app->exec(); diff --git a/src/app/asteroidapp.h b/src/app/asteroidapp.h index 077c39b..4f07052 100644 --- a/src/app/asteroidapp.h +++ b/src/app/asteroidapp.h @@ -43,7 +43,7 @@ namespace AsteroidApp { ASTEROIDAPP_EXPORT QGuiApplication *application(int &argc, char **argv); ASTEROIDAPP_EXPORT QQuickView *createView(); - // Very simple interface: Uses "qrc:/main.qml" as QML entry point + // Very simple interface: Uses "qrc:/qt/qml/asteroidapp/main.qml" as QML entry point ASTEROIDAPP_EXPORT int main(int &argc, char **argv); }; From 69866f365f796d69d277629e345631d4a658d944 Mon Sep 17 00:00:00 2001 From: Jami Kettunen Date: Mon, 25 Nov 2024 17:10:31 +0200 Subject: [PATCH 14/15] Generate everything org.asteroid.utils related via CMake --- src/utils/CMakeLists.txt | 27 +++++++++++++++++-------- src/utils/qmldir | 3 --- src/utils/src/bluetoothstatus.h | 2 ++ src/utils/src/deviceinfo.h | 7 +++---- src/utils/src/fileinfo.h | 8 ++++---- src/utils/src/utils_plugin.cpp | 36 --------------------------------- src/utils/src/utils_plugin.h | 34 ------------------------------- 7 files changed, 28 insertions(+), 89 deletions(-) delete mode 100644 src/utils/qmldir delete mode 100644 src/utils/src/utils_plugin.cpp delete mode 100644 src/utils/src/utils_plugin.h diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt index 12ce753..01532f4 100644 --- a/src/utils/CMakeLists.txt +++ b/src/utils/CMakeLists.txt @@ -1,22 +1,33 @@ set(SRC - src/utils_plugin.cpp src/deviceinfo.cpp src/fileinfo.cpp src/bluetoothstatus.cpp) set(HEADERS - src/utils_plugin.h src/deviceinfo.h src/fileinfo.h src/bluetoothstatus.h) -add_library(asteroidutilsplugin ${SRC} ${HEADERS}) +# TODO: ensure FileInfo 1.0 (singleton) & BluetoothStatus 1.0 (normal) QML classes work +qt_add_qml_module(asteroidutilsplugin + URI org.asteroid.utils + VERSION 1.0 + PLUGIN_TARGET asteroidutilsplugin + #NO_PLUGIN_OPTIONAL + SOURCES + ${SRC} ${HEADERS} +) + +target_include_directories(asteroidutilsplugin PRIVATE src) target_link_libraries(asteroidutilsplugin - Qt::DBus - Qt::Qml - Qt::Quick) + #PUBLIC + # Qt::Qml + # Qt::Quick + PRIVATE + Qt::DBus # bluetoothstatus +) install(TARGETS asteroidutilsplugin DESTINATION ${INSTALL_QML_IMPORT_DIR}/org/asteroid/utils) -install(FILES qmldir - DESTINATION ${INSTALL_QML_IMPORT_DIR}/org/asteroid/utils) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qmldir + DESTINATION ${INSTALL_QML_IMPORT_DIR}/org/asteroid/utils) diff --git a/src/utils/qmldir b/src/utils/qmldir deleted file mode 100644 index 6a0ed83..0000000 --- a/src/utils/qmldir +++ /dev/null @@ -1,3 +0,0 @@ -module org.asteroid.utils - -plugin asteroidutilsplugin diff --git a/src/utils/src/bluetoothstatus.h b/src/utils/src/bluetoothstatus.h index 6924bf4..eadf25b 100644 --- a/src/utils/src/bluetoothstatus.h +++ b/src/utils/src/bluetoothstatus.h @@ -23,6 +23,7 @@ #include #include #include +#include typedef QMap> InterfaceList; Q_DECLARE_METATYPE(InterfaceList) @@ -30,6 +31,7 @@ Q_DECLARE_METATYPE(InterfaceList) class BluetoothStatus : public QObject { Q_OBJECT + QML_ELEMENT Q_PROPERTY(bool powered READ getPowered WRITE setPowered NOTIFY poweredChanged) Q_PROPERTY(bool connected READ getConnected NOTIFY connectedChanged) diff --git a/src/utils/src/deviceinfo.h b/src/utils/src/deviceinfo.h index e4b1a50..44c9d6f 100644 --- a/src/utils/src/deviceinfo.h +++ b/src/utils/src/deviceinfo.h @@ -26,6 +26,8 @@ class DeviceInfo : public QObject { Q_OBJECT + QML_SINGLETON + QML_ELEMENT Q_DISABLE_COPY(DeviceInfo) Q_PROPERTY(bool hasRoundScreen READ hasRoundScreen CONSTANT) Q_PROPERTY(double borderGestureWidth READ borderGestureWidth CONSTANT) @@ -38,11 +40,8 @@ class DeviceInfo : public QObject Q_PROPERTY(QString buildID READ buildID CONSTANT) DeviceInfo(); public: - static QObject *qmlInstance(QQmlEngine *engine, QJSEngine *scriptEngine) + static DeviceInfo *create(QQmlEngine *, QJSEngine *) { - Q_UNUSED(engine); - Q_UNUSED(scriptEngine); - return new DeviceInfo; } bool hasRoundScreen(); diff --git a/src/utils/src/fileinfo.h b/src/utils/src/fileinfo.h index 3aba610..a966e37 100644 --- a/src/utils/src/fileinfo.h +++ b/src/utils/src/fileinfo.h @@ -25,16 +25,16 @@ class FileInfo : public QObject { Q_OBJECT + QML_SINGLETON + QML_ELEMENT Q_DISABLE_COPY(FileInfo) FileInfo() {} public: - static QObject *qmlInstance(QQmlEngine *engine, QJSEngine *scriptEngine) + static FileInfo *create(QQmlEngine *, QJSEngine *) { - Q_UNUSED(engine); - Q_UNUSED(scriptEngine); - return new FileInfo; } + // TODO: FileInfo(QObject *parent = 0); instead? Q_INVOKABLE bool exists(const QString fileName); }; diff --git a/src/utils/src/utils_plugin.cpp b/src/utils/src/utils_plugin.cpp deleted file mode 100644 index 754fee6..0000000 --- a/src/utils/src/utils_plugin.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2016 - Florent Revest - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "utils_plugin.h" -#include -#include "bluetoothstatus.h" -#include "deviceinfo.h" -#include "fileinfo.h" - -UtilsPlugin::UtilsPlugin(QObject *parent) : QQmlExtensionPlugin(parent) -{ -} - -void UtilsPlugin::registerTypes(const char *uri) -{ - Q_ASSERT(uri == QLatin1String("org.asteroid.utils")); - - qmlRegisterSingletonType(uri, 1,0, "DeviceInfo", &DeviceInfo::qmlInstance); - qmlRegisterSingletonType(uri, 1, 0, "FileInfo", &FileInfo::qmlInstance); - qmlRegisterType(uri, 1, 0, "BluetoothStatus"); -} - diff --git a/src/utils/src/utils_plugin.h b/src/utils/src/utils_plugin.h deleted file mode 100644 index e1f79ff..0000000 --- a/src/utils/src/utils_plugin.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2016 - Florent Revest - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef UTILSPLUGIN_H -#define UTILSPLUGIN_H - -#include - -class UtilsPlugin : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") - -public: - explicit UtilsPlugin(QObject *parent = 0); - void registerTypes(const char *uri); -}; - -#endif // UTILSPLUGIN_H - From 556cfe2f77cc3c96387caee136160c816449c28e Mon Sep 17 00:00:00 2001 From: Jami Kettunen Date: Mon, 25 Nov 2024 17:16:51 +0200 Subject: [PATCH 15/15] [RESIVIT] Use CMake qt_qml_add_module() for org.asteroid.controls This one (for now at least) retains the manually written plugin instead of generating one since it also changes the default font instead of just calling qmlRegisterType for each C++ QML component: QGuiApplication::setFont(QFont("Noto Sans")); If another way to accomplish the same task globally for anything using org.asteroid.controls is found the same as one commit above for org.asteroid.utils can also be done here and controls_plugin.* can be done away with. --- src/controls/CMakeLists.txt | 36 ++++++++++++++++++++++++++---------- src/controls/qmldir | 29 ----------------------------- 2 files changed, 26 insertions(+), 39 deletions(-) delete mode 100644 src/controls/qmldir diff --git a/src/controls/CMakeLists.txt b/src/controls/CMakeLists.txt index e46a7c8..36c2a05 100644 --- a/src/controls/CMakeLists.txt +++ b/src/controls/CMakeLists.txt @@ -42,11 +42,24 @@ foreach(control ${controls}) list(APPEND controls-qml "qml/${control}.qml") endforeach() -add_library(asteroidcontrolsplugin ${SRC} ${HEADERS}) +set_source_files_properties(qml/Dims.qml + PROPERTIES QT_QML_SINGLETON_TYPE TRUE) -qt_add_resources(asteroidcontrolsplugin "asteroidcontrolsplugin_qrc" - PREFIX "/org/asteroid/controls/" - FILES "${controls-qml}") +qt_add_qml_module(asteroidcontrolsplugin + URI org.asteroid.controls + VERSION 1.0 + PLUGIN_TARGET asteroidcontrolsplugin + NO_GENERATE_PLUGIN_SOURCE + #NO_PLUGIN_OPTIONAL + QML_FILES + ${controls-qml} + #ENABLE_TYPE_COMPILER + SOURCES + ${SRC} ${HEADERS} +) + +# TODO: drop debug once AOT produces less warnings etc +set_target_properties(asteroidcontrolsplugin PROPERTIES QT_QMLCACHEGEN_ARGUMENTS "--verbose") qt6_add_shaders(asteroidcontrolsplugin "asteroidcontrolsplugin_shaders" PREFIX "/org/asteroid/controls/" @@ -55,6 +68,14 @@ qt6_add_shaders(asteroidcontrolsplugin "asteroidcontrolsplugin_shaders" PRECOMPILE OPTIMIZED) +target_link_libraries(asteroidcontrolsplugin + PUBLIC + #Qt::Qml + Qt::Quick # src/{application_p,flatmesh{,node},icon}.* + PRIVATE + Qt::Svg # src/icon.cpp +) + set(controls-docs "$,PREPEND,qml->,APPEND,.html>") set(doc-dir "${CMAKE_BINARY_DIR}/doc/html") set(full-controls-docs "$") @@ -70,12 +91,7 @@ add_custom_command( COMMENT "Generating HTML format Reference documentation..." VERBATIM ) -target_link_libraries(asteroidcontrolsplugin - Qt::Qml - Qt::Quick - Qt::Svg) - install(TARGETS asteroidcontrolsplugin DESTINATION ${INSTALL_QML_IMPORT_DIR}/org/asteroid/controls) -install(FILES qmldir +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qmldir DESTINATION ${INSTALL_QML_IMPORT_DIR}/org/asteroid/controls) diff --git a/src/controls/qmldir b/src/controls/qmldir deleted file mode 100644 index 88dfe74..0000000 --- a/src/controls/qmldir +++ /dev/null @@ -1,29 +0,0 @@ -module org.asteroid.controls - -plugin asteroidcontrolsplugin - -Application 1.0 qrc:///org/asteroid/controls/qml/Application.qml -BorderGestureArea 1.0 qrc:///org/asteroid/controls/qml/BorderGestureArea.qml -CircularSpinner 1.0 qrc:///org/asteroid/controls/qml/CircularSpinner.qml -singleton Dims 1.0 qrc:///org/asteroid/controls/qml/Dims.qml -HandWritingKeyboard 1.0 qrc:///org/asteroid/controls/qml/HandWritingKeyboard.qml -HighlightBar 1.0 qrc:///org/asteroid/controls/qml/HighlightBar.qml -IconButton 1.0 qrc:///org/asteroid/controls/qml/IconButton.qml -Indicator 1.0 qrc:///org/asteroid/controls/qml/Indicator.qml -IntSelector 1.0 qrc:///org/asteroid/controls/qml/IntSelector.qml -Label 1.0 qrc:///org/asteroid/controls/qml/Label.qml -LabeledActionButton 1.0 qrc:///org/asteroid/controls/qml/LabeledActionButton.qml -LabeledSwitch 1.0 qrc:///org/asteroid/controls/qml/LabeledSwitch.qml -LayerStack 1.0 qrc:///org/asteroid/controls/qml/LayerStack.qml -ListItem 1.0 qrc:///org/asteroid/controls/qml/ListItem.qml -Marquee 1.0 qrc:///org/asteroid/controls/qml/Marquee.qml -PageDot 1.0 qrc:///org/asteroid/controls/qml/PageDot.qml -PageHeader 1.0 qrc:///org/asteroid/controls/qml/PageHeader.qml -SegmentedArc 1.0 qrc:///org/asteroid/controls/qml/SegmentedArc.qml -Spinner 1.0 qrc:///org/asteroid/controls/qml/Spinner.qml -SpinnerDelegate 1.0 qrc:///org/asteroid/controls/qml/SpinnerDelegate.qml -StatusPage 1.0 qrc:///org/asteroid/controls/qml/StatusPage.qml -Switch 1.0 qrc:///org/asteroid/controls/qml/Switch.qml -TextArea 1.0 qrc:///org/asteroid/controls/qml/TextArea.qml -TextBase 1.0 qrc:///org/asteroid/controls/qml/TextBase.qml -TextField 1.0 qrc:///org/asteroid/controls/qml/TextField.qml