diff options
| author | Samuli Piippo <samuli.piippo@qt.io> | 2025-02-10 11:04:50 +0200 |
|---|---|---|
| committer | Samuli Piippo <samuli.piippo@qt.io> | 2025-12-02 09:33:02 +0000 |
| commit | 2a2b28bfcf82a70f6d4dd3c3a9e9eb5989e029de (patch) | |
| tree | 526af0a2c2924027e20e2190f43fbd4a6ee46cca | |
| parent | 0ed42f0fca999622b9b6b8971855dab655fe4832 (diff) | |
Add the default example metadata as resources to the demo launcher,
which let's us build the launcher and examples from qtdoc repo
independently without adding metadata from yet another git repo.
The applications-root is stil used to look for additional metadata.
Don't show the demo on the launcher menu unless the binary exists.
Change the metadata so that, if binary path is relative, use the
configured Qt examples path to prefix it. Use the configured Qt
example path also for searching the metadata.
The calqlatr has different name in different Qt version, add both
to support all Qt versions.
Change-Id: Ia59ca8914459126bad309a937a3c671fd7ae5697
Reviewed-by: Ari Parkkila <ari.parkkila@qt.io>
| -rw-r--r-- | CMakeLists.txt | 11 | ||||
| -rw-r--r-- | QtLauncher/QtImageProviders/imageproviders.cpp | 4 | ||||
| -rw-r--r-- | QtLauncher/applicationsmodel.cpp | 14 | ||||
| -rw-r--r-- | main.cpp | 3 | ||||
| -rw-r--r-- | metadata/calqlatr/demo.xml | 7 | ||||
| -rw-r--r-- | metadata/calqlatr/preview.png | bin | 0 -> 15143 bytes | |||
| -rw-r--r-- | metadata/calqlatrexample/demo.xml | 7 | ||||
| -rw-r--r-- | metadata/calqlatrexample/preview.png | bin | 0 -> 15143 bytes | |||
| -rw-r--r-- | metadata/coffee/demo.xml | 7 | ||||
| -rw-r--r-- | metadata/coffee/preview.png | bin | 0 -> 22852 bytes | |||
| -rw-r--r-- | metadata/robotarm/demo.xml | 7 | ||||
| -rw-r--r-- | metadata/robotarm/preview.png | bin | 0 -> 28840 bytes | |||
| -rw-r--r-- | metadata/samegame/demo.xml | 7 | ||||
| -rw-r--r-- | metadata/samegame/preview.png | bin | 0 -> 45216 bytes | |||
| -rw-r--r-- | metadata/stocqt/demo.xml | 7 | ||||
| -rw-r--r-- | metadata/stocqt/preview.png | bin | 0 -> 37743 bytes | |||
| -rw-r--r-- | metadata/thermostat/demo.xml | 7 | ||||
| -rw-r--r-- | metadata/thermostat/preview.png | bin | 0 -> 35478 bytes | |||
| -rw-r--r-- | metadata/todolist/demo.xml | 7 | ||||
| -rw-r--r-- | metadata/todolist/preview.png | bin | 0 -> 14260 bytes |
20 files changed, 82 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ea404a..55ce69d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,17 @@ qt_add_executable(${PROJECT_NAME} main.cpp ) + +# Collect metadata +file(GLOB_RECURSE metadata_glob + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + metadata/*) +list(APPEND metadata ${metadata_glob}) + +qt_add_resources(${PROJECT_NAME} "metadata" + FILES ${metadata} +) + if(NOT DEFINED USE_SHARED_BUILD) target_compile_definitions(${PROJECT_NAME} PRIVATE USE_STATIC_BUILD_FLAG) endif() diff --git a/QtLauncher/QtImageProviders/imageproviders.cpp b/QtLauncher/QtImageProviders/imageproviders.cpp index 6dcd038..726f29e 100644 --- a/QtLauncher/QtImageProviders/imageproviders.cpp +++ b/QtLauncher/QtImageProviders/imageproviders.cpp @@ -62,7 +62,7 @@ QPixmap QtImageProvider::requestPixmap(const QString &id, QSize *size, const QSi Q_UNUSED(requestedSize); QString idd = id; - idd.remove("file://"); + idd.remove("file:"); if (idd.endsWith("_missing")) idd = ":/qt/qml/QtLauncher/QtImageProviders/thumbnail.png"; @@ -89,7 +89,7 @@ QPixmap QtSquareImageProvider::requestPixmap(const QString &id, QSize *size, con QString idd = id; - idd.remove("file://"); + idd.remove("file:"); idd.remove("gradient/"); if (idd.endsWith("_missing")) diff --git a/QtLauncher/applicationsmodel.cpp b/QtLauncher/applicationsmodel.cpp index a706255..c077a16 100644 --- a/QtLauncher/applicationsmodel.cpp +++ b/QtLauncher/applicationsmodel.cpp @@ -12,6 +12,7 @@ #include <QJsonDocument> #include <QJsonObject> #include <QXmlStreamReader> +#include <QLibraryInfo> static bool appOrder(const AppData& a, const AppData& b) { @@ -23,7 +24,7 @@ static bool appOrder(const AppData& a, const AppData& b) void IndexingThread::run() { QList<AppData> results; - QList<QString> roots = root.split(":"); + QList<QString> roots = {root, ":metadata"}; foreach (const QString &root, roots) { QDirIterator it(root, QDir::Dirs | QDir::NoDotDot); while (it.hasNext()) { @@ -71,6 +72,9 @@ void IndexingThread::parseDemo(QString path, QList<AppData> &results) { data.priority = xml.attributes().value("priority").toInt(); data.binary = xml.attributes().value("binary").toString(); + QFileInfo binary(data.binary); + if (!binary.isAbsolute()) + data.binary = QLibraryInfo::path(QLibraryInfo::ExamplesPath) + "/" + data.binary; data.arguments = xml.attributes().value("arguments").toString(); data.scalable = xml.attributes().value("scalable").toInt(); @@ -93,8 +97,12 @@ void IndexingThread::parseDemo(QString path, QList<AppData> &results) { break; case QXmlStreamReader::EndElement: - if (xml.name().toString().toLower() == "application") - results << data; + if (xml.name().toString().toLower() == "application") { + if (QFileInfo::exists(data.binary)) + results << data; + else + qInfo() << "Demo not found:" << data.binary; + } break; default: @@ -9,6 +9,7 @@ #include <QtGui/QFontDatabase> #include <QtGui/QGuiApplication> #include <QtQml/QQmlApplicationEngine> +#include <QtCore/QLibraryInfo> #if defined(USE_STATIC_BUILD_FLAG) #include <QtQml/QQmlEngineExtensionPlugin> @@ -64,7 +65,7 @@ int main(int argc, char **argv) } if (appsRoot.isEmpty()) { - appsRoot = "/usr/share/examples/boot2qt-launcher-demos"; + appsRoot = QLibraryInfo::path(QLibraryInfo::ExamplesPath); } qInfo() << "Applications Root:" << appsRoot; diff --git a/metadata/calqlatr/demo.xml b/metadata/calqlatr/demo.xml new file mode 100644 index 0000000..b881dfc --- /dev/null +++ b/metadata/calqlatr/demo.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<application title="Calqlatr" priority="2" scalable="1" icon="preview.png" binary="demos/calqlatr/bin/calqlatr"> + <description> + A Qt Quick app designed for landscape and portrait devices that uses custom components, responsive layouts, and JavaScript for the application logic. + </description> +</application> diff --git a/metadata/calqlatr/preview.png b/metadata/calqlatr/preview.png Binary files differnew file mode 100644 index 0000000..9490814 --- /dev/null +++ b/metadata/calqlatr/preview.png diff --git a/metadata/calqlatrexample/demo.xml b/metadata/calqlatrexample/demo.xml new file mode 100644 index 0000000..00951c5 --- /dev/null +++ b/metadata/calqlatrexample/demo.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<application title="Calqlatr" priority="2" scalable="1" icon="preview.png" binary="demos/calqlatr/bin/calqlatrexample"> + <description> + A Qt Quick app designed for landscape and portrait devices that uses custom components, responsive layouts, and JavaScript for the application logic. + </description> +</application> diff --git a/metadata/calqlatrexample/preview.png b/metadata/calqlatrexample/preview.png Binary files differnew file mode 100644 index 0000000..9490814 --- /dev/null +++ b/metadata/calqlatrexample/preview.png diff --git a/metadata/coffee/demo.xml b/metadata/coffee/demo.xml new file mode 100644 index 0000000..2363722 --- /dev/null +++ b/metadata/coffee/demo.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<application title="Coffee Machine" priority="5" scalable="1" icon="preview.png" binary="demos/coffee/bin/coffeemachine"> + <description> + A Qt Quick application with a state-based custom user interface. + </description> +</application> diff --git a/metadata/coffee/preview.png b/metadata/coffee/preview.png Binary files differnew file mode 100644 index 0000000..7435373 --- /dev/null +++ b/metadata/coffee/preview.png diff --git a/metadata/robotarm/demo.xml b/metadata/robotarm/demo.xml new file mode 100644 index 0000000..628f27b --- /dev/null +++ b/metadata/robotarm/demo.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<application title="Robot Arm" priority="7" scalable="1" icon="preview.png" binary="demos/robotarm/bin/RobotArmApp"> + <description> + This example demonstrates adding a C++ backend to a 3D project created in Qt Design Studio. The example itself consists of an interactive industrial robot arm in a Qt Quick 3D scene. The 2D UI to control the robot arm is implement using Qt Quick Controls. + </description> +</application> diff --git a/metadata/robotarm/preview.png b/metadata/robotarm/preview.png Binary files differnew file mode 100644 index 0000000..17efae1 --- /dev/null +++ b/metadata/robotarm/preview.png diff --git a/metadata/samegame/demo.xml b/metadata/samegame/demo.xml new file mode 100644 index 0000000..5ba5ed9 --- /dev/null +++ b/metadata/samegame/demo.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<application title="Same Game" priority="5" scalable="0" icon="preview.png" binary="demos/samegame/bin/samegame"> + <description> + Same Game demonstrates a QML game with custom types and logic written in JavaScript. The game uses various Qt Quick features such as particles, animation, and loading images. + </description> +</application> diff --git a/metadata/samegame/preview.png b/metadata/samegame/preview.png Binary files differnew file mode 100644 index 0000000..2ddf43e --- /dev/null +++ b/metadata/samegame/preview.png diff --git a/metadata/stocqt/demo.xml b/metadata/stocqt/demo.xml new file mode 100644 index 0000000..f034de1 --- /dev/null +++ b/metadata/stocqt/demo.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<application title="Qt Quick Demo - StocQt" priority="7" scalable="1" icon="preview.png" binary="demos/stocqt/bin/appStocQt"> + <description> + The StocQt application presents a trend chart for the first stock in the list of NASDAQ-100 stocks. It allows the user to choose another stock from the list, and fetches the required data from the offline dataset using XMLHttpRequest. + </description> +</application> diff --git a/metadata/stocqt/preview.png b/metadata/stocqt/preview.png Binary files differnew file mode 100644 index 0000000..6caf3d2 --- /dev/null +++ b/metadata/stocqt/preview.png diff --git a/metadata/thermostat/demo.xml b/metadata/thermostat/demo.xml new file mode 100644 index 0000000..fb208c9 --- /dev/null +++ b/metadata/thermostat/demo.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<application title="Thermostat" priority="8" scalable="1" icon="preview.png" binary="demos/thermostat/bin/ThermostatApp"> + <description> + A user interface for a home thermostat, implemented in Qt Quick. It demonstrates how to create responsive applications that scale from large desktop displays to mobile and small embedded displays. + </description> +</application> diff --git a/metadata/thermostat/preview.png b/metadata/thermostat/preview.png Binary files differnew file mode 100644 index 0000000..20ecf62 --- /dev/null +++ b/metadata/thermostat/preview.png diff --git a/metadata/todolist/demo.xml b/metadata/todolist/demo.xml new file mode 100644 index 0000000..9b9a66c --- /dev/null +++ b/metadata/todolist/demo.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<application title="To Do List" priority="5" scalable="1" icon="preview.png" binary="demos/todolist/bin/ToDoListApp"> + <description> + A QML implementation of to do list application that demonstrates how to create application thats looks native on any platform. + </description> +</application> diff --git a/metadata/todolist/preview.png b/metadata/todolist/preview.png Binary files differnew file mode 100644 index 0000000..ffe90c2 --- /dev/null +++ b/metadata/todolist/preview.png |
