From 2a2b28bfcf82a70f6d4dd3c3a9e9eb5989e029de Mon Sep 17 00:00:00 2001 From: Samuli Piippo Date: Mon, 10 Feb 2025 11:04:50 +0200 Subject: Add example metadata to resources 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 --- CMakeLists.txt | 11 +++++++++++ QtLauncher/QtImageProviders/imageproviders.cpp | 4 ++-- QtLauncher/applicationsmodel.cpp | 14 +++++++++++--- main.cpp | 3 ++- metadata/calqlatr/demo.xml | 7 +++++++ metadata/calqlatr/preview.png | Bin 0 -> 15143 bytes metadata/calqlatrexample/demo.xml | 7 +++++++ metadata/calqlatrexample/preview.png | Bin 0 -> 15143 bytes metadata/coffee/demo.xml | 7 +++++++ metadata/coffee/preview.png | Bin 0 -> 22852 bytes metadata/robotarm/demo.xml | 7 +++++++ metadata/robotarm/preview.png | Bin 0 -> 28840 bytes metadata/samegame/demo.xml | 7 +++++++ metadata/samegame/preview.png | Bin 0 -> 45216 bytes metadata/stocqt/demo.xml | 7 +++++++ metadata/stocqt/preview.png | Bin 0 -> 37743 bytes metadata/thermostat/demo.xml | 7 +++++++ metadata/thermostat/preview.png | Bin 0 -> 35478 bytes metadata/todolist/demo.xml | 7 +++++++ metadata/todolist/preview.png | Bin 0 -> 14260 bytes 20 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 metadata/calqlatr/demo.xml create mode 100644 metadata/calqlatr/preview.png create mode 100644 metadata/calqlatrexample/demo.xml create mode 100644 metadata/calqlatrexample/preview.png create mode 100644 metadata/coffee/demo.xml create mode 100644 metadata/coffee/preview.png create mode 100644 metadata/robotarm/demo.xml create mode 100644 metadata/robotarm/preview.png create mode 100644 metadata/samegame/demo.xml create mode 100644 metadata/samegame/preview.png create mode 100644 metadata/stocqt/demo.xml create mode 100644 metadata/stocqt/preview.png create mode 100644 metadata/thermostat/demo.xml create mode 100644 metadata/thermostat/preview.png create mode 100644 metadata/todolist/demo.xml create mode 100644 metadata/todolist/preview.png 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 #include #include +#include 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 results; - QList roots = root.split(":"); + QList 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 &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 &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: diff --git a/main.cpp b/main.cpp index 2ce7f18..80f57a3 100644 --- a/main.cpp +++ b/main.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #if defined(USE_STATIC_BUILD_FLAG) #include @@ -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 @@ + + + + + A Qt Quick app designed for landscape and portrait devices that uses custom components, responsive layouts, and JavaScript for the application logic. + + diff --git a/metadata/calqlatr/preview.png b/metadata/calqlatr/preview.png new file mode 100644 index 0000000..9490814 Binary files /dev/null and b/metadata/calqlatr/preview.png differ 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 @@ + + + + + A Qt Quick app designed for landscape and portrait devices that uses custom components, responsive layouts, and JavaScript for the application logic. + + diff --git a/metadata/calqlatrexample/preview.png b/metadata/calqlatrexample/preview.png new file mode 100644 index 0000000..9490814 Binary files /dev/null and b/metadata/calqlatrexample/preview.png differ 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 @@ + + + + + A Qt Quick application with a state-based custom user interface. + + diff --git a/metadata/coffee/preview.png b/metadata/coffee/preview.png new file mode 100644 index 0000000..7435373 Binary files /dev/null and b/metadata/coffee/preview.png differ 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 @@ + + + + + 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. + + diff --git a/metadata/robotarm/preview.png b/metadata/robotarm/preview.png new file mode 100644 index 0000000..17efae1 Binary files /dev/null and b/metadata/robotarm/preview.png differ 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 @@ + + + + + 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. + + diff --git a/metadata/samegame/preview.png b/metadata/samegame/preview.png new file mode 100644 index 0000000..2ddf43e Binary files /dev/null and b/metadata/samegame/preview.png differ 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 @@ + + + + + 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. + + diff --git a/metadata/stocqt/preview.png b/metadata/stocqt/preview.png new file mode 100644 index 0000000..6caf3d2 Binary files /dev/null and b/metadata/stocqt/preview.png differ 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 @@ + + + + + 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. + + diff --git a/metadata/thermostat/preview.png b/metadata/thermostat/preview.png new file mode 100644 index 0000000..20ecf62 Binary files /dev/null and b/metadata/thermostat/preview.png differ 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 @@ + + + + + A QML implementation of to do list application that demonstrates how to create application thats looks native on any platform. + + diff --git a/metadata/todolist/preview.png b/metadata/todolist/preview.png new file mode 100644 index 0000000..ffe90c2 Binary files /dev/null and b/metadata/todolist/preview.png differ -- cgit v1.2.3