diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2023-01-26 16:22:46 +0100 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2023-03-10 16:37:11 +0100 |
commit | e0c4a5ecf9c9fa8cdcda355ec828665c3a3e0b93 (patch) | |
tree | 93c23aa134819814ca3c3d45e253497e8151b9cb /examples/qml | |
parent | 17d0bf258b40064f35189ca3cf62b3179ca65c72 (diff) |
examples: Remove shell example
We did not document it anywhere, the code is rather dated, and if we
want to promote QML as a scripting engine/an interpreter, we would need
to invest quite a bit more effort into a showcase.
Thus, remove the example for now.
Pick-to: 6.5
Task-number: QTBUG-110649
Change-Id: Ie23b26379e7ea72271d793a6928a3757cde2cb12
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'examples/qml')
-rw-r--r-- | examples/qml/CMakeLists.txt | 1 | ||||
-rw-r--r-- | examples/qml/qml.pro | 3 | ||||
-rw-r--r-- | examples/qml/shell/CMakeLists.txt | 47 | ||||
-rw-r--r-- | examples/qml/shell/main.cpp | 116 | ||||
-rw-r--r-- | examples/qml/shell/shell.pro | 9 |
5 files changed, 1 insertions, 175 deletions
diff --git a/examples/qml/CMakeLists.txt b/examples/qml/CMakeLists.txt index 91fc57b8f1..6b3e51bf9f 100644 --- a/examples/qml/CMakeLists.txt +++ b/examples/qml/CMakeLists.txt @@ -3,7 +3,6 @@ add_subdirectory(referenceexamples) add_subdirectory(tutorials) -qt_internal_add_example(shell) if(TARGET Qt::Quick) qt_internal_add_example(qmlextensionplugins) if (TARGET Qt::lupdate) diff --git a/examples/qml/qml.pro b/examples/qml/qml.pro index 5a81c00212..9fe8aab7e0 100644 --- a/examples/qml/qml.pro +++ b/examples/qml/qml.pro @@ -8,8 +8,7 @@ qtHaveModule(quick) { SUBDIRS += \ referenceexamples \ - tutorials \ - shell + tutorials EXAMPLE_FILES = \ dynamicscene \ diff --git a/examples/qml/shell/CMakeLists.txt b/examples/qml/shell/CMakeLists.txt deleted file mode 100644 index b5bda8a4db..0000000000 --- a/examples/qml/shell/CMakeLists.txt +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -cmake_minimum_required(VERSION 3.16) -project(shell LANGUAGES CXX) - -set(CMAKE_AUTOMOC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qml/shell") - -find_package(Qt6 REQUIRED COMPONENTS Core Qml) - -qt_add_executable(shell - main.cpp -) - -set_target_properties(shell PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) - -target_link_libraries(shell PUBLIC - Qt::Core - Qt::Qml -) - -if(WIN32) - set_target_properties(shell PROPERTIES - WIN32_EXECUTABLE FALSE - ) -endif() - -if(APPLE) - set_target_properties(shell PROPERTIES - MACOSX_BUNDLE FALSE - ) -endif() - -install(TARGETS shell - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/qml/shell/main.cpp b/examples/qml/shell/main.cpp deleted file mode 100644 index 6ec72c3d05..0000000000 --- a/examples/qml/shell/main.cpp +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - - -#include <QtCore/qfile.h> -#include <QtCore/qtextstream.h> -#include <QtCore/qstringlist.h> -#include <QtCore/qscopedpointer.h> - -#include <QtCore/QCoreApplication> - -#include <QtQml/qjsengine.h> - -#include <stdlib.h> - - -class CommandInterface : public QObject -{ - Q_OBJECT -public: - Q_INVOKABLE void quit() { m_wantsToQuit = true; } - static bool wantsToQuit() { return m_wantsToQuit; } -private: - static bool m_wantsToQuit; -}; - -bool CommandInterface::m_wantsToQuit = false; - - -static void interactive(QJSEngine *eng) -{ - QTextStream qin(stdin, QFile::ReadOnly); - const char *prompt = "qs> "; - - forever { - QString line; - - printf("%s", prompt); - fflush(stdout); - - line = qin.readLine(); - if (line.isNull()) - break; - - if (line.trimmed().isEmpty()) - continue; - - line += QLatin1Char('\n'); - - QJSValue result = eng->evaluate(line, QLatin1String("typein")); - - fprintf(stderr, "%s\n", qPrintable(result.toString())); - - if (CommandInterface::wantsToQuit()) - break; - } -} - -int main(int argc, char *argv[]) -{ - QCoreApplication app(argc, argv); - QScopedPointer<QJSEngine> eng(new QJSEngine()); - { - QJSValue globalObject = eng->globalObject(); - QJSValue interface = eng->newQObject(new CommandInterface); - globalObject.setProperty("qt", interface); - } - - if (! *++argv) { - interactive(eng.data()); - return EXIT_SUCCESS; - } - - while (const char *arg = *argv++) { - QString fileName = QString::fromLocal8Bit(arg); - - if (fileName == QLatin1String("-i")) { - interactive(eng.data()); - break; - } - - QString contents; - int lineNumber = 1; - - if (fileName == QLatin1String("-")) { - QTextStream stream(stdin, QFile::ReadOnly); - contents = stream.readAll(); - } else { - QFile file(fileName); - if (file.open(QFile::ReadOnly)) { - QTextStream stream(&file); - contents = stream.readAll(); - file.close(); - - // strip off #!/usr/bin/env qjs line - if (contents.startsWith("#!")) { - contents.remove(0, contents.indexOf("\n")); - ++lineNumber; - } - } - } - - if (contents.isEmpty()) - continue; - - QJSValue result = eng->evaluate(contents, fileName, lineNumber); - if (result.isError()) { - fprintf (stderr, " %s\n\n", qPrintable(result.toString())); - return EXIT_FAILURE; - } - } - - return EXIT_SUCCESS; -} - -#include <main.moc> diff --git a/examples/qml/shell/shell.pro b/examples/qml/shell/shell.pro deleted file mode 100644 index 9215108e6d..0000000000 --- a/examples/qml/shell/shell.pro +++ /dev/null @@ -1,9 +0,0 @@ -QT = core qml - -win32: CONFIG += console -mac:CONFIG -= app_bundle - -SOURCES += main.cpp - -target.path = $$[QT_INSTALL_EXAMPLES]/qml/shell -INSTALLS += target |