From ebfdaeaa2ae4a07fe2c5a37fb35709d8456a69df Mon Sep 17 00:00:00 2001
From: PierrePouchet <pierre.pouchet@etu.ec-lyon.fr>
Date: Mon, 17 Mar 2025 11:07:37 +0100
Subject: [PATCH] =?UTF-8?q?fait=20jusqu'=C3=A0=20fin=20tuto3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 Motus/.gitignore     | 82 ++++++++++++++++++++++++++++++++++++++++++++
 Motus/CMakeLists.txt | 44 ++++++++++++++++++++++++
 Motus/Case.qml       | 20 +++++++++++
 Motus/Main.qml       | 40 +++++++++++++++++++++
 Motus/Ressources.qrc |  5 +++
 Motus/main.cpp       | 18 ++++++++++
 6 files changed, 209 insertions(+)
 create mode 100644 Motus/.gitignore
 create mode 100644 Motus/CMakeLists.txt
 create mode 100644 Motus/Case.qml
 create mode 100644 Motus/Main.qml
 create mode 100644 Motus/Ressources.qrc
 create mode 100644 Motus/main.cpp

diff --git a/Motus/.gitignore b/Motus/.gitignore
new file mode 100644
index 0000000..aa3808c
--- /dev/null
+++ b/Motus/.gitignore
@@ -0,0 +1,82 @@
+# This file is used to ignore files which are generated
+# ----------------------------------------------------------------------------
+
+*~
+*.autosave
+*.a
+*.core
+*.moc
+*.o
+*.obj
+*.orig
+*.rej
+*.so
+*.so.*
+*_pch.h.cpp
+*_resource.rc
+*.qm
+.#*
+*.*#
+core
+!core/
+tags
+.DS_Store
+.directory
+*.debug
+Makefile*
+*.prl
+*.app
+moc_*.cpp
+ui_*.h
+qrc_*.cpp
+Thumbs.db
+*.res
+*.rc
+/.qmake.cache
+/.qmake.stash
+
+# qtcreator generated files
+*.pro.user*
+*.qbs.user*
+CMakeLists.txt.user*
+
+# xemacs temporary files
+*.flc
+
+# Vim temporary files
+.*.swp
+
+# Visual Studio generated files
+*.ib_pdb_index
+*.idb
+*.ilk
+*.pdb
+*.sln
+*.suo
+*.vcproj
+*vcproj.*.*.user
+*.ncb
+*.sdf
+*.opensdf
+*.vcxproj
+*vcxproj.*
+
+# MinGW generated files
+*.Debug
+*.Release
+
+# Python byte code
+*.pyc
+
+# Binaries
+# --------
+*.dll
+*.exe
+
+# Directories with generated files
+.moc/
+.obj/
+.pch/
+.rcc/
+.uic/
+/build*/
diff --git a/Motus/CMakeLists.txt b/Motus/CMakeLists.txt
new file mode 100644
index 0000000..a1bfec2
--- /dev/null
+++ b/Motus/CMakeLists.txt
@@ -0,0 +1,44 @@
+cmake_minimum_required(VERSION 3.16)
+
+project(Motus VERSION 0.1 LANGUAGES CXX)
+
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
+find_package(Qt6 REQUIRED COMPONENTS Quick)
+
+qt_standard_project_setup(REQUIRES 6.5)
+
+qt_add_executable(appMotus
+    main.cpp
+)
+
+qt_add_qml_module(appMotus
+    URI Motus
+    VERSION 1.0
+    QML_FILES
+        Main.qml
+        RESOURCES Ressources.qrc
+        QML_FILES Case.qml
+)
+
+# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
+# If you are developing for iOS or macOS you should consider setting an
+# explicit, fixed bundle identifier manually though.
+set_target_properties(appMotus PROPERTIES
+#    MACOSX_BUNDLE_GUI_IDENTIFIER com.example.appMotus
+    MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
+    MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
+    MACOSX_BUNDLE TRUE
+    WIN32_EXECUTABLE TRUE
+)
+
+target_link_libraries(appMotus
+    PRIVATE Qt6::Quick
+)
+
+include(GNUInstallDirs)
+install(TARGETS appMotus
+    BUNDLE DESTINATION .
+    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+)
diff --git a/Motus/Case.qml b/Motus/Case.qml
new file mode 100644
index 0000000..6b53145
--- /dev/null
+++ b/Motus/Case.qml
@@ -0,0 +1,20 @@
+import QtQuick
+
+Item {
+    width: 90
+    height: 90
+    property alias _textText: _text.text
+
+    Text {
+        id: _text
+        x: 0
+        y: 0
+        width: 90
+        height: 90
+        text: qsTr("Text")
+        font.pixelSize: 24
+        horizontalAlignment: Text.AlignHCenter
+        verticalAlignment: Text.AlignVCenter
+    }
+
+}
diff --git a/Motus/Main.qml b/Motus/Main.qml
new file mode 100644
index 0000000..57039b1
--- /dev/null
+++ b/Motus/Main.qml
@@ -0,0 +1,40 @@
+import QtQuick
+
+Window {
+    width: 1920
+    height: 1080
+    visible: true
+    title: qsTr("Hello World")
+
+    Rectangle {
+        id: rectangle
+        x: 0
+        y: 0
+        width: 1920
+        height: 1080
+        color: "#f56363"
+        focus: true
+
+        Case {
+            id: case1
+            x: 225
+            y: 647
+            _textText: "A"
+        }
+
+        Case {
+            id: case2
+            x: 945
+            y: 736
+            _textText: "B"
+        }
+
+        Keys.onPressed: (event) => {
+            if (event.key === Qt.Key_A) {
+                case1._textText = qsTr("C");  // Correcte modification
+                console.log(event.key + " /// " + event.text);
+                event.accepted = true;
+            }
+        }
+    }
+}
diff --git a/Motus/Ressources.qrc b/Motus/Ressources.qrc
new file mode 100644
index 0000000..388ced6
--- /dev/null
+++ b/Motus/Ressources.qrc
@@ -0,0 +1,5 @@
+<RCC>
+    <qresource prefix="/">
+        <file>Case.qml</file>
+    </qresource>
+</RCC>
diff --git a/Motus/main.cpp b/Motus/main.cpp
new file mode 100644
index 0000000..643f1b0
--- /dev/null
+++ b/Motus/main.cpp
@@ -0,0 +1,18 @@
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+
+int main(int argc, char *argv[])
+{
+    QGuiApplication app(argc, argv);
+
+    QQmlApplicationEngine engine;
+    QObject::connect(
+        &engine,
+        &QQmlApplicationEngine::objectCreationFailed,
+        &app,
+        []() { QCoreApplication::exit(-1); },
+        Qt::QueuedConnection);
+    engine.loadFromModule("Motus", "Main");
+
+    return app.exec();
+}
-- 
GitLab