diff options
Diffstat (limited to 'examples/quickcontrols2')
119 files changed, 671 insertions, 556 deletions
diff --git a/examples/quickcontrols2/CMakeLists.txt b/examples/quickcontrols2/CMakeLists.txt index 7ca535e9ef..4c3c54b032 100644 --- a/examples/quickcontrols2/CMakeLists.txt +++ b/examples/quickcontrols2/CMakeLists.txt @@ -1,14 +1,14 @@ # Generated from quickcontrols2.pro. -add_subdirectory(gallery) +qt_internal_add_example(gallery) add_subdirectory(chattutorial) -add_subdirectory(texteditor) -add_subdirectory(contactlist) -add_subdirectory(sidepanel) -add_subdirectory(swipetoremove) -add_subdirectory(wearable) -add_subdirectory(imagine/automotive) -add_subdirectory(imagine/musicplayer) +qt_internal_add_example(texteditor) +qt_internal_add_example(contactlist) +qt_internal_add_example(sidepanel) +qt_internal_add_example(swipetoremove) +qt_internal_add_example(wearable) +qt_internal_add_example(imagine/automotive) +qt_internal_add_example(imagine/musicplayer) if(TARGET Qt::Widgets) - add_subdirectory(flatstyle) + qt_internal_add_example(flatstyle) endif() diff --git a/examples/quickcontrols2/chattutorial/CMakeLists.txt b/examples/quickcontrols2/chattutorial/CMakeLists.txt index 9bfd799492..88f9cb5cf2 100644 --- a/examples/quickcontrols2/chattutorial/CMakeLists.txt +++ b/examples/quickcontrols2/chattutorial/CMakeLists.txt @@ -1,10 +1,10 @@ # Generated from chattutorial.pro. -add_subdirectory(chapter1-settingup) -add_subdirectory(chapter2-lists) -add_subdirectory(chapter3-navigation) +qt_internal_add_example(chapter1) +qt_internal_add_example(chapter2) +qt_internal_add_example(chapter3) if (TARGET Qt::Sql) - add_subdirectory(chapter4-models) - add_subdirectory(chapter5-styling) + qt_internal_add_example(chapter4) + qt_internal_add_example(chapter5) endif() diff --git a/examples/quickcontrols2/chattutorial/chapter1-settingup/CMakeLists.txt b/examples/quickcontrols2/chattutorial/chapter1-settingup/CMakeLists.txt deleted file mode 100644 index 00cf9f6025..0000000000 --- a/examples/quickcontrols2/chattutorial/chapter1-settingup/CMakeLists.txt +++ /dev/null @@ -1,54 +0,0 @@ -# Generated from chapter1-settingup.pro. - -cmake_minimum_required(VERSION 3.16) -project(chapter1-settingup LANGUAGES CXX) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols2/chattutorial/chapter1-settingup") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Qml) -find_package(Qt6 COMPONENTS Quick) - -qt_add_executable(chapter1-settingup - main.cpp -) -set_target_properties(chapter1-settingup PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(chapter1-settingup PUBLIC - Qt::Core - Qt::Gui - Qt::Qml - Qt::Quick -) - - -# Resources: -set(qml_resource_files - "main.qml" -) - -qt6_add_resources(chapter1-settingup "qml" - PREFIX - "/" - FILES - ${qml_resource_files} -) - -install(TARGETS chapter1-settingup - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/quickcontrols2/chattutorial/chapter1-settingup/chapter1-settingup.pro b/examples/quickcontrols2/chattutorial/chapter1-settingup/chapter1-settingup.pro deleted file mode 100644 index 6b7e71082c..0000000000 --- a/examples/quickcontrols2/chattutorial/chapter1-settingup/chapter1-settingup.pro +++ /dev/null @@ -1,11 +0,0 @@ -TEMPLATE = app - -QT += qml quick -CONFIG += c++11 - -SOURCES += main.cpp - -RESOURCES += qml.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/chattutorial/chapter1-settingup -INSTALLS += target diff --git a/examples/quickcontrols2/chattutorial/chapter1-settingup/qml.qrc b/examples/quickcontrols2/chattutorial/chapter1-settingup/qml.qrc deleted file mode 100644 index 0ff3892d9c..0000000000 --- a/examples/quickcontrols2/chattutorial/chapter1-settingup/qml.qrc +++ /dev/null @@ -1,6 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>main.qml</file> - </qresource> -</RCC> - diff --git a/examples/quickcontrols2/chattutorial/chapter1/CMakeLists.txt b/examples/quickcontrols2/chattutorial/chapter1/CMakeLists.txt new file mode 100644 index 0000000000..4b8770a83d --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter1/CMakeLists.txt @@ -0,0 +1,44 @@ +cmake_minimum_required(VERSION 3.16) +project(chapter1 LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) + +if(NOT DEFINED INSTALL_EXAMPLESDIR) + set(INSTALL_EXAMPLESDIR "examples") +endif() + +set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols2/chattutorial/chapter1") + +find_package(Qt6 COMPONENTS Core Gui Qml Quick) + +qt_add_executable(chattutorial-chapter1 WIN32 MACOSX_BUNDLE + main.cpp +) +target_link_libraries(chattutorial-chapter1 PRIVATE + Qt::Core + Qt::Gui + Qt::Qml + Qt::Quick +) + +qt_add_qml_module(chattutorial-chapter1 + URI chapter1 + VERSION 1.0 + QML_FILES + "main.qml" +) + +qt6_add_resources(chattutorial-chapter1 "conf" + PREFIX + "/" + FILES + "qtquickcontrols2.conf" +) + +install(TARGETS chattutorial-chapter1 + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/examples/quickcontrols2/chattutorial/chapter2-lists/chapter2-lists.pro b/examples/quickcontrols2/chattutorial/chapter1/chapter1.pro index dff0aac2b1..6b50809f20 100644 --- a/examples/quickcontrols2/chattutorial/chapter2-lists/chapter2-lists.pro +++ b/examples/quickcontrols2/chattutorial/chapter1/chapter1.pro @@ -5,8 +5,10 @@ CONFIG += c++11 SOURCES += main.cpp -RESOURCES += qml.qrc \ - ../shared/shared.qrc +resources.files = main.qml +resources.prefix = chapter1/ +RESOURCES += resources \ + qtquickcontrols2.conf -target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/chattutorial/chapter2-lists +target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/chattutorial/chapter1 INSTALLS += target diff --git a/examples/quickcontrols2/chattutorial/chapter3-navigation/main.cpp b/examples/quickcontrols2/chattutorial/chapter1/main.cpp index ea20c89012..ca175ccf9c 100644 --- a/examples/quickcontrols2/chattutorial/chapter3-navigation/main.cpp +++ b/examples/quickcontrols2/chattutorial/chapter1/main.cpp @@ -56,7 +56,7 @@ int main(int argc, char *argv[]) QGuiApplication app(argc, argv); QQmlApplicationEngine engine; - engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + engine.load(QUrl(QStringLiteral("qrc:/chapter1/main.qml"))); return app.exec(); } diff --git a/examples/quickcontrols2/chattutorial/chapter1-settingup/main.qml b/examples/quickcontrols2/chattutorial/chapter1/main.qml index 3dc93e47d0..3dc93e47d0 100644 --- a/examples/quickcontrols2/chattutorial/chapter1-settingup/main.qml +++ b/examples/quickcontrols2/chattutorial/chapter1/main.qml diff --git a/examples/quickcontrols2/chattutorial/chapter1/qtquickcontrols2.conf b/examples/quickcontrols2/chattutorial/chapter1/qtquickcontrols2.conf new file mode 100644 index 0000000000..db9486764e --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter1/qtquickcontrols2.conf @@ -0,0 +1,2 @@ +[Controls] +Style=Basic diff --git a/examples/quickcontrols2/chattutorial/chapter2-lists/CMakeLists.txt b/examples/quickcontrols2/chattutorial/chapter2-lists/CMakeLists.txt deleted file mode 100644 index 9bc55dad96..0000000000 --- a/examples/quickcontrols2/chattutorial/chapter2-lists/CMakeLists.txt +++ /dev/null @@ -1,77 +0,0 @@ -# Generated from chapter2-lists.pro. - -cmake_minimum_required(VERSION 3.16) -project(chapter2-lists LANGUAGES CXX) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols2/chattutorial/chapter2-lists") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Qml) -find_package(Qt6 COMPONENTS Quick) - -qt_add_executable(chapter2-lists - main.cpp -) -set_target_properties(chapter2-lists PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(chapter2-lists PUBLIC - Qt::Core - Qt::Gui - Qt::Qml - Qt::Quick -) - - -# Resources: -set(qml_resource_files - "main.qml" -) - -qt6_add_resources(chapter2-lists "qml" - PREFIX - "/" - FILES - ${qml_resource_files} -) -set(shared_resource_files - "../shared/Albert_Einstein.png" - "../shared/Albert_Einstein@2x.png" - "../shared/Albert_Einstein@3x.png" - "../shared/Albert_Einstein@4x.png" - "../shared/Ernest_Hemingway.png" - "../shared/Ernest_Hemingway@2x.png" - "../shared/Ernest_Hemingway@3x.png" - "../shared/Ernest_Hemingway@4x.png" - "../shared/Hans_Gude.png" - "../shared/Hans_Gude@2x.png" - "../shared/Hans_Gude@3x.png" - "../shared/Hans_Gude@4x.png" -) - -qt6_add_resources(chapter2-lists "shared" - PREFIX - "/" - BASE - "../shared" - FILES - ${shared_resource_files} -) - -install(TARGETS chapter2-lists - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/quickcontrols2/chattutorial/chapter2-lists/qml.qrc b/examples/quickcontrols2/chattutorial/chapter2-lists/qml.qrc deleted file mode 100644 index 0ff3892d9c..0000000000 --- a/examples/quickcontrols2/chattutorial/chapter2-lists/qml.qrc +++ /dev/null @@ -1,6 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>main.qml</file> - </qresource> -</RCC> - diff --git a/examples/quickcontrols2/chattutorial/chapter2/CMakeLists.txt b/examples/quickcontrols2/chattutorial/chapter2/CMakeLists.txt new file mode 100644 index 0000000000..5c73c212ce --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter2/CMakeLists.txt @@ -0,0 +1,57 @@ +cmake_minimum_required(VERSION 3.16) +project(chapter2 LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) + +if(NOT DEFINED INSTALL_EXAMPLESDIR) + set(INSTALL_EXAMPLESDIR "examples") +endif() + +set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols2/chattutorial/chapter2") + +find_package(Qt6 COMPONENTS Core Gui Qml Quick) + +qt_add_executable(chattutorial-chapter2 WIN32 MACOSX_BUNDLE + main.cpp +) +target_link_libraries(chattutorial-chapter2 PRIVATE + Qt::Core + Qt::Gui + Qt::Qml + Qt::Quick +) + +qt_add_qml_module(chattutorial-chapter2 + URI chapter2 + VERSION 1.0 + QML_FILES + "main.qml" + RESOURCES + "images/Albert_Einstein.png" + "images/Albert_Einstein@2x.png" + "images/Albert_Einstein@3x.png" + "images/Albert_Einstein@4x.png" + "images/Ernest_Hemingway.png" + "images/Ernest_Hemingway@2x.png" + "images/Ernest_Hemingway@3x.png" + "images/Ernest_Hemingway@4x.png" + "images/Hans_Gude.png" + "images/Hans_Gude@2x.png" + "images/Hans_Gude@3x.png" + "images/Hans_Gude@4x.png" +) + +qt6_add_resources(chattutorial-chapter2 "conf" + PREFIX + "/" + FILES + "qtquickcontrols2.conf" +) + +install(TARGETS chattutorial-chapter2 + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/examples/quickcontrols2/chattutorial/chapter2/chapter2.pro b/examples/quickcontrols2/chattutorial/chapter2/chapter2.pro new file mode 100644 index 0000000000..15429b7c89 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter2/chapter2.pro @@ -0,0 +1,27 @@ +TEMPLATE = app + +QT += qml quick +CONFIG += c++11 + +SOURCES += main.cpp + +resources.files = \ + images/Albert_Einstein.png \ + images/Albert_Einstein@2x.png \ + images/Albert_Einstein@3x.png \ + images/Albert_Einstein@4x.png \ + images/Ernest_Hemingway.png \ + images/Ernest_Hemingway@2x.png \ + images/Ernest_Hemingway@3x.png \ + images/Ernest_Hemingway@4x.png \ + images/Hans_Gude.png \ + images/Hans_Gude@2x.png \ + images/Hans_Gude@3x.png \ + images/Hans_Gude@4x.png \ + main.qml +resources.prefix = chapter2/ +RESOURCES += resources \ + qtquickcontrols2.conf + +target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/chattutorial/chapter2 +INSTALLS += target diff --git a/examples/quickcontrols2/chattutorial/shared/Albert_Einstein.png b/examples/quickcontrols2/chattutorial/chapter2/images/Albert_Einstein.png Binary files differindex 7c44b90b8d..7c44b90b8d 100644 --- a/examples/quickcontrols2/chattutorial/shared/Albert_Einstein.png +++ b/examples/quickcontrols2/chattutorial/chapter2/images/Albert_Einstein.png diff --git a/examples/quickcontrols2/chattutorial/shared/Albert_Einstein@2x.png b/examples/quickcontrols2/chattutorial/chapter2/images/Albert_Einstein@2x.png Binary files differindex 6ce9c39b6c..6ce9c39b6c 100644 --- a/examples/quickcontrols2/chattutorial/shared/Albert_Einstein@2x.png +++ b/examples/quickcontrols2/chattutorial/chapter2/images/Albert_Einstein@2x.png diff --git a/examples/quickcontrols2/chattutorial/shared/Albert_Einstein@3x.png b/examples/quickcontrols2/chattutorial/chapter2/images/Albert_Einstein@3x.png Binary files differindex aab6a6a162..aab6a6a162 100644 --- a/examples/quickcontrols2/chattutorial/shared/Albert_Einstein@3x.png +++ b/examples/quickcontrols2/chattutorial/chapter2/images/Albert_Einstein@3x.png diff --git a/examples/quickcontrols2/chattutorial/shared/Albert_Einstein@4x.png b/examples/quickcontrols2/chattutorial/chapter2/images/Albert_Einstein@4x.png Binary files differindex 3611284df4..3611284df4 100644 --- a/examples/quickcontrols2/chattutorial/shared/Albert_Einstein@4x.png +++ b/examples/quickcontrols2/chattutorial/chapter2/images/Albert_Einstein@4x.png diff --git a/examples/quickcontrols2/chattutorial/shared/Ernest_Hemingway.png b/examples/quickcontrols2/chattutorial/chapter2/images/Ernest_Hemingway.png Binary files differindex 3ac8992fd9..3ac8992fd9 100644 --- a/examples/quickcontrols2/chattutorial/shared/Ernest_Hemingway.png +++ b/examples/quickcontrols2/chattutorial/chapter2/images/Ernest_Hemingway.png diff --git a/examples/quickcontrols2/chattutorial/shared/Ernest_Hemingway@2x.png b/examples/quickcontrols2/chattutorial/chapter2/images/Ernest_Hemingway@2x.png Binary files differindex 122d9f1e53..122d9f1e53 100644 --- a/examples/quickcontrols2/chattutorial/shared/Ernest_Hemingway@2x.png +++ b/examples/quickcontrols2/chattutorial/chapter2/images/Ernest_Hemingway@2x.png diff --git a/examples/quickcontrols2/chattutorial/shared/Ernest_Hemingway@3x.png b/examples/quickcontrols2/chattutorial/chapter2/images/Ernest_Hemingway@3x.png Binary files differindex 2fe9c2cc1c..2fe9c2cc1c 100644 --- a/examples/quickcontrols2/chattutorial/shared/Ernest_Hemingway@3x.png +++ b/examples/quickcontrols2/chattutorial/chapter2/images/Ernest_Hemingway@3x.png diff --git a/examples/quickcontrols2/chattutorial/shared/Ernest_Hemingway@4x.png b/examples/quickcontrols2/chattutorial/chapter2/images/Ernest_Hemingway@4x.png Binary files differindex 96fb6788b5..96fb6788b5 100644 --- a/examples/quickcontrols2/chattutorial/shared/Ernest_Hemingway@4x.png +++ b/examples/quickcontrols2/chattutorial/chapter2/images/Ernest_Hemingway@4x.png diff --git a/examples/quickcontrols2/chattutorial/shared/Hans_Gude.png b/examples/quickcontrols2/chattutorial/chapter2/images/Hans_Gude.png Binary files differindex 907e38bc61..907e38bc61 100644 --- a/examples/quickcontrols2/chattutorial/shared/Hans_Gude.png +++ b/examples/quickcontrols2/chattutorial/chapter2/images/Hans_Gude.png diff --git a/examples/quickcontrols2/chattutorial/shared/Hans_Gude@2x.png b/examples/quickcontrols2/chattutorial/chapter2/images/Hans_Gude@2x.png Binary files differindex 6837796a83..6837796a83 100644 --- a/examples/quickcontrols2/chattutorial/shared/Hans_Gude@2x.png +++ b/examples/quickcontrols2/chattutorial/chapter2/images/Hans_Gude@2x.png diff --git a/examples/quickcontrols2/chattutorial/shared/Hans_Gude@3x.png b/examples/quickcontrols2/chattutorial/chapter2/images/Hans_Gude@3x.png Binary files differindex 29af422ad3..29af422ad3 100644 --- a/examples/quickcontrols2/chattutorial/shared/Hans_Gude@3x.png +++ b/examples/quickcontrols2/chattutorial/chapter2/images/Hans_Gude@3x.png diff --git a/examples/quickcontrols2/chattutorial/shared/Hans_Gude@4x.png b/examples/quickcontrols2/chattutorial/chapter2/images/Hans_Gude@4x.png Binary files differindex bc35eeaa79..bc35eeaa79 100644 --- a/examples/quickcontrols2/chattutorial/shared/Hans_Gude@4x.png +++ b/examples/quickcontrols2/chattutorial/chapter2/images/Hans_Gude@4x.png diff --git a/examples/quickcontrols2/chattutorial/shared/shared.qrc b/examples/quickcontrols2/chattutorial/chapter2/images/images.qrc index 9eda6aa29c..9eda6aa29c 100644 --- a/examples/quickcontrols2/chattutorial/shared/shared.qrc +++ b/examples/quickcontrols2/chattutorial/chapter2/images/images.qrc diff --git a/examples/quickcontrols2/chattutorial/chapter2-lists/main.cpp b/examples/quickcontrols2/chattutorial/chapter2/main.cpp index ea20c89012..55997aa8ad 100644 --- a/examples/quickcontrols2/chattutorial/chapter2-lists/main.cpp +++ b/examples/quickcontrols2/chattutorial/chapter2/main.cpp @@ -56,7 +56,7 @@ int main(int argc, char *argv[]) QGuiApplication app(argc, argv); QQmlApplicationEngine engine; - engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + engine.load(QUrl(QStringLiteral("qrc:/chapter2/main.qml"))); return app.exec(); } diff --git a/examples/quickcontrols2/chattutorial/chapter2-lists/main.qml b/examples/quickcontrols2/chattutorial/chapter2/main.qml index 66a51d2db2..8a87d41020 100644 --- a/examples/quickcontrols2/chattutorial/chapter2-lists/main.qml +++ b/examples/quickcontrols2/chattutorial/chapter2/main.qml @@ -83,7 +83,7 @@ ApplicationWindow { Image { id: avatar - source: "qrc:/" + modelData.replace(" ", "_") + ".png" + source: "images/" + modelData.replace(" ", "_") + ".png" } } } diff --git a/examples/quickcontrols2/chattutorial/chapter2/qtquickcontrols2.conf b/examples/quickcontrols2/chattutorial/chapter2/qtquickcontrols2.conf new file mode 100644 index 0000000000..db9486764e --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter2/qtquickcontrols2.conf @@ -0,0 +1,2 @@ +[Controls] +Style=Basic diff --git a/examples/quickcontrols2/chattutorial/chapter3-navigation/CMakeLists.txt b/examples/quickcontrols2/chattutorial/chapter3-navigation/CMakeLists.txt deleted file mode 100644 index 6c258e709b..0000000000 --- a/examples/quickcontrols2/chattutorial/chapter3-navigation/CMakeLists.txt +++ /dev/null @@ -1,79 +0,0 @@ -# Generated from chapter3-navigation.pro. - -cmake_minimum_required(VERSION 3.16) -project(chapter3-navigation LANGUAGES CXX) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols2/chattutorial/chapter3-navigation") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Qml) -find_package(Qt6 COMPONENTS Quick) - -qt_add_executable(chapter3-navigation - main.cpp -) -set_target_properties(chapter3-navigation PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(chapter3-navigation PUBLIC - Qt::Core - Qt::Gui - Qt::Qml - Qt::Quick -) - - -# Resources: -set(qml_resource_files - "ContactPage.qml" - "ConversationPage.qml" - "main.qml" -) - -qt6_add_resources(chapter3-navigation "qml" - PREFIX - "/" - FILES - ${qml_resource_files} -) -set(shared_resource_files - "../shared/Albert_Einstein.png" - "../shared/Albert_Einstein@2x.png" - "../shared/Albert_Einstein@3x.png" - "../shared/Albert_Einstein@4x.png" - "../shared/Ernest_Hemingway.png" - "../shared/Ernest_Hemingway@2x.png" - "../shared/Ernest_Hemingway@3x.png" - "../shared/Ernest_Hemingway@4x.png" - "../shared/Hans_Gude.png" - "../shared/Hans_Gude@2x.png" - "../shared/Hans_Gude@3x.png" - "../shared/Hans_Gude@4x.png" -) - -qt6_add_resources(chapter3-navigation "shared" - PREFIX - "/" - BASE - "../shared" - FILES - ${shared_resource_files} -) - -install(TARGETS chapter3-navigation - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/quickcontrols2/chattutorial/chapter3-navigation/chapter3-navigation.pro b/examples/quickcontrols2/chattutorial/chapter3-navigation/chapter3-navigation.pro deleted file mode 100644 index 92736a651d..0000000000 --- a/examples/quickcontrols2/chattutorial/chapter3-navigation/chapter3-navigation.pro +++ /dev/null @@ -1,12 +0,0 @@ -TEMPLATE = app - -QT += qml quick -CONFIG += c++11 - -SOURCES += main.cpp - -RESOURCES += qml.qrc \ - ../shared/shared.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/chattutorial/chapter3-navigation -INSTALLS += target diff --git a/examples/quickcontrols2/chattutorial/chapter3-navigation/qml.qrc b/examples/quickcontrols2/chattutorial/chapter3-navigation/qml.qrc deleted file mode 100644 index a72e1b7134..0000000000 --- a/examples/quickcontrols2/chattutorial/chapter3-navigation/qml.qrc +++ /dev/null @@ -1,7 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>main.qml</file> - <file>ContactPage.qml</file> - <file>ConversationPage.qml</file> - </qresource> -</RCC> diff --git a/examples/quickcontrols2/chattutorial/chapter3/CMakeLists.txt b/examples/quickcontrols2/chattutorial/chapter3/CMakeLists.txt new file mode 100644 index 0000000000..e835d38ac9 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/CMakeLists.txt @@ -0,0 +1,60 @@ +cmake_minimum_required(VERSION 3.16) +project(chapter3 LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) + +if(NOT DEFINED INSTALL_EXAMPLESDIR) + set(INSTALL_EXAMPLESDIR "examples") +endif() + +set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols2/chattutorial/chapter3") + +find_package(Qt6 COMPONENTS Core Gui Qml Quick) + +qt_add_executable(chattutorial-chapter3 WIN32 MACOSX_BUNDLE + main.cpp +) +target_link_libraries(chattutorial-chapter3 PRIVATE + Qt::Core + Qt::Gui + Qt::Qml + Qt::Quick +) + +# Resources: +qt_add_qml_module(chattutorial-chapter3 + URI chapter3 + VERSION 1.0 + QML_FILES + "ContactPage.qml" + "ConversationPage.qml" + "main.qml" + RESOURCES + "images/Albert_Einstein.png" + "images/Albert_Einstein@2x.png" + "images/Albert_Einstein@3x.png" + "images/Albert_Einstein@4x.png" + "images/Ernest_Hemingway.png" + "images/Ernest_Hemingway@2x.png" + "images/Ernest_Hemingway@3x.png" + "images/Ernest_Hemingway@4x.png" + "images/Hans_Gude.png" + "images/Hans_Gude@2x.png" + "images/Hans_Gude@3x.png" + "images/Hans_Gude@4x.png" +) + +qt6_add_resources(chattutorial-chapter3 "conf" + PREFIX + "/" + FILES + "qtquickcontrols2.conf" +) + +install(TARGETS chattutorial-chapter3 + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/examples/quickcontrols2/chattutorial/chapter3-navigation/ContactPage.qml b/examples/quickcontrols2/chattutorial/chapter3/ContactPage.qml index 080d8bdb30..b0be22718e 100644 --- a/examples/quickcontrols2/chattutorial/chapter3-navigation/ContactPage.qml +++ b/examples/quickcontrols2/chattutorial/chapter3/ContactPage.qml @@ -76,11 +76,11 @@ Page { width: listView.width - listView.leftMargin - listView.rightMargin height: avatar.implicitHeight leftPadding: avatar.implicitWidth + 32 - onClicked: root.StackView.view.push("qrc:/ConversationPage.qml", { inConversationWith: modelData }) + onClicked: root.StackView.view.push("ConversationPage.qml", { inConversationWith: modelData }) Image { id: avatar - source: "qrc:/" + modelData.replace(" ", "_") + ".png" + source: "images/" + modelData.replace(" ", "_") + ".png" } } } diff --git a/examples/quickcontrols2/chattutorial/chapter3-navigation/ConversationPage.qml b/examples/quickcontrols2/chattutorial/chapter3/ConversationPage.qml index 2ae56444c7..2ae56444c7 100644 --- a/examples/quickcontrols2/chattutorial/chapter3-navigation/ConversationPage.qml +++ b/examples/quickcontrols2/chattutorial/chapter3/ConversationPage.qml diff --git a/examples/quickcontrols2/chattutorial/chapter3/chapter3.pro b/examples/quickcontrols2/chattutorial/chapter3/chapter3.pro new file mode 100644 index 0000000000..42adc69fe9 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/chapter3.pro @@ -0,0 +1,29 @@ +TEMPLATE = app + +QT += qml quick +CONFIG += c++11 + +SOURCES += main.cpp + +resources.files = \ + ContactPage.qml \ + ConversationPage.qml \ + images/Albert_Einstein.png \ + images/Albert_Einstein@2x.png \ + images/Albert_Einstein@3x.png \ + images/Albert_Einstein@4x.png \ + images/Ernest_Hemingway.png \ + images/Ernest_Hemingway@2x.png \ + images/Ernest_Hemingway@3x.png \ + images/Ernest_Hemingway@4x.png \ + images/Hans_Gude.png \ + images/Hans_Gude@2x.png \ + images/Hans_Gude@3x.png \ + images/Hans_Gude@4x.png \ + main.qml +resources.prefix = chapter3/ +RESOURCES += resources \ + qtquickcontrols2.conf + +target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/chattutorial/chapter3 +INSTALLS += target diff --git a/examples/quickcontrols2/chattutorial/chapter3/images/Albert_Einstein.png b/examples/quickcontrols2/chattutorial/chapter3/images/Albert_Einstein.png Binary files differnew file mode 100644 index 0000000000..7c44b90b8d --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/images/Albert_Einstein.png diff --git a/examples/quickcontrols2/chattutorial/chapter3/images/Albert_Einstein@2x.png b/examples/quickcontrols2/chattutorial/chapter3/images/Albert_Einstein@2x.png Binary files differnew file mode 100644 index 0000000000..6ce9c39b6c --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/images/Albert_Einstein@2x.png diff --git a/examples/quickcontrols2/chattutorial/chapter3/images/Albert_Einstein@3x.png b/examples/quickcontrols2/chattutorial/chapter3/images/Albert_Einstein@3x.png Binary files differnew file mode 100644 index 0000000000..aab6a6a162 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/images/Albert_Einstein@3x.png diff --git a/examples/quickcontrols2/chattutorial/chapter3/images/Albert_Einstein@4x.png b/examples/quickcontrols2/chattutorial/chapter3/images/Albert_Einstein@4x.png Binary files differnew file mode 100644 index 0000000000..3611284df4 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/images/Albert_Einstein@4x.png diff --git a/examples/quickcontrols2/chattutorial/chapter3/images/Ernest_Hemingway.png b/examples/quickcontrols2/chattutorial/chapter3/images/Ernest_Hemingway.png Binary files differnew file mode 100644 index 0000000000..3ac8992fd9 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/images/Ernest_Hemingway.png diff --git a/examples/quickcontrols2/chattutorial/chapter3/images/Ernest_Hemingway@2x.png b/examples/quickcontrols2/chattutorial/chapter3/images/Ernest_Hemingway@2x.png Binary files differnew file mode 100644 index 0000000000..122d9f1e53 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/images/Ernest_Hemingway@2x.png diff --git a/examples/quickcontrols2/chattutorial/chapter3/images/Ernest_Hemingway@3x.png b/examples/quickcontrols2/chattutorial/chapter3/images/Ernest_Hemingway@3x.png Binary files differnew file mode 100644 index 0000000000..2fe9c2cc1c --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/images/Ernest_Hemingway@3x.png diff --git a/examples/quickcontrols2/chattutorial/chapter3/images/Ernest_Hemingway@4x.png b/examples/quickcontrols2/chattutorial/chapter3/images/Ernest_Hemingway@4x.png Binary files differnew file mode 100644 index 0000000000..96fb6788b5 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/images/Ernest_Hemingway@4x.png diff --git a/examples/quickcontrols2/chattutorial/chapter3/images/Hans_Gude.png b/examples/quickcontrols2/chattutorial/chapter3/images/Hans_Gude.png Binary files differnew file mode 100644 index 0000000000..907e38bc61 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/images/Hans_Gude.png diff --git a/examples/quickcontrols2/chattutorial/chapter3/images/Hans_Gude@2x.png b/examples/quickcontrols2/chattutorial/chapter3/images/Hans_Gude@2x.png Binary files differnew file mode 100644 index 0000000000..6837796a83 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/images/Hans_Gude@2x.png diff --git a/examples/quickcontrols2/chattutorial/chapter3/images/Hans_Gude@3x.png b/examples/quickcontrols2/chattutorial/chapter3/images/Hans_Gude@3x.png Binary files differnew file mode 100644 index 0000000000..29af422ad3 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/images/Hans_Gude@3x.png diff --git a/examples/quickcontrols2/chattutorial/chapter3/images/Hans_Gude@4x.png b/examples/quickcontrols2/chattutorial/chapter3/images/Hans_Gude@4x.png Binary files differnew file mode 100644 index 0000000000..bc35eeaa79 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/images/Hans_Gude@4x.png diff --git a/examples/quickcontrols2/chattutorial/chapter3/images/images.qrc b/examples/quickcontrols2/chattutorial/chapter3/images/images.qrc new file mode 100644 index 0000000000..9eda6aa29c --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/images/images.qrc @@ -0,0 +1,16 @@ +<RCC> + <qresource prefix="/"> + <file>Albert_Einstein.png</file> + <file>Albert_Einstein@2x.png</file> + <file>Albert_Einstein@3x.png</file> + <file>Albert_Einstein@4x.png</file> + <file>Ernest_Hemingway.png</file> + <file>Ernest_Hemingway@2x.png</file> + <file>Ernest_Hemingway@3x.png</file> + <file>Ernest_Hemingway@4x.png</file> + <file>Hans_Gude.png</file> + <file>Hans_Gude@2x.png</file> + <file>Hans_Gude@3x.png</file> + <file>Hans_Gude@4x.png</file> + </qresource> +</RCC> diff --git a/examples/quickcontrols2/chattutorial/chapter1-settingup/main.cpp b/examples/quickcontrols2/chattutorial/chapter3/main.cpp index ea20c89012..657318a775 100644 --- a/examples/quickcontrols2/chattutorial/chapter1-settingup/main.cpp +++ b/examples/quickcontrols2/chattutorial/chapter3/main.cpp @@ -56,7 +56,7 @@ int main(int argc, char *argv[]) QGuiApplication app(argc, argv); QQmlApplicationEngine engine; - engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + engine.load(QUrl(QStringLiteral("qrc:/chapter3/main.qml"))); return app.exec(); } diff --git a/examples/quickcontrols2/chattutorial/chapter3-navigation/main.qml b/examples/quickcontrols2/chattutorial/chapter3/main.qml index 029f45e3c8..029f45e3c8 100644 --- a/examples/quickcontrols2/chattutorial/chapter3-navigation/main.qml +++ b/examples/quickcontrols2/chattutorial/chapter3/main.qml diff --git a/examples/quickcontrols2/chattutorial/chapter3/qtquickcontrols2.conf b/examples/quickcontrols2/chattutorial/chapter3/qtquickcontrols2.conf new file mode 100644 index 0000000000..db9486764e --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/qtquickcontrols2.conf @@ -0,0 +1,2 @@ +[Controls] +Style=Basic diff --git a/examples/quickcontrols2/chattutorial/chapter4-models/CMakeLists.txt b/examples/quickcontrols2/chattutorial/chapter4-models/CMakeLists.txt deleted file mode 100644 index 6c11375ed5..0000000000 --- a/examples/quickcontrols2/chattutorial/chapter4-models/CMakeLists.txt +++ /dev/null @@ -1,83 +0,0 @@ -# Generated from chapter4-models.pro. - -cmake_minimum_required(VERSION 3.16) -project(chapter4-models LANGUAGES CXX) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols2/chattutorial/chapter4-models") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Qml) -find_package(Qt6 COMPONENTS Quick) -find_package(Qt6 COMPONENTS Sql) - -qt_add_executable(chapter4-models - main.cpp - sqlcontactmodel.cpp sqlcontactmodel.h - sqlconversationmodel.cpp sqlconversationmodel.h -) -set_target_properties(chapter4-models PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(chapter4-models PUBLIC - Qt::Core - Qt::Gui - Qt::Qml - Qt::Quick - Qt::Sql -) - - -# Resources: -set(qml_resource_files - "ContactPage.qml" - "ConversationPage.qml" - "main.qml" -) - -qt6_add_resources(chapter4-models "qml" - PREFIX - "/" - FILES - ${qml_resource_files} -) -set(shared_resource_files - "../shared/Albert_Einstein.png" - "../shared/Albert_Einstein@2x.png" - "../shared/Albert_Einstein@3x.png" - "../shared/Albert_Einstein@4x.png" - "../shared/Ernest_Hemingway.png" - "../shared/Ernest_Hemingway@2x.png" - "../shared/Ernest_Hemingway@3x.png" - "../shared/Ernest_Hemingway@4x.png" - "../shared/Hans_Gude.png" - "../shared/Hans_Gude@2x.png" - "../shared/Hans_Gude@3x.png" - "../shared/Hans_Gude@4x.png" -) - -qt6_add_resources(chapter4-models "shared" - PREFIX - "/" - BASE - "../shared" - FILES - ${shared_resource_files} -) - -install(TARGETS chapter4-models - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/quickcontrols2/chattutorial/chapter4-models/chapter4-models.pro b/examples/quickcontrols2/chattutorial/chapter4-models/chapter4-models.pro deleted file mode 100644 index 2a2d955b1a..0000000000 --- a/examples/quickcontrols2/chattutorial/chapter4-models/chapter4-models.pro +++ /dev/null @@ -1,18 +0,0 @@ -TEMPLATE = app - -QT += qml quick sql -CONFIG += c++11 - -HEADERS += sqlcontactmodel.h \ - sqlconversationmodel.h - -SOURCES += main.cpp \ - sqlcontactmodel.cpp \ - sqlconversationmodel.cpp - -RESOURCES += \ - qml.qrc \ - ../shared/shared.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/chattutorial/chapter4-models -INSTALLS += target diff --git a/examples/quickcontrols2/chattutorial/chapter4-models/qml.qrc b/examples/quickcontrols2/chattutorial/chapter4-models/qml.qrc deleted file mode 100644 index a72e1b7134..0000000000 --- a/examples/quickcontrols2/chattutorial/chapter4-models/qml.qrc +++ /dev/null @@ -1,7 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>main.qml</file> - <file>ContactPage.qml</file> - <file>ConversationPage.qml</file> - </qresource> -</RCC> diff --git a/examples/quickcontrols2/chattutorial/chapter4/CMakeLists.txt b/examples/quickcontrols2/chattutorial/chapter4/CMakeLists.txt new file mode 100644 index 0000000000..aba8c1000b --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/CMakeLists.txt @@ -0,0 +1,63 @@ +cmake_minimum_required(VERSION 3.16) +project(chapter4 LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) + +if(NOT DEFINED INSTALL_EXAMPLESDIR) + set(INSTALL_EXAMPLESDIR "examples") +endif() + +set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols2/chattutorial/chapter4") + +find_package(Qt6 COMPONENTS Core Gui Qml Quick Sql) + +qt_add_executable(chattutorial-chapter4 WIN32 MACOSX_BUNDLE + main.cpp + sqlcontactmodel.cpp sqlcontactmodel.h + sqlconversationmodel.cpp sqlconversationmodel.h +) +target_link_libraries(chattutorial-chapter4 PRIVATE + Qt::Core + Qt::Gui + Qt::Qml + Qt::Quick + Qt::Sql +) + +# Resources: +qt_add_qml_module(chattutorial-chapter4 + URI chapter4 + VERSION 1.0 + QML_FILES + "ContactPage.qml" + "ConversationPage.qml" + "main.qml" + RESOURCES + "images/Albert_Einstein.png" + "images/Albert_Einstein@2x.png" + "images/Albert_Einstein@3x.png" + "images/Albert_Einstein@4x.png" + "images/Ernest_Hemingway.png" + "images/Ernest_Hemingway@2x.png" + "images/Ernest_Hemingway@3x.png" + "images/Ernest_Hemingway@4x.png" + "images/Hans_Gude.png" + "images/Hans_Gude@2x.png" + "images/Hans_Gude@3x.png" + "images/Hans_Gude@4x.png" +) + +qt6_add_resources(chattutorial-chapter4 "conf" + PREFIX + "/" + FILES + "qtquickcontrols2.conf" +) + +install(TARGETS chattutorial-chapter4 + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/examples/quickcontrols2/chattutorial/chapter4-models/ContactPage.qml b/examples/quickcontrols2/chattutorial/chapter4/ContactPage.qml index c8e8872420..e0fc2e12c9 100644 --- a/examples/quickcontrols2/chattutorial/chapter4-models/ContactPage.qml +++ b/examples/quickcontrols2/chattutorial/chapter4/ContactPage.qml @@ -78,11 +78,11 @@ Page { width: listView.width - listView.leftMargin - listView.rightMargin height: avatar.implicitHeight leftPadding: avatar.implicitWidth + 32 - onClicked: root.StackView.view.push("qrc:/ConversationPage.qml", { inConversationWith: model.display }) + onClicked: root.StackView.view.push("ConversationPage.qml", { inConversationWith: model.display }) Image { id: avatar - source: "qrc:/" + model.display.replace(" ", "_") + ".png" + source: "images/" + model.display.replace(" ", "_") + ".png" } } } diff --git a/examples/quickcontrols2/chattutorial/chapter4-models/ConversationPage.qml b/examples/quickcontrols2/chattutorial/chapter4/ConversationPage.qml index 35f770f58b..f69ebcd467 100644 --- a/examples/quickcontrols2/chattutorial/chapter4-models/ConversationPage.qml +++ b/examples/quickcontrols2/chattutorial/chapter4/ConversationPage.qml @@ -104,7 +104,7 @@ Page { Image { id: avatar - source: !sentByMe ? "qrc:/" + model.author.replace(" ", "_") + ".png" : "" + source: !sentByMe ? "images/" + model.author.replace(" ", "_") + ".png" : "" } Rectangle { diff --git a/examples/quickcontrols2/chattutorial/chapter4/chapter4.pro b/examples/quickcontrols2/chattutorial/chapter4/chapter4.pro new file mode 100644 index 0000000000..ae8141f7f1 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/chapter4.pro @@ -0,0 +1,34 @@ +TEMPLATE = app + +QT += qml quick sql +CONFIG += c++11 + +HEADERS += sqlcontactmodel.h \ + sqlconversationmodel.h + +SOURCES += main.cpp \ + sqlcontactmodel.cpp \ + sqlconversationmodel.cpp + +resources.files = \ + ContactPage.qml \ + ConversationPage.qml \ + images/Albert_Einstein.png \ + images/Albert_Einstein@2x.png \ + images/Albert_Einstein@3x.png \ + images/Albert_Einstein@4x.png \ + images/Ernest_Hemingway.png \ + images/Ernest_Hemingway@2x.png \ + images/Ernest_Hemingway@3x.png \ + images/Ernest_Hemingway@4x.png \ + images/Hans_Gude.png \ + images/Hans_Gude@2x.png \ + images/Hans_Gude@3x.png \ + images/Hans_Gude@4x.png \ + main.qml +resources.prefix = chapter4/ +RESOURCES += resources \ + qtquickcontrols2.conf + +target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/chattutorial/chapter4 +INSTALLS += target diff --git a/examples/quickcontrols2/chattutorial/chapter4/images/Albert_Einstein.png b/examples/quickcontrols2/chattutorial/chapter4/images/Albert_Einstein.png Binary files differnew file mode 100644 index 0000000000..7c44b90b8d --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/images/Albert_Einstein.png diff --git a/examples/quickcontrols2/chattutorial/chapter4/images/Albert_Einstein@2x.png b/examples/quickcontrols2/chattutorial/chapter4/images/Albert_Einstein@2x.png Binary files differnew file mode 100644 index 0000000000..6ce9c39b6c --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/images/Albert_Einstein@2x.png diff --git a/examples/quickcontrols2/chattutorial/chapter4/images/Albert_Einstein@3x.png b/examples/quickcontrols2/chattutorial/chapter4/images/Albert_Einstein@3x.png Binary files differnew file mode 100644 index 0000000000..aab6a6a162 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/images/Albert_Einstein@3x.png diff --git a/examples/quickcontrols2/chattutorial/chapter4/images/Albert_Einstein@4x.png b/examples/quickcontrols2/chattutorial/chapter4/images/Albert_Einstein@4x.png Binary files differnew file mode 100644 index 0000000000..3611284df4 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/images/Albert_Einstein@4x.png diff --git a/examples/quickcontrols2/chattutorial/chapter4/images/Ernest_Hemingway.png b/examples/quickcontrols2/chattutorial/chapter4/images/Ernest_Hemingway.png Binary files differnew file mode 100644 index 0000000000..3ac8992fd9 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/images/Ernest_Hemingway.png diff --git a/examples/quickcontrols2/chattutorial/chapter4/images/Ernest_Hemingway@2x.png b/examples/quickcontrols2/chattutorial/chapter4/images/Ernest_Hemingway@2x.png Binary files differnew file mode 100644 index 0000000000..122d9f1e53 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/images/Ernest_Hemingway@2x.png diff --git a/examples/quickcontrols2/chattutorial/chapter4/images/Ernest_Hemingway@3x.png b/examples/quickcontrols2/chattutorial/chapter4/images/Ernest_Hemingway@3x.png Binary files differnew file mode 100644 index 0000000000..2fe9c2cc1c --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/images/Ernest_Hemingway@3x.png diff --git a/examples/quickcontrols2/chattutorial/chapter4/images/Ernest_Hemingway@4x.png b/examples/quickcontrols2/chattutorial/chapter4/images/Ernest_Hemingway@4x.png Binary files differnew file mode 100644 index 0000000000..96fb6788b5 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/images/Ernest_Hemingway@4x.png diff --git a/examples/quickcontrols2/chattutorial/chapter4/images/Hans_Gude.png b/examples/quickcontrols2/chattutorial/chapter4/images/Hans_Gude.png Binary files differnew file mode 100644 index 0000000000..907e38bc61 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/images/Hans_Gude.png diff --git a/examples/quickcontrols2/chattutorial/chapter4/images/Hans_Gude@2x.png b/examples/quickcontrols2/chattutorial/chapter4/images/Hans_Gude@2x.png Binary files differnew file mode 100644 index 0000000000..6837796a83 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/images/Hans_Gude@2x.png diff --git a/examples/quickcontrols2/chattutorial/chapter4/images/Hans_Gude@3x.png b/examples/quickcontrols2/chattutorial/chapter4/images/Hans_Gude@3x.png Binary files differnew file mode 100644 index 0000000000..29af422ad3 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/images/Hans_Gude@3x.png diff --git a/examples/quickcontrols2/chattutorial/chapter4/images/Hans_Gude@4x.png b/examples/quickcontrols2/chattutorial/chapter4/images/Hans_Gude@4x.png Binary files differnew file mode 100644 index 0000000000..bc35eeaa79 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/images/Hans_Gude@4x.png diff --git a/examples/quickcontrols2/chattutorial/chapter4/images/images.qrc b/examples/quickcontrols2/chattutorial/chapter4/images/images.qrc new file mode 100644 index 0000000000..9eda6aa29c --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/images/images.qrc @@ -0,0 +1,16 @@ +<RCC> + <qresource prefix="/"> + <file>Albert_Einstein.png</file> + <file>Albert_Einstein@2x.png</file> + <file>Albert_Einstein@3x.png</file> + <file>Albert_Einstein@4x.png</file> + <file>Ernest_Hemingway.png</file> + <file>Ernest_Hemingway@2x.png</file> + <file>Ernest_Hemingway@3x.png</file> + <file>Ernest_Hemingway@4x.png</file> + <file>Hans_Gude.png</file> + <file>Hans_Gude@2x.png</file> + <file>Hans_Gude@3x.png</file> + <file>Hans_Gude@4x.png</file> + </qresource> +</RCC> diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/main.cpp b/examples/quickcontrols2/chattutorial/chapter4/main.cpp index bbe7b3ad66..e4a06399e8 100644 --- a/examples/quickcontrols2/chattutorial/chapter5-styling/main.cpp +++ b/examples/quickcontrols2/chattutorial/chapter4/main.cpp @@ -90,7 +90,7 @@ int main(int argc, char *argv[]) connectToDatabase(); QQmlApplicationEngine engine; - engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + engine.load(QUrl(QStringLiteral("qrc:/chapter4/main.qml"))); if (engine.rootObjects().isEmpty()) return -1; diff --git a/examples/quickcontrols2/chattutorial/chapter4-models/main.qml b/examples/quickcontrols2/chattutorial/chapter4/main.qml index 029f45e3c8..029f45e3c8 100644 --- a/examples/quickcontrols2/chattutorial/chapter4-models/main.qml +++ b/examples/quickcontrols2/chattutorial/chapter4/main.qml diff --git a/examples/quickcontrols2/chattutorial/chapter4/qtquickcontrols2.conf b/examples/quickcontrols2/chattutorial/chapter4/qtquickcontrols2.conf new file mode 100644 index 0000000000..db9486764e --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/qtquickcontrols2.conf @@ -0,0 +1,2 @@ +[Controls] +Style=Basic diff --git a/examples/quickcontrols2/chattutorial/chapter4-models/sqlcontactmodel.cpp b/examples/quickcontrols2/chattutorial/chapter4/sqlcontactmodel.cpp index 6203ebec1e..6203ebec1e 100644 --- a/examples/quickcontrols2/chattutorial/chapter4-models/sqlcontactmodel.cpp +++ b/examples/quickcontrols2/chattutorial/chapter4/sqlcontactmodel.cpp diff --git a/examples/quickcontrols2/chattutorial/chapter4-models/sqlcontactmodel.h b/examples/quickcontrols2/chattutorial/chapter4/sqlcontactmodel.h index fdbe5f1e70..5953c76258 100644 --- a/examples/quickcontrols2/chattutorial/chapter4-models/sqlcontactmodel.h +++ b/examples/quickcontrols2/chattutorial/chapter4/sqlcontactmodel.h @@ -56,7 +56,7 @@ class SqlContactModel : public QSqlQueryModel { public: - SqlContactModel(QObject *parent = 0); + SqlContactModel(QObject *parent = nullptr); }; #endif // SQLCONTACTMODEL_H diff --git a/examples/quickcontrols2/chattutorial/chapter4-models/sqlconversationmodel.cpp b/examples/quickcontrols2/chattutorial/chapter4/sqlconversationmodel.cpp index 99526e81d3..99526e81d3 100644 --- a/examples/quickcontrols2/chattutorial/chapter4-models/sqlconversationmodel.cpp +++ b/examples/quickcontrols2/chattutorial/chapter4/sqlconversationmodel.cpp diff --git a/examples/quickcontrols2/chattutorial/chapter4-models/sqlconversationmodel.h b/examples/quickcontrols2/chattutorial/chapter4/sqlconversationmodel.h index 14ab12e262..9c65d64a84 100644 --- a/examples/quickcontrols2/chattutorial/chapter4-models/sqlconversationmodel.h +++ b/examples/quickcontrols2/chattutorial/chapter4/sqlconversationmodel.h @@ -59,7 +59,7 @@ class SqlConversationModel : public QSqlTableModel Q_PROPERTY(QString recipient READ recipient WRITE setRecipient NOTIFY recipientChanged) public: - SqlConversationModel(QObject *parent = 0); + SqlConversationModel(QObject *parent = nullptr); QString recipient() const; void setRecipient(const QString &recipient); diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/CMakeLists.txt b/examples/quickcontrols2/chattutorial/chapter5-styling/CMakeLists.txt deleted file mode 100644 index 80a9bde0e1..0000000000 --- a/examples/quickcontrols2/chattutorial/chapter5-styling/CMakeLists.txt +++ /dev/null @@ -1,86 +0,0 @@ -# Generated from chapter5-styling.pro. - -cmake_minimum_required(VERSION 3.16) -project(chapter5-styling LANGUAGES CXX) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols2/chattutorial/chapter5-styling") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Qml) -find_package(Qt6 COMPONENTS Quick) -find_package(Qt6 COMPONENTS Sql) - -qt_add_executable(chapter5-styling - main.cpp - sqlcontactmodel.cpp sqlcontactmodel.h - sqlconversationmodel.cpp sqlconversationmodel.h -) -set_target_properties(chapter5-styling PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(chapter5-styling PUBLIC - Qt::Core - Qt::Gui - Qt::Qml - Qt::Quick - Qt::Sql -) - - -# Resources: -set(qml_resource_files - "+Material/ChatToolBar.qml" - "ChatToolBar.qml" - "ContactPage.qml" - "ConversationPage.qml" - "main.qml" - "qtquickcontrols2.conf" -) - -qt6_add_resources(chapter5-styling "qml" - PREFIX - "/" - FILES - ${qml_resource_files} -) -set(shared_resource_files - "../shared/Albert_Einstein.png" - "../shared/Albert_Einstein@2x.png" - "../shared/Albert_Einstein@3x.png" - "../shared/Albert_Einstein@4x.png" - "../shared/Ernest_Hemingway.png" - "../shared/Ernest_Hemingway@2x.png" - "../shared/Ernest_Hemingway@3x.png" - "../shared/Ernest_Hemingway@4x.png" - "../shared/Hans_Gude.png" - "../shared/Hans_Gude@2x.png" - "../shared/Hans_Gude@3x.png" - "../shared/Hans_Gude@4x.png" -) - -qt6_add_resources(chapter5-styling "shared" - PREFIX - "/" - BASE - "../shared" - FILES - ${shared_resource_files} -) - -install(TARGETS chapter5-styling - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/chapter5-styling.pro b/examples/quickcontrols2/chattutorial/chapter5-styling/chapter5-styling.pro deleted file mode 100644 index e798fe3cd7..0000000000 --- a/examples/quickcontrols2/chattutorial/chapter5-styling/chapter5-styling.pro +++ /dev/null @@ -1,18 +0,0 @@ -TEMPLATE = app - -QT += qml quick sql -CONFIG += c++11 - -HEADERS += sqlcontactmodel.h \ - sqlconversationmodel.h - -SOURCES += main.cpp \ - sqlcontactmodel.cpp \ - sqlconversationmodel.cpp - -RESOURCES += \ - qml.qrc \ - ../shared/shared.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/chattutorial/chapter5-styling -INSTALLS += target diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/qml.qrc b/examples/quickcontrols2/chattutorial/chapter5-styling/qml.qrc deleted file mode 100644 index 54cf6d5a99..0000000000 --- a/examples/quickcontrols2/chattutorial/chapter5-styling/qml.qrc +++ /dev/null @@ -1,10 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>main.qml</file> - <file>ContactPage.qml</file> - <file>ConversationPage.qml</file> - <file>qtquickcontrols2.conf</file> - <file>ChatToolBar.qml</file> - <file>+Material/ChatToolBar.qml</file> - </qresource> -</RCC> diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/+Material/ChatToolBar.qml b/examples/quickcontrols2/chattutorial/chapter5/+Material/ChatToolBar.qml index d4a66764bd..d4a66764bd 100644 --- a/examples/quickcontrols2/chattutorial/chapter5-styling/+Material/ChatToolBar.qml +++ b/examples/quickcontrols2/chattutorial/chapter5/+Material/ChatToolBar.qml diff --git a/examples/quickcontrols2/chattutorial/chapter5/CMakeLists.txt b/examples/quickcontrols2/chattutorial/chapter5/CMakeLists.txt new file mode 100644 index 0000000000..1d39757f1d --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter5/CMakeLists.txt @@ -0,0 +1,65 @@ +cmake_minimum_required(VERSION 3.16) +project(chapter5 LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) + +if(NOT DEFINED INSTALL_EXAMPLESDIR) + set(INSTALL_EXAMPLESDIR "examples") +endif() + +set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols2/chattutorial/chapter5") + +find_package(Qt6 COMPONENTS Core Gui Qml Quick Sql) + +qt_add_executable(chattutorial-chapter5 WIN32 MACOSX_BUNDLE + main.cpp + sqlcontactmodel.cpp sqlcontactmodel.h + sqlconversationmodel.cpp sqlconversationmodel.h +) +target_link_libraries(chattutorial-chapter5 PRIVATE + Qt::Core + Qt::Gui + Qt::Qml + Qt::Quick + Qt::Sql +) + +# Resources: +qt_add_qml_module(chattutorial-chapter5 + URI chapter5 + VERSION 1.0 + QML_FILES + "+Material/ChatToolBar.qml" + "ChatToolBar.qml" + "ContactPage.qml" + "ConversationPage.qml" + "main.qml" + RESOURCES + "images/Albert_Einstein.png" + "images/Albert_Einstein@2x.png" + "images/Albert_Einstein@3x.png" + "images/Albert_Einstein@4x.png" + "images/Ernest_Hemingway.png" + "images/Ernest_Hemingway@2x.png" + "images/Ernest_Hemingway@3x.png" + "images/Ernest_Hemingway@4x.png" + "images/Hans_Gude.png" + "images/Hans_Gude@2x.png" + "images/Hans_Gude@3x.png" + "images/Hans_Gude@4x.png" +) + +qt6_add_resources(chattutorial-chapter5 "conf" + PREFIX + "/" + FILES + "qtquickcontrols2.conf" +) + +install(TARGETS chattutorial-chapter5 + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/ChatToolBar.qml b/examples/quickcontrols2/chattutorial/chapter5/ChatToolBar.qml index c192aeb51a..c192aeb51a 100644 --- a/examples/quickcontrols2/chattutorial/chapter5-styling/ChatToolBar.qml +++ b/examples/quickcontrols2/chattutorial/chapter5/ChatToolBar.qml diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/ContactPage.qml b/examples/quickcontrols2/chattutorial/chapter5/ContactPage.qml index 65460bf127..34a138edca 100644 --- a/examples/quickcontrols2/chattutorial/chapter5-styling/ContactPage.qml +++ b/examples/quickcontrols2/chattutorial/chapter5/ContactPage.qml @@ -78,11 +78,11 @@ Page { width: listView.width - listView.leftMargin - listView.rightMargin height: avatar.implicitHeight leftPadding: avatar.implicitWidth + 32 - onClicked: root.StackView.view.push("qrc:/ConversationPage.qml", { inConversationWith: model.display }) + onClicked: root.StackView.view.push("ConversationPage.qml", { inConversationWith: model.display }) Image { id: avatar - source: "qrc:/" + model.display.replace(" ", "_") + ".png" + source: "images/" + model.display.replace(" ", "_") + ".png" } } } diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/ConversationPage.qml b/examples/quickcontrols2/chattutorial/chapter5/ConversationPage.qml index c668072e34..60dbc4a2ee 100644 --- a/examples/quickcontrols2/chattutorial/chapter5-styling/ConversationPage.qml +++ b/examples/quickcontrols2/chattutorial/chapter5/ConversationPage.qml @@ -104,7 +104,7 @@ Page { Image { id: avatar - source: !sentByMe ? "qrc:/" + model.author.replace(" ", "_") + ".png" : "" + source: !sentByMe ? "images/" + model.author.replace(" ", "_") + ".png" : "" } Rectangle { diff --git a/examples/quickcontrols2/chattutorial/chapter5/chapter5.pro b/examples/quickcontrols2/chattutorial/chapter5/chapter5.pro new file mode 100644 index 0000000000..625642d7b5 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter5/chapter5.pro @@ -0,0 +1,36 @@ +TEMPLATE = app + +QT += qml quick sql +CONFIG += c++11 + +HEADERS += sqlcontactmodel.h \ + sqlconversationmodel.h + +SOURCES += main.cpp \ + sqlcontactmodel.cpp \ + sqlconversationmodel.cpp + +resources.files = \ + +Material/ChatToolBar.qml \ + ChatToolBar.qml \ + ContactPage.qml \ + ConversationPage.qml \ + images/Albert_Einstein.png \ + images/Albert_Einstein@2x.png \ + images/Albert_Einstein@3x.png \ + images/Albert_Einstein@4x.png \ + images/Ernest_Hemingway.png \ + images/Ernest_Hemingway@2x.png \ + images/Ernest_Hemingway@3x.png \ + images/Ernest_Hemingway@4x.png \ + images/Hans_Gude.png \ + images/Hans_Gude@2x.png \ + images/Hans_Gude@3x.png \ + images/Hans_Gude@4x.png \ + main.qml +resources.prefix = chapter5/ +RESOURCES += resources \ + qtquickcontrols2.conf + +target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/chattutorial/chapter5 +INSTALLS += target diff --git a/examples/quickcontrols2/chattutorial/chapter5/images/Albert_Einstein.png b/examples/quickcontrols2/chattutorial/chapter5/images/Albert_Einstein.png Binary files differnew file mode 100644 index 0000000000..7c44b90b8d --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter5/images/Albert_Einstein.png diff --git a/examples/quickcontrols2/chattutorial/chapter5/images/Albert_Einstein@2x.png b/examples/quickcontrols2/chattutorial/chapter5/images/Albert_Einstein@2x.png Binary files differnew file mode 100644 index 0000000000..6ce9c39b6c --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter5/images/Albert_Einstein@2x.png diff --git a/examples/quickcontrols2/chattutorial/chapter5/images/Albert_Einstein@3x.png b/examples/quickcontrols2/chattutorial/chapter5/images/Albert_Einstein@3x.png Binary files differnew file mode 100644 index 0000000000..aab6a6a162 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter5/images/Albert_Einstein@3x.png diff --git a/examples/quickcontrols2/chattutorial/chapter5/images/Albert_Einstein@4x.png b/examples/quickcontrols2/chattutorial/chapter5/images/Albert_Einstein@4x.png Binary files differnew file mode 100644 index 0000000000..3611284df4 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter5/images/Albert_Einstein@4x.png diff --git a/examples/quickcontrols2/chattutorial/chapter5/images/Ernest_Hemingway.png b/examples/quickcontrols2/chattutorial/chapter5/images/Ernest_Hemingway.png Binary files differnew file mode 100644 index 0000000000..3ac8992fd9 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter5/images/Ernest_Hemingway.png diff --git a/examples/quickcontrols2/chattutorial/chapter5/images/Ernest_Hemingway@2x.png b/examples/quickcontrols2/chattutorial/chapter5/images/Ernest_Hemingway@2x.png Binary files differnew file mode 100644 index 0000000000..122d9f1e53 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter5/images/Ernest_Hemingway@2x.png diff --git a/examples/quickcontrols2/chattutorial/chapter5/images/Ernest_Hemingway@3x.png b/examples/quickcontrols2/chattutorial/chapter5/images/Ernest_Hemingway@3x.png Binary files differnew file mode 100644 index 0000000000..2fe9c2cc1c --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter5/images/Ernest_Hemingway@3x.png diff --git a/examples/quickcontrols2/chattutorial/chapter5/images/Ernest_Hemingway@4x.png b/examples/quickcontrols2/chattutorial/chapter5/images/Ernest_Hemingway@4x.png Binary files differnew file mode 100644 index 0000000000..96fb6788b5 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter5/images/Ernest_Hemingway@4x.png diff --git a/examples/quickcontrols2/chattutorial/chapter5/images/Hans_Gude.png b/examples/quickcontrols2/chattutorial/chapter5/images/Hans_Gude.png Binary files differnew file mode 100644 index 0000000000..907e38bc61 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter5/images/Hans_Gude.png diff --git a/examples/quickcontrols2/chattutorial/chapter5/images/Hans_Gude@2x.png b/examples/quickcontrols2/chattutorial/chapter5/images/Hans_Gude@2x.png Binary files differnew file mode 100644 index 0000000000..6837796a83 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter5/images/Hans_Gude@2x.png diff --git a/examples/quickcontrols2/chattutorial/chapter5/images/Hans_Gude@3x.png b/examples/quickcontrols2/chattutorial/chapter5/images/Hans_Gude@3x.png Binary files differnew file mode 100644 index 0000000000..29af422ad3 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter5/images/Hans_Gude@3x.png diff --git a/examples/quickcontrols2/chattutorial/chapter5/images/Hans_Gude@4x.png b/examples/quickcontrols2/chattutorial/chapter5/images/Hans_Gude@4x.png Binary files differnew file mode 100644 index 0000000000..bc35eeaa79 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter5/images/Hans_Gude@4x.png diff --git a/examples/quickcontrols2/chattutorial/chapter5/images/images.qrc b/examples/quickcontrols2/chattutorial/chapter5/images/images.qrc new file mode 100644 index 0000000000..9eda6aa29c --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter5/images/images.qrc @@ -0,0 +1,16 @@ +<RCC> + <qresource prefix="/"> + <file>Albert_Einstein.png</file> + <file>Albert_Einstein@2x.png</file> + <file>Albert_Einstein@3x.png</file> + <file>Albert_Einstein@4x.png</file> + <file>Ernest_Hemingway.png</file> + <file>Ernest_Hemingway@2x.png</file> + <file>Ernest_Hemingway@3x.png</file> + <file>Ernest_Hemingway@4x.png</file> + <file>Hans_Gude.png</file> + <file>Hans_Gude@2x.png</file> + <file>Hans_Gude@3x.png</file> + <file>Hans_Gude@4x.png</file> + </qresource> +</RCC> diff --git a/examples/quickcontrols2/chattutorial/chapter4-models/main.cpp b/examples/quickcontrols2/chattutorial/chapter5/main.cpp index bbe7b3ad66..74e66106d4 100644 --- a/examples/quickcontrols2/chattutorial/chapter4-models/main.cpp +++ b/examples/quickcontrols2/chattutorial/chapter5/main.cpp @@ -90,7 +90,7 @@ int main(int argc, char *argv[]) connectToDatabase(); QQmlApplicationEngine engine; - engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + engine.load(QUrl(QStringLiteral("qrc:/chapter5/main.qml"))); if (engine.rootObjects().isEmpty()) return -1; diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/main.qml b/examples/quickcontrols2/chattutorial/chapter5/main.qml index 029f45e3c8..029f45e3c8 100644 --- a/examples/quickcontrols2/chattutorial/chapter5-styling/main.qml +++ b/examples/quickcontrols2/chattutorial/chapter5/main.qml diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/qtquickcontrols2.conf b/examples/quickcontrols2/chattutorial/chapter5/qtquickcontrols2.conf index e338c80432..c8a8eeeb05 100644 --- a/examples/quickcontrols2/chattutorial/chapter5-styling/qtquickcontrols2.conf +++ b/examples/quickcontrols2/chattutorial/chapter5/qtquickcontrols2.conf @@ -1,4 +1,7 @@ -[material] +[Controls] +Style=Basic + +[Material] Primary=Indigo Accent=Indigo Theme=Dark diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/sqlcontactmodel.cpp b/examples/quickcontrols2/chattutorial/chapter5/sqlcontactmodel.cpp index 6203ebec1e..6203ebec1e 100644 --- a/examples/quickcontrols2/chattutorial/chapter5-styling/sqlcontactmodel.cpp +++ b/examples/quickcontrols2/chattutorial/chapter5/sqlcontactmodel.cpp diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/sqlcontactmodel.h b/examples/quickcontrols2/chattutorial/chapter5/sqlcontactmodel.h index fdbe5f1e70..5953c76258 100644 --- a/examples/quickcontrols2/chattutorial/chapter5-styling/sqlcontactmodel.h +++ b/examples/quickcontrols2/chattutorial/chapter5/sqlcontactmodel.h @@ -56,7 +56,7 @@ class SqlContactModel : public QSqlQueryModel { public: - SqlContactModel(QObject *parent = 0); + SqlContactModel(QObject *parent = nullptr); }; #endif // SQLCONTACTMODEL_H diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/sqlconversationmodel.cpp b/examples/quickcontrols2/chattutorial/chapter5/sqlconversationmodel.cpp index 99526e81d3..99526e81d3 100644 --- a/examples/quickcontrols2/chattutorial/chapter5-styling/sqlconversationmodel.cpp +++ b/examples/quickcontrols2/chattutorial/chapter5/sqlconversationmodel.cpp diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/sqlconversationmodel.h b/examples/quickcontrols2/chattutorial/chapter5/sqlconversationmodel.h index 14ab12e262..9c65d64a84 100644 --- a/examples/quickcontrols2/chattutorial/chapter5-styling/sqlconversationmodel.h +++ b/examples/quickcontrols2/chattutorial/chapter5/sqlconversationmodel.h @@ -59,7 +59,7 @@ class SqlConversationModel : public QSqlTableModel Q_PROPERTY(QString recipient READ recipient WRITE setRecipient NOTIFY recipientChanged) public: - SqlConversationModel(QObject *parent = 0); + SqlConversationModel(QObject *parent = nullptr); QString recipient() const; void setRecipient(const QString &recipient); diff --git a/examples/quickcontrols2/chattutorial/chattutorial.pro b/examples/quickcontrols2/chattutorial/chattutorial.pro index 2f38254ed8..1c70b2653e 100644 --- a/examples/quickcontrols2/chattutorial/chattutorial.pro +++ b/examples/quickcontrols2/chattutorial/chattutorial.pro @@ -1,8 +1,8 @@ TEMPLATE = subdirs SUBDIRS += \ - chapter1-settingup \ - chapter2-lists \ - chapter3-navigation \ - chapter4-models \ - chapter5-styling + chapter1 \ + chapter2 \ + chapter3 \ + chapter4 \ + chapter5 diff --git a/examples/quickcontrols2/chattutorial/doc/src/qtquickcontrols2-chattutorial.qdoc b/examples/quickcontrols2/chattutorial/doc/src/qtquickcontrols2-chattutorial.qdoc index a56a470379..e457a414b1 100644 --- a/examples/quickcontrols2/chattutorial/doc/src/qtquickcontrols2-chattutorial.qdoc +++ b/examples/quickcontrols2/chattutorial/doc/src/qtquickcontrols2-chattutorial.qdoc @@ -52,14 +52,14 @@ basic "Hello World" application with the following files: \li \c chattutorial.pro - Provides the qmake configuration \endlist -\note Delete the \c MainForm.ui.qml from the project as we will -not use it in this tutorial. +\note Delete the \c MainForm.ui.qml and \c qml.qrc files from the project, as +we will not use them in this tutorial. \section2 main.cpp The default code in \c main.cpp has two includes: -\quotefromfile chattutorial/chapter1-settingup/main.cpp +\quotefromfile chattutorial/chapter1/main.cpp \skipto include \printline include \printline include @@ -96,7 +96,7 @@ Once we've set up things in C++, we can move on to the user interface in QML. Let's modify the default QML code to suit our needs. -\quotefromfile chattutorial/chapter1-settingup/main.qml +\quotefromfile chattutorial/chapter1/main.qml \skipto import \printuntil import QtQuick.Controls @@ -145,7 +145,7 @@ which screen the user is viewing, it is much easier to use \l Page. For now, we'll just add one page, but in the next chapter, we'll demonstrate how to navigate between several pages. -\quotefromfile chattutorial/chapter1-settingup/main.qml +\quotefromfile chattutorial/chapter1/main.qml \skipto Page \printuntil } \printuntil } @@ -183,7 +183,7 @@ The \c .pro or \l {Creating Project Files}{project} file contains all of the information needed by \l {qmake Manual}{qmake} to generate a Makefile, which is then used to compile and link the application. -\quotefromfile chattutorial/chapter1-settingup/chapter1-settingup.pro +\quotefromfile chattutorial/chapter1/chapter1.pro \printline TEMPLATE The first line tells \c qmake which kind of project this is. We're building an @@ -203,7 +203,7 @@ project. The \c SOURCES variable lists all of the source files that should be compiled. A similar variable, \c HEADERS, is available for header files. -\printline RESOURCES +\printuntil qtquickcontrols2 The next line tells \c qmake that we have a collection of \l {The Qt Resource System}{resources} that should be built into the @@ -234,7 +234,7 @@ can display text, be checked on and off, and react to mouse clicks. Here is our ListView: -\quotefromfile chattutorial/chapter2-lists/main.qml +\quotefromfile chattutorial/chapter2/main.qml \dots 8 \codeline \skipto ListView @@ -303,7 +303,7 @@ vertical space. In this chapter, you'll learn how to use \l StackView to navigate between pages in an application. Here's the revised \c main.qml: -\quotefromfile chattutorial/chapter3-navigation/main.qml +\quotefromfile chattutorial/chapter3/main.qml \skipto import \printuntil } \printuntil } @@ -362,7 +362,7 @@ application-wide and context-sensitive actions and controls, such as navigation buttons and search fields. Best of all, it has a background color that, as usual, comes from the application style. Here it is in action: -\quotefromfile chattutorial/chapter3-navigation/ContactPage.qml +\quotefromfile chattutorial/chapter3/ContactPage.qml \skipto header \printuntil } \printuntil } @@ -389,7 +389,7 @@ name, which it then uses to display the relevant conversation. Note the Let's step through \c ConversationPage.qml, beginning with the imports: -\quotefromfile chattutorial/chapter3-navigation/ConversationPage.qml +\quotefromfile chattutorial/chapter3/ConversationPage.qml \skipto import \printline import \printline import @@ -459,7 +459,7 @@ accommodating the Pane. Let's look at the listview in detail: -\quotefromfile chattutorial/chapter3-navigation/ConversationPage.qml +\quotefromfile chattutorial/chapter3/ConversationPage.qml \skipto ListView \printuntil ScrollBar \printuntil } @@ -539,13 +539,13 @@ purpose, as it provides a read-only data model for SQL result sets. Let's take a look at our \c SqlContactModel class that derives from QSqlQueryModel: -\quotefromfile chattutorial/chapter4-models/sqlcontactmodel.h +\quotefromfile chattutorial/chapter4/sqlcontactmodel.h \skipto #include \printuntil }; There's not much going on here, so let's move on to the \c .cpp file: -\quotefromfile chattutorial/chapter4-models/sqlcontactmodel.cpp +\quotefromfile chattutorial/chapter4/sqlcontactmodel.cpp \skipto #include \printuntil } \printuntil } @@ -572,7 +572,7 @@ all rows of the \c Contacts table. \c SqlConversationModel is more complex: -\quotefromfile chattutorial/chapter4-models/sqlconversationmodel.h +\quotefromfile chattutorial/chapter4/sqlconversationmodel.h \skipto #include \printuntil }; @@ -592,7 +592,7 @@ QML, hence the \c Q_INVOKABLE macro. Let's take a look at the \c .cpp file: -\quotefromfile chattutorial/chapter4-models/sqlconversationmodel.cpp +\quotefromfile chattutorial/chapter4/sqlconversationmodel.cpp \skipto #include \printuntil } \printuntil } @@ -649,7 +649,7 @@ of \l QSqlTableModel::OnManualSubmit, we must manually call Now that we've established the model classes, let's take a look at \c main.cpp: -\quotefromfile chattutorial/chapter4-models/main.cpp +\quotefromfile chattutorial/chapter4/main.cpp \skipto #include \printuntil return app.exec(); \printuntil } @@ -666,7 +666,7 @@ Now that we have the models available as QML types, there are some minor changes to be done to \c ContactPage.qml. To be able to use the types, we must first import them using the URI we set in \c main.cpp: -\quotefromfile chattutorial/chapter4-models/ContactPage.qml +\quotefromfile chattutorial/chapter4/ContactPage.qml \skipto import io.qt.examples.chattutorial \printline import io.qt.examples.chattutorial @@ -683,7 +683,7 @@ Within the delegate, we use a different syntax for accessing the model data: In \c ConversationPage.qml, we add the same \c chattutorial import, and replace the dummy model: -\quotefromfile chattutorial/chapter4-models/ConversationPage.qml +\quotefromfile chattutorial/chapter4/ConversationPage.qml \skipto model: SqlConversationModel { \printuntil } @@ -792,7 +792,7 @@ means that it will be used when the \l {Basic Style}{Basic style} (which is the style that is used when none is specified) is in use. Here's the new file: -\quotefromfile chattutorial/chapter5-styling/ChatToolBar.qml +\quotefromfile chattutorial/chapter5/ChatToolBar.qml \skipto import \printuntil } @@ -803,7 +803,7 @@ of the file, nothing needs to be different. Back in \c ContactPage.qml, we update the code to use the new type: -\quotefromfile chattutorial/chapter5-styling/ContactPage.qml +\quotefromfile chattutorial/chapter5/ContactPage.qml \skipto ToolBar \printuntil } \printuntil } @@ -817,13 +817,13 @@ that the selection feature is not accidentally triggered. Here's \c +Material/ChatToolBar.qml: -\quotefromfile chattutorial/chapter5-styling/+Material/ChatToolBar.qml +\quotefromfile chattutorial/chapter5/+Material/ChatToolBar.qml \skipto import \printuntil } We'll make the same changes to \c ConversationPage.qml: -\quotefromfile chattutorial/chapter5-styling/ConversationPage.qml +\quotefromfile chattutorial/chapter5/ConversationPage.qml \skipto header: ChatToolBar \printuntil } \printuntil } diff --git a/examples/quickcontrols2/flatstyle/flatstyle.qmlproject b/examples/quickcontrols2/flatstyle/flatstyle.qmlproject new file mode 100644 index 0000000000..80b42820ad --- /dev/null +++ b/examples/quickcontrols2/flatstyle/flatstyle.qmlproject @@ -0,0 +1,45 @@ +import QmlProject + +Project { + mainFile: "flatstyle.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + + JavaScriptFiles { + directory: "." + } + + ImageFiles { + directory: "." + } + + Files { + filter: "*.conf" + files: ["qtquickcontrols2.conf"] + } + + Files { + filter: "qmldir" + directory: "." + } + + Files { + filter: "*.ttf;*.otf" + } + + Environment { + QT_QUICK_CONTROLS_CONF: "qtquickcontrols2.conf" + QT_AUTO_SCREEN_SCALE_FACTOR: "1" + } + + qt6Project: true + + /* List of plugin directories passed to QML runtime */ + importPaths: [ ".", "imports" ] + + /* Required for deployment */ + targetDirectory: "/opt/flatstyle" +} diff --git a/examples/quickcontrols2/texteditor/CMakeLists.txt b/examples/quickcontrols2/texteditor/CMakeLists.txt index 187d1a88b4..6c3de0891f 100644 --- a/examples/quickcontrols2/texteditor/CMakeLists.txt +++ b/examples/quickcontrols2/texteditor/CMakeLists.txt @@ -37,7 +37,6 @@ set(texteditor_resource_files "images/qt-logo.png" "qml/+touch/texteditor.qml" "qml/texteditor.qml" - "qtquickcontrols2.conf" "texteditor.html" ) diff --git a/examples/quickcontrols2/texteditor/documenthandler.cpp b/examples/quickcontrols2/texteditor/documenthandler.cpp index d904e6f637..b266bc5694 100644 --- a/examples/quickcontrols2/texteditor/documenthandler.cpp +++ b/examples/quickcontrols2/texteditor/documenthandler.cpp @@ -323,4 +323,73 @@ void DocumentHandler::setFont(const QFont & font){ emit fontChanged(); } +bool DocumentHandler::bold() const +{ + const QTextCursor cursor = textCursor(); + if (cursor.isNull()) + return m_document->textDocument()->defaultFont().bold(); + return cursor.charFormat().font().bold(); +} + +void DocumentHandler::setBold(bool bold) +{ + const QTextCursor cursor = textCursor(); + if (!cursor.isNull() && cursor.charFormat().font().bold() == bold) + return; + + QFont font = cursor.charFormat().font(); + font.setBold(bold); + QTextCharFormat format; + format.setFont(font); + mergeFormatOnWordOrSelection(format); + + emit boldChanged(); +} + +bool DocumentHandler::underline() const +{ + const QTextCursor cursor = textCursor(); + if (cursor.isNull()) + return m_document->textDocument()->defaultFont().underline(); + return cursor.charFormat().font().underline(); +} + +void DocumentHandler::setUnderline(bool underline) +{ + const QTextCursor cursor = textCursor(); + if (!cursor.isNull() && cursor.charFormat().font().underline() == underline) + return; + + QFont font = cursor.charFormat().font(); + font.setUnderline(underline); + QTextCharFormat format; + format.setFont(font); + mergeFormatOnWordOrSelection(format); + + emit underlineChanged(); +} + +bool DocumentHandler::italic() const +{ + const QTextCursor cursor = textCursor(); + if (cursor.isNull()) + return m_document->textDocument()->defaultFont().italic(); + return cursor.charFormat().font().italic(); +} + +void DocumentHandler::setItalic(bool italic) +{ + const QTextCursor cursor = textCursor(); + if (!cursor.isNull() && cursor.charFormat().font().italic() == italic) + return; + + QFont font = cursor.charFormat().font(); + font.setItalic(italic); + QTextCharFormat format; + format.setFont(font); + mergeFormatOnWordOrSelection(format); + + emit italicChanged(); +} + #include "moc_documenthandler.cpp" diff --git a/examples/quickcontrols2/texteditor/documenthandler.h b/examples/quickcontrols2/texteditor/documenthandler.h index 66b5957a20..aa3f257558 100644 --- a/examples/quickcontrols2/texteditor/documenthandler.h +++ b/examples/quickcontrols2/texteditor/documenthandler.h @@ -75,6 +75,10 @@ class DocumentHandler : public QObject Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged) + Q_PROPERTY(bool bold READ bold WRITE setBold NOTIFY boldChanged) + Q_PROPERTY(bool underline READ underline WRITE setUnderline NOTIFY underlineChanged) + Q_PROPERTY(bool italic READ italic WRITE setItalic NOTIFY italicChanged) + Q_PROPERTY(QString fileName READ fileName NOTIFY fileUrlChanged) Q_PROPERTY(QString fileType READ fileType NOTIFY fileUrlChanged) Q_PROPERTY(QUrl fileUrl READ fileUrl NOTIFY fileUrlChanged) @@ -105,6 +109,15 @@ public: QFont font() const; void setFont(const QFont & font); + bool bold() const; + void setBold(bool bold); + + bool underline() const; + void setUnderline(bool underline); + + bool italic() const; + void setItalic(bool italic); + QString fileName() const; QString fileType() const; QUrl fileUrl() const; @@ -123,6 +136,9 @@ Q_SIGNALS: void selectionEndChanged(); void fontChanged(); + void boldChanged(); + void underlineChanged(); + void italicChanged(); void textColorChanged(); void alignmentChanged(); diff --git a/examples/quickcontrols2/texteditor/qml/+touch/texteditor.qml b/examples/quickcontrols2/texteditor/qml/+touch/texteditor.qml index 7d7554f44b..677d25fbd9 100644 --- a/examples/quickcontrols2/texteditor/qml/+touch/texteditor.qml +++ b/examples/quickcontrols2/texteditor/qml/+touch/texteditor.qml @@ -149,9 +149,6 @@ ApplicationWindow { footer: ToolBar { visible: !textArea.readOnly && textArea.activeFocus - Material.primary: "#E0E0E0" - Material.elevation: 0 - Flickable { anchors.fill: parent contentWidth: toolRow.implicitWidth diff --git a/examples/quickcontrols2/texteditor/qtquickcontrols2.conf b/examples/quickcontrols2/texteditor/qtquickcontrols2.conf deleted file mode 100644 index ecac617fcb..0000000000 --- a/examples/quickcontrols2/texteditor/qtquickcontrols2.conf +++ /dev/null @@ -1,11 +0,0 @@ -[Controls] -Style=Material - -[Material] -Primary=White -Foreground=#444444 -Accent=Blue -Theme=System - -[Universal] -Theme=System diff --git a/examples/quickcontrols2/texteditor/texteditor.cpp b/examples/quickcontrols2/texteditor/texteditor.cpp index 9b882dc803..72148c72ea 100644 --- a/examples/quickcontrols2/texteditor/texteditor.cpp +++ b/examples/quickcontrols2/texteditor/texteditor.cpp @@ -57,7 +57,6 @@ #include <QDebug> #include <QQmlApplicationEngine> #include <QQmlContext> -#include <QQmlFileSelector> #include <QQuickStyle> #include "documenthandler.h" @@ -87,7 +86,7 @@ int main(int argc, char *argv[]) #endif QQmlApplicationEngine engine; - QQmlFileSelector::get(&engine)->setExtraSelectors(selectors); + engine.setExtraFileSelectors(selectors); engine.load(QUrl("qrc:/qml/texteditor.qml")); if (engine.rootObjects().isEmpty()) diff --git a/examples/quickcontrols2/texteditor/texteditor.qrc b/examples/quickcontrols2/texteditor/texteditor.qrc index 8f2da8432b..cdb7225a39 100644 --- a/examples/quickcontrols2/texteditor/texteditor.qrc +++ b/examples/quickcontrols2/texteditor/texteditor.qrc @@ -1,6 +1,5 @@ <RCC> <qresource prefix="/"> - <file>qtquickcontrols2.conf</file> <file>images/qt-logo.png</file> <file>fonts/fontello.ttf</file> <file>qml/texteditor.qml</file> |