diff --git a/doc/qtcreator/images/qtquick-qml-export-dialog.png b/doc/qtcreator/images/qtquick-qml-export-dialog.png new file mode 100644 index 00000000000..d06a01e5b97 Binary files /dev/null and b/doc/qtcreator/images/qtquick-qml-export-dialog.png differ diff --git a/doc/qtcreator/src/mcu/creator-mcu-dev.qdoc b/doc/qtcreator/src/mcu/creator-mcu-dev.qdoc index 3673f97b195..f86ce3c3194 100644 --- a/doc/qtcreator/src/mcu/creator-mcu-dev.qdoc +++ b/doc/qtcreator/src/mcu/creator-mcu-dev.qdoc @@ -101,6 +101,7 @@ \li The \uicontrol {GNU ARM Embedded Toolchain} path. \li The \uicontrol {STM32CubeProgrammer} install path. \li The \uicontrol {MCU SDK} for the chosen target. + \li The \uicontrol {FreeRTOS Sources} for the chosen target. \endlist \li For NXP targets: \list diff --git a/doc/qtcreator/src/qtcreator-toc.qdoc b/doc/qtcreator/src/qtcreator-toc.qdoc index 8b3f1efa241..debfa4cda10 100644 --- a/doc/qtcreator/src/qtcreator-toc.qdoc +++ b/doc/qtcreator/src/qtcreator-toc.qdoc @@ -148,6 +148,7 @@ \li \l {Browsing ISO 7000 Icons} \li \l {Using QML Modules with Plugins} \li \l {Converting UI Projects to Applications} + \li \l {Exporting QML} \endlist \li \l{Developing Widget Based Applications} \list diff --git a/doc/qtcreator/src/qtquick/creator-only/qtquick-app-development.qdoc b/doc/qtcreator/src/qtquick/creator-only/qtquick-app-development.qdoc index 30e78fe38a2..9230f3a3dde 100644 --- a/doc/qtcreator/src/qtquick/creator-only/qtquick-app-development.qdoc +++ b/doc/qtcreator/src/qtquick/creator-only/qtquick-app-development.qdoc @@ -96,6 +96,11 @@ convert them to Qt Quick Application projects that contain .pro, .cpp, and .qrc files. + \li \l {Exporting QML} + + \l{Qt Quick UI Forms}{UI forms} (ui.qml files) can be exported to + JSON metadata format and PNG assets. + \endlist */ diff --git a/doc/qtcreator/src/qtquick/creator-only/qtquick-export.qdoc b/doc/qtcreator/src/qtquick/creator-only/qtquick-export.qdoc new file mode 100644 index 00000000000..db641f080fa --- /dev/null +++ b/doc/qtcreator/src/qtquick/creator-only/qtquick-export.qdoc @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Creator documentation. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** +****************************************************************************/ + +/*! + \page creator-exporting-qml.html + \previouspage quick-converting-ui-projects.html + \nextpage creator-using-qt-designer.html + + \title Exporting QML + + \l{Qt Quick UI Forms}{UI forms} (ui.qml files) can be exported to + JSON metadata format and PNG assets. + + To export the \l{Qt Quick UI Forms}{UI forms} (ui.qml files) from the + current project, select \uicontrol Build > \uicontrol {Export QML}. + + The primary use of exported metadata and assets is to generate native file + formats in content creation tools, such as Adobe Photoshop, using \QB. \QBPS + can generate PSD files by importing the metadata and assets. + + QML is exported as follows: + + \list + \li QML types inherited from \l [QML]{Item}{Item} are exported, other + types are ignored. + \li \l [QML]{Text}{Text} components are exported as metadata only + and no assets are generated. + \li \l [QML]{Rectangle}{Rectangle} and \l [QML]{Image}{Image} types + generate assets as PNG files. + \endlist + + \section1 Configuring QML Export + + You can configure the export in the \uicontrol {Export QML} dialog, which + lists the \l{Qt Quick UI Forms}{UI forms} (ui.qml files) of the current + project. + + \image qtquick-qml-export-dialog.png "QML Export Dialog" + + \list 1 + \li In the \uicontrol {Export path} field, specify the path where + the metadata file and assets are exported. + \li Deselect the \uicontrol {Export assets} check box to disable + exporting assets and only generate the metadata file. + \li In the file list, select the \l{Qt Quick UI Forms}{UI forms} + to be exported. + \li Select \uicontrol {Export} export to start the export process. + \endlist +*/ diff --git a/doc/qtcreator/src/qtquick/qtquick-from-qmlproject-to-pro.qdoc b/doc/qtcreator/src/qtquick/qtquick-from-qmlproject-to-pro.qdoc index 00e4bb74e8e..31849550331 100644 --- a/doc/qtcreator/src/qtquick/qtquick-from-qmlproject-to-pro.qdoc +++ b/doc/qtcreator/src/qtquick/qtquick-from-qmlproject-to-pro.qdoc @@ -26,11 +26,11 @@ /*! \page quick-converting-ui-projects.html \if defined(qtdesignstudio) - \previouspage studio-importing-designs.html + \previouspage studio-importing-3d.html \nextpage quick-uis.html \else \previouspage creator-qml-modules-with-plugins.html - \nextpage creator-using-qt-designer.html + \nextpage creator-exporting-qml.html \endif \title Converting UI Projects to Applications diff --git a/doc/qtcreator/src/widgets/qtdesigner-overview.qdoc b/doc/qtcreator/src/widgets/qtdesigner-overview.qdoc index 915765c2b0d..e2342dbe416 100644 --- a/doc/qtcreator/src/widgets/qtdesigner-overview.qdoc +++ b/doc/qtcreator/src/widgets/qtdesigner-overview.qdoc @@ -30,7 +30,7 @@ // ********************************************************************** /*! - \previouspage quick-converting-ui-projects.html + \previouspage creator-exporting-qml.html \page creator-using-qt-designer.html \nextpage adding-plugins.html diff --git a/doc/qtdesignstudio/config/style/qt5-sidebar.html b/doc/qtdesignstudio/config/style/qt5-sidebar.html index cc4f709bc3a..8a33d73402c 100644 --- a/doc/qtdesignstudio/config/style/qt5-sidebar.html +++ b/doc/qtdesignstudio/config/style/qt5-sidebar.html @@ -8,7 +8,7 @@
  • Getting Started
  • Managing Projects
  • Creating UIs
  • -
  • Adding Dynamics
  • +
  • Adding Dynamics
  • Editing 3D Scenes
  • Previewing
  • Advanced Topics
  • diff --git a/doc/qtdesignstudio/images/material-aluminum-anodized-emissive.png b/doc/qtdesignstudio/images/material-aluminum-anodized-emissive.png new file mode 100644 index 00000000000..bc9818aed4e Binary files /dev/null and b/doc/qtdesignstudio/images/material-aluminum-anodized-emissive.png differ diff --git a/doc/qtdesignstudio/images/material-aluminum-anodized.png b/doc/qtdesignstudio/images/material-aluminum-anodized.png new file mode 100644 index 00000000000..aa45c477f12 Binary files /dev/null and b/doc/qtdesignstudio/images/material-aluminum-anodized.png differ diff --git a/doc/qtdesignstudio/images/material-aluminum-brushed.png b/doc/qtdesignstudio/images/material-aluminum-brushed.png new file mode 100644 index 00000000000..9be6229b05d Binary files /dev/null and b/doc/qtdesignstudio/images/material-aluminum-brushed.png differ diff --git a/doc/qtdesignstudio/images/material-aluminum-emissive.png b/doc/qtdesignstudio/images/material-aluminum-emissive.png new file mode 100644 index 00000000000..18917da4297 Binary files /dev/null and b/doc/qtdesignstudio/images/material-aluminum-emissive.png differ diff --git a/doc/qtdesignstudio/images/material-aluminum.png b/doc/qtdesignstudio/images/material-aluminum.png new file mode 100644 index 00000000000..18917da4297 Binary files /dev/null and b/doc/qtdesignstudio/images/material-aluminum.png differ diff --git a/doc/qtdesignstudio/images/material-artistic-paper.png b/doc/qtdesignstudio/images/material-artistic-paper.png new file mode 100644 index 00000000000..0c381dd9f1e Binary files /dev/null and b/doc/qtdesignstudio/images/material-artistic-paper.png differ diff --git a/doc/qtdesignstudio/images/material-copper.png b/doc/qtdesignstudio/images/material-copper.png new file mode 100644 index 00000000000..ca6aed276b8 Binary files /dev/null and b/doc/qtdesignstudio/images/material-copper.png differ diff --git a/doc/qtdesignstudio/images/material-frosted-glass-single-pass.png b/doc/qtdesignstudio/images/material-frosted-glass-single-pass.png new file mode 100644 index 00000000000..2aab9bf0448 Binary files /dev/null and b/doc/qtdesignstudio/images/material-frosted-glass-single-pass.png differ diff --git a/doc/qtdesignstudio/images/material-frosted-glass.png b/doc/qtdesignstudio/images/material-frosted-glass.png new file mode 100644 index 00000000000..8de910ea81e Binary files /dev/null and b/doc/qtdesignstudio/images/material-frosted-glass.png differ diff --git a/doc/qtdesignstudio/images/material-glass.png b/doc/qtdesignstudio/images/material-glass.png new file mode 100644 index 00000000000..d35e4352b2f Binary files /dev/null and b/doc/qtdesignstudio/images/material-glass.png differ diff --git a/doc/qtdesignstudio/images/material-office-paper.png b/doc/qtdesignstudio/images/material-office-paper.png new file mode 100644 index 00000000000..506c5c1b51f Binary files /dev/null and b/doc/qtdesignstudio/images/material-office-paper.png differ diff --git a/doc/qtdesignstudio/images/material-red-plastic-structured-emissive.png b/doc/qtdesignstudio/images/material-red-plastic-structured-emissive.png new file mode 100644 index 00000000000..d6e18ebadf2 Binary files /dev/null and b/doc/qtdesignstudio/images/material-red-plastic-structured-emissive.png differ diff --git a/doc/qtdesignstudio/images/material-red-plastic-structured.png b/doc/qtdesignstudio/images/material-red-plastic-structured.png new file mode 100644 index 00000000000..c1d58332d81 Binary files /dev/null and b/doc/qtdesignstudio/images/material-red-plastic-structured.png differ diff --git a/doc/qtdesignstudio/images/material-refractive-glass.png b/doc/qtdesignstudio/images/material-refractive-glass.png new file mode 100644 index 00000000000..b0c1f6330ab Binary files /dev/null and b/doc/qtdesignstudio/images/material-refractive-glass.png differ diff --git a/doc/qtdesignstudio/images/material-steel-milled-concentric.png b/doc/qtdesignstudio/images/material-steel-milled-concentric.png new file mode 100644 index 00000000000..25b67dc6bf8 Binary files /dev/null and b/doc/qtdesignstudio/images/material-steel-milled-concentric.png differ diff --git a/doc/qtdesignstudio/images/studio-custom-material-uniform-properties.png b/doc/qtdesignstudio/images/studio-custom-material-uniform-properties.png new file mode 100644 index 00000000000..b69d4561829 Binary files /dev/null and b/doc/qtdesignstudio/images/studio-custom-material-uniform-properties.png differ diff --git a/doc/qtdesignstudio/src/qtdesignstudio-toc.qdoc b/doc/qtdesignstudio/src/qtdesignstudio-toc.qdoc index 4a0edda2efd..6a32c95123e 100644 --- a/doc/qtdesignstudio/src/qtdesignstudio-toc.qdoc +++ b/doc/qtdesignstudio/src/qtdesignstudio-toc.qdoc @@ -107,6 +107,7 @@ \li \l{Adding Models} \li \l{Using Materials and Shaders} \li \l{Attaching Textures to Materials} + \li \l{Using 3D Materials} \li \l{Applying 3D Effects} \li \l{Using Custom Shaders} \li \l{Creating Custom Effects and Materials} diff --git a/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-custom-effects-materials.qdoc b/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-custom-effects-materials.qdoc index b5d03d9fb90..7d98babad7f 100644 --- a/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-custom-effects-materials.qdoc +++ b/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-custom-effects-materials.qdoc @@ -32,16 +32,27 @@ \title Creating Custom Effects and Materials + The \l{Applying 3D Effects}{Qt Quick 3D Effects} and \l{Using 3D Materials} + {Qt Quick 3D Materials} modules contain a set of ready-made effects and + materials that you can apply to 3D models. If the ready-made effects and + materials don't meet your needs, you can create custom effects and + materials. Each effect or material must have a fragment shader that + implements all the functions needed to calculate the shaded color. The + material system also offers ready-made functions to help you implement + the material. + + The material system supports dielectric, metallic, and transparent + materials, point lights, area lights, ambient occlusion, shadowing, + two-sided polygons, index-of-refraction, and fragment cutoff (masking). + For more information, see \l {Qt Quick 3D Custom Material Reference}. + You can use the QML types in the \uicontrol {Qt Quick 3D Custom Shader Utils} tab of \uicontrol Library to create custom effects and materials. To make the \uicontrol Effect and \uicontrol {Custom Material} types appear in the tab, you must select \uicontrol {Add Import} in the \uicontrol {QML Imports} tab, and then select \uicontrol QtQuick3D.Effects and - \uicontrol QtQuick3D.Materials to import the QML types in the - \l{Qt Quick 3D Effects QML Types}{Qt Quick 3D Effects} and - \l{Qt Quick 3D Materials QML Types}{Qt Quick 3D Materials} modules to your - project. These modules contain a set of ready-made effects and materials - that you can apply to 3D models. + \uicontrol QtQuick3D.Materials to import the QML types in those modules to + your project. For more information about the shader utilities and commands and their properties, see \l {Using Custom Shaders}. @@ -50,7 +61,10 @@ \note You must create the actual shader source files with some other tool and copy them to your project folder. You can then specify the source file - names in the custom effect or material properties. + names in the custom effect or material properties. To use custom \e uniforms + in the shader files, you must specify them as QML properties for the custom + effect or material component. \QDS automatically generates the uniforms for + the shaders based on the property values. \section1 Creating Custom Effects @@ -160,4 +174,42 @@ \uicontrol Properties. \image studio-qtquick-3d-shader-properties.png "Shader properties" \endlist + + \section1 Creating Shader Files + + The requirements set for shaders that you can use in custom effects and + materials are described in \l {Qt Quick 3D Custom Material Reference}. + + If you use custom uniforms in the shader files, you must specify them + as QML properties for the custom effect or material component. \QDS + automatically generates the uniforms based on the property values. + + For example, the following code snippet shows fragment shader code that + uses two uniforms: \c uTextureInUse and \c uInputTexture. + + \code + out vec4 fragColor; + + in vec3 pos; + in vec3 texCoord0; + + void main() { + + vec4 textCol; + if (uTextureInUse) + textCol = texture( uInputTexture, texCoord0.xy ); + + fragColor = vec4(pos.x * 0.02 * textCol.x, pos.y * 0.02 * textCol.y, pos.z * 0.02, 1.0); + } + \endcode + + To use the above fragment shader in a custom effect or material component, + you must remove the uniforms from the shader code and define them as + properties for the component in \uicontrol {Connection View} > + \uicontrol Properties. + + \image studio-custom-material-uniform-properties.png "Uniforms as properties in Connection View Properties tab" + + For more information about adding properties, see + \l{Specifying Dynamic Properties}. */ diff --git a/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-editor.qdoc b/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-editor.qdoc index cc42cbc1005..e89783168b4 100644 --- a/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-editor.qdoc +++ b/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-editor.qdoc @@ -30,8 +30,8 @@ \title Working in 3D Editor - When editing a 3D scene, you view the scene in \uicontrol {3D Editor} by - using the \uicontrol {3D Editor} camera. You can switch between + When editing a 3D scene, you view the scene in the \uicontrol {3D Editor} + view. You can change the projection of the view by switching between \e {perspective camera} and \e {orthographic camera} modes. When using the perspective camera mode, objects that are far from the camera appear smaller than those nearby. In the orthographic camera mode, all objects appear at @@ -61,7 +61,8 @@ Additional helpful features when editing 3D scenes are the \e {edit light}, which is a quick way to light the scene, and the grid that helps you to navigate in 3D space. Select the \inlineimage grid_on.png - (\uicontrol {Toggle Grid Visibility}) to show or hide the grid. + (\uicontrol {Toggle Grid Visibility}) or press \key G to show or hide the + grid. \image studio-3d-editor.png "3D Editor" @@ -78,10 +79,10 @@ camera: \list - \li To pan, press \key Alt and use the middle mouse button to click - anywhere in the rendered view to slide the view around. - \li To orbit, press \key Alt and click anywhere in the rendered view to - rotate the view. + \li To pan, press \key Alt and use the middle mouse button to click and + drag anywhere in the rendered view to slide the view around. + \li To orbit, press \key Alt and click and drag anywhere in the rendered + view to rotate the view. \li To zoom, use the mouse wheel or press \key Alt and right-click anywhere in the rendered view to zoom the view in or out as you drag up or down. @@ -91,11 +92,12 @@ select \inlineimage fit_selected.png (\uicontrol {Fit Selected}) or press \key F. - The world axis helper (1) shows the direction of the world axes in respect - to the 3D Editor camera. To point the camera at the currently selected - component in the direction of an axis, click the axis. If no component - is selected, the camera is pointed at the world origin. This does not - affect the camera zoom level. + The world axis helper (1) shows the direction of the world axes in view. + To point the camera at the currently selected component in the direction of + an axis, click the axis. Clicking the dot at the end of the axis will point + the camera at the opposite direction of the axis. If no component is + selected, the camera is pointed at the world origin. This does not affect + the camera zoom level. \image studio-3d-editor-axis-helper.png "Axis helper in 3D Editor" @@ -128,8 +130,8 @@ \section1 Using Edit Light - The edit light is an extra point light that follows the edit camera. - To switch the edit light on and off, select \inlineimage edit_light_on.png + The edit light is an extra point light that can be used to illuminate the + scene. To toggle the edit light on and off, select \inlineimage edit_light_on.png or \inlineimage edit_light_off.png (\uicontrol {Toggle Edit Light}) or press \key U. @@ -160,7 +162,7 @@ You can move items in relation to their coordinate system, along the x, y, or z axis or on the top, bottom, left, and right clip planes of the - \uicontrol {3D Editor} camera. + \uicontrol {3D Editor} view. To move items, select \inlineimage move_on.png or press \key W: @@ -170,8 +172,8 @@ drag the item along the axis. \li To move items on a plane, click the plane handle and drag the item on the plane. - \li To move an item freely in the editor, click the gray handle at the - center of the item. + \li To move an item freely in 3D editor, click and drag the gray handle + at the center of the move gizmo. \endlist \section1 Rotating Items @@ -182,9 +184,10 @@ or press \key E: \list - \li To rotate an item around its rotation gizmo, click the axis and + \li To rotate an item around its rotation gizmo, click the axis ring and drag in the direction you want to rotate the item in. - \li To freely rotate the item, select the gray circle. + \li To freely rotate the item, click and drag the inner center circle of + the gizmo. \endlist \section1 Scaling Items @@ -203,7 +206,7 @@ attached to the axis. \li To adjust the scale across a plane, click the plane handle and drag the item on the plane. - \li To uniformly scale an item across all axes, click and drag the + \li To uniformly scale an item across all axes, click and drag the gray handle at the center of the item. \endlist */ diff --git a/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-effects.qdoc b/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-effects.qdoc index a1839cca56a..77c15f700f2 100644 --- a/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-effects.qdoc +++ b/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-effects.qdoc @@ -27,7 +27,7 @@ /*! \page studio-3d-effects.html - \previouspage studio-3d-texture.html + \previouspage studio-3d-materials-types.html \nextpage studio-3d-custom-shaders.html \title Applying 3D Effects diff --git a/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-materials.qdoc b/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-materials.qdoc new file mode 100644 index 00000000000..7101135bfc7 --- /dev/null +++ b/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-materials.qdoc @@ -0,0 +1,399 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Design Studio. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page studio-3d-materials-types.html + \previouspage studio-3d-texture.html + \nextpage studio-3d-effects.html + + \title Using 3D Materials + + \QDS provides a set of pregenerated Qt Quick 3D materials that can be used + to create good-looking models quickly and easily. + + To apply a 3D material to a component, drag-and-drop a material from the + \uicontrol {Qt Quick 3D Materials} tab of \uicontrol Library to a model + component in \uicontrol Navigator. The materials you add to the model are + listed in the model component's \uicontrol Properties view. + + Each material has its own set of properties that can be used to further + define the appearance of the material. For each material the \uicontrol + {Environment Map} property specifies whether or not + \l{Selecting the Mapping Method}{environment mapping} is used for + specular reflection. Use the \uicontrol Texture property to select + a texture for the environment map. The \uicontrol {Shadow Map} property + determine whether or not shadow mapping is used for generating realistic + shadows. You can also select a \uicontrol Texture for shadow mapping. + + \section1 Metal Materials + + The following describes properties of the metal-based materials, which + include \uicontrol Aluminum, \uicontrol {Aluminum Anod Emis}, \uicontrol + {Aluminum Anodized}, \uicontrol {Aluminum Brushed}, \uicontrol + {Aluminum Emissive}, \uicontrol Copper, and \uicontrol + {Steel Milled Concentric}. + + \section2 Color + + Set the surface tint of the material by specifying the + \uicontrol {Metal Color} and \uicontrol {Base Color} properties. Use + the \uicontrol {Emission Color} property to set the color of the glow for + emissive materials. You can either use the color picker or specify an + RBG value. + + \section2 Reflection + + Use the properties under the \uicontrol Reflection tab to specify the + reflective qualities of the material. For more information on the various + material properties related to reflection, see \l {Using Highlights and + Reflections}. + + \list + \target tiling_metal + \li Use the \uicontrol {Map Offset} and \uicontrol {Map Scale} + properties to define offset and scale for the reflection map. You + can also define a texture for the reflection map by using the + \uicontrol Texture property, and set a the tiling repeat for it + by using the \uicontrol Tiling property. + \li To further define the reflective qualities of the material, + you can also set the \uicontrol Stretch and \uicontrol Texture + properties of \uicontrol Reflection, or define a numerical + value for \uicontrol Reflectivity. + \li Set the \uicontrol {Fresnel Power} property to decrease head-on + reflections (looking directly at the surface) while maintaining + reflections seen at grazing angles. + \endlist + + \section2 Roughness + Use the \uicontrol Roughness properties to determine how light behaves when + it comes in contact with material. With zero roughness, light bounces off a + material, which makes it appear glossy. Increased roughness causes the light + reflected off the material to scatter, which results in a matte appearance. + + \list + \li The \uicontrol {Map Offset} \uicontrol {Map Scale} and \uicontrol + Texture specify the quality of roughness applied to the material. + \li Use the numerical \uicontrol Roughness property to define how + glossy or matte the material appears. + \endlist + + \target emission_metal + \section2 Emission + Use the properties under the \uicontrol Emission tab to specify the + emissive qualities of the material. For more information on properties + related to emission, see \l {Self-Illuminating Materials}. + \list + \li The \uicontrol Intensity property determines the quantity of light + the surface of material emits. + \li The \uicontrol {Map Texture} property defines a texture for + emissive map, while the \uicontrol {Mask Texture} defines a + texture for emissive mask. Use the \uicontrol {Mask Offset} + to set the mask offset for the emissive map. + \endlist + + \target bump_metal + \section2 Bump + Specify the properties under the \uicontrol Bump tab to simulate fine + geometry displacement across the surface of the material. Use the + \uicontrol Amount property to set the quantity of displacement, and + the \uicontrol Texture property to define a texture for the bump map. + For more information, see \l {Simulating Geometry Displacement}. + + \section2 Properties of the Steel Milled Concentric Material + + Another metal, the \uicontrol {Steel Milled Concentric} Material has + certain properties that the other materials do not possess: + + \list + \li The \uicontrol Anisotropy property stretches the highlight, + which simulates minuscule scratches. You can also use a + \uicontrol Texture property to define a texture for the anisotropy + map. + \li The \uicontrol {Index of Refraction} defines how much a ray of + transmitted light is bent when it reaches the surface of the + material. + \endlist + + Under the \uicontrol Textures tab: + + \list + \li The \uicontrol Tiling property to set the tiling repeat of the + texture maps. + \li Use the \uicontrol Diffuse property to set a texture for the + diffuse map, and the \uicontrol Anisotropy property to set a + texture for the anisotropy map. + \endlist + + \section1 Glass Materials + + The following describes properties related to glass-based materials, which + include \uicontrol Glass, \uicontrol {Frosted Glass}, \uicontrol + {Frosted Glass Single Pass}, and \uicontrol {Glass Refractive}. + + \section2 Color + + Set the surface tint of the material by specifying the + \uicontrol {Glass Color} property. You can also specify the \uicontrol + {Band Light Color} for the \uicontrol {Frosted Glass} material. + + Use the \uicontrol {Glass Color} and \uicontrol {Band Light Color} + properties to set the color properties for glass-based materials. + + \target general_glass + \section2 General + + \list + \li Set the \uicontrol {Fresnel Power} property to decrease head-on + reflections (looking directly at the surface) while maintaining + reflections seen at grazing angles. + \li Use the \uicontrol Roughness property to determine how light + behaves when it comes in contact with material. With zero roughness, + light bounces off a material, which makes it appear glossy. + Increased roughness causes the light reflected off the material to + scatter, which results in a matte appearance. + \li The \uicontrol Reflectivity property specifies how much light is + reflected from the material. + \li The \uicontrol {Index of Refraction} defines reflectivity by + determinining how much a ray of transmitted light is bent when it + reaches the surface of the material. + \li The \uicontrol {Refract Depth} property sets the refraction depth + for the material. + \li Use the \uicontrol {Minimum Opacity} property to determine the + minimum level of opaqueness for the material. + \li The \uicontrol {Blur size} property sets the amount of blurring + behind the glass. + \endlist + + \section2 Bump + + For frosted glass materials, specify the properties under the + \uicontrol Bump tab to simulate fine geometry displacement across the + surface of the material: + + \list + \li Use the \uicontrol Scale and \uicontrol Bands properties to define + the scale and number of the Bump Bands. + \li The \uicontrol Strength property sets the glass bump map strength. + \li Use the \uicontrol Internal property to specify whether the bump map + should only be used for internal lighting. + \li The \uicontrol Texture property to define a texture for the bump + map. + \li The \uicontrol Coordinates property sets the bump coordinates of the + refraction. + \endlist + + For more information, see \l {Simulating Geometry Displacement}. + + \target rgm_glass + \section2 Random Gradient Mapping + + For frosted glass materials, you can also specify \uicontrol + {Random Gradient Maps} by using properties \uicontrol 1D, \uicontrol 2D, + \uicontrol 3D and \uicontrol 4D. Each of the properties defines a texture + map used to create the random bumpiness of the material. + + \section2 Band Light + + The outlook of the \uicontrol {Frosted Glass} material can be further + defined by specifying the \uicontrol {Band Light} properties: + \list + \li The \uicontrol Fallof property sets the light intensity falloff + rate. + \li The \uicontrol Angle property sets the angle of the light source to + which the band is perpendicular. + \li You can also set the \uicontrol Brightness of the band light. + \li Use the \uicontrol Position property to set the coordinates for + the band light in the UV space. + \endlist + + \section2 Noise + + For the \uicontrol {Frosted Glass Single Pass} material you can specify + the noise quality by defining the noise \uicontrol Scale property and + setting the noise \uicontrol Coordinates. + + \section1 Plastic + + The following describes properties for the available plastic materials, + which include \uicontrol {Plastic Structured} and \uicontrol {Plastic + Struct Emissive}. + + \section2 Color + + Use the \uicontrol {Diffuse Color} to set the color that the material + reflects when illuminated by direct light. + + The \uicontrol {Emission Color} defines the color of emission for + the \uicontrol {Plastic Struct Emissive} material. + + \section2 General + + Plastic materials share some of the properties with glass materials. For + descriptions of \uicontrol Roughness and \uicontrol {Index of Refraction} + properties, see \l{general_glass} {general properties for glass materials}. + \list + \li The \uicontrol {Texture scaling} property determines how fast a + material is repeated on a surface. + \li The \uicontrol {Bump Factor} property sets the strength of bumpiness + for glass materials. + \endlist + + \section2 Random Gradient Mapping + + See \l {rgm_glass}{Random Gradient Mapping for Glass Materials}. + + \section2 Emission + + The properties of emission for glass materials are similar to those of + metal materials. For decription of emission properties, see + \l{emission_metal} {emission properties for metal materials}. + + \section1 Paper Materials + + The following describes properties for the available paper materials, + which include \uicontrol {Paper Artistic} and \uicontrol {Paper Office}. + + \section2 Color + + Set the surface tint for the \uicontrol {Paper Office} material by + specifying the \uicontrol {Paper Color} property. + + \section2 Transmission + + Specify the \uicontrol Transmission settings to define the outlook of light + passing through the material. The \uicontrol {Transmission Weight} + property specifies how much light scatters through the surface of the + material, while the \uicontrol {Reflection Weight} sets the luminance of + highlights and reflections. + + \section2 General + \list + \li The \uicontrol {Translucency Falloff} sets the point of decline for + translucency of the material. + \li The \uicontrol Opacity property sets the material's level of + opaqueness. + \li For the description of \uicontrol {Texture Tiling} properties, see + \l {tiling_metal} {tiling for metal materials}. + \endlist + + \section2 Diffuse Map + + Use the \uicontrol {Light Wrap} property to set the diffuse light bend of + the material. The \uicontrol Texture property defines a texture for the + diffuse map. + + \section2 Bump + + For the description of \uicontrol Bump properties, see \l {bump_metal} + {properties for metal materials}. + + \section1 Available Materials + + See the following table for available materials. + + \table + \header + \li Material + \li Example Image + \li Description + + \row + \li Aluminum + \li \image material-aluminum.png "The Aluminum material" + \li A material with the appearance of aluminum. + + \row + \li Aluminum Anod Emis + \li \image material-aluminum-anodized-emissive.png "The Aluminum Anodized Emissive material" + \li Anodized aluminum with emissive properties. + + \row + \li Aluminum Anodized + \li \image material-aluminum-anodized.png "The Anodized Aluminum material" + \li Anodized aluminum. + + \row + \li Aluminum Brushed + \li \image material-aluminum-brushed.png "The Brushed Aluminum material" + \li Brushed aluminum. + + \row + \li Aluminum Emissive + \li \image material-aluminum-emissive.png "The Aluminum Emissive material" + \li Aluminum with emissive properties. + + \row + \li Copper + \li \image material-copper.png "The Copper material" + \li A material with the appearance of copper. + + \row + \li Glass + \li \image material-glass.png "The Glass material" + \li A material with the appearance of glass. + + \row + \li Frosted glass + \li \image material-frosted-glass.png "The Frosted Glass material" + \li Frosted glass. + + \row + \li Frosted Glass Single Pass + \li \image material-frosted-glass-single-pass.png "The Frosted Glass Single Pass material" + \li A single-pass frosted glass. + + \row + \li Glass Refractive + \li \image material-refractive-glass.png "The Glass Refractive material" + \li Refractive glass. + + \row + \li Paper Artistic + \li \image material-artistic-paper.png "The Paper Artistic material" + \li A paper material with an artistic finishing. + + \row + \li Paper Office + \li \image material-office-paper.png "The Paper Office material" + \li A paper material with an office-style finishing. + + \row + \li Plastic Struct Emissive + \li \image material-red-plastic-structured-emissive.png The Plastic Structured Emissive material" + \li A red structured plastic material with emissive properties. + + \row + \li Plastic Structured + \li \image material-red-plastic-structured.png "The Plastic Structured material" + \li A red structured plastic material. + + \row + \li Steel Milled Concentric + \li \image material-steel-milled-concentric.png "The Steel Milled Concentric material" + \li A milled concentric steel material. + \endtable +*/ diff --git a/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-texture.qdoc b/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-texture.qdoc index ab145f9ef2c..8354f8943aa 100644 --- a/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-texture.qdoc +++ b/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-texture.qdoc @@ -28,7 +28,7 @@ /*! \page studio-3d-texture.html \previouspage studio-3d-materials.html - \nextpage studio-3d-effects.html + \nextpage studio-3d-materials-types.html \title Attaching Textures to Materials @@ -112,9 +112,12 @@ \section1 Applying Textures to Materials - You drag and drop an image from \uicontrol Library > \uicontrol Assets - on a material to create and set the texture automatically, or you can use - a Texture component. + Drag and drop an image from \uicontrol Library > \uicontrol Assets + on a material to create and set the texture automatically, or use + a Texture component. For a default material the created \uicontrol Texture + is assigned to the \uicontrol {Diffuse Map} property and for a principled + material to the \uicontrol {Base Color Map}. For a custom material, you + must assign the texture to a map. To use Texture components to apply textures to materials: diff --git a/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d.qdoc b/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d.qdoc index ab65cea8f48..a295ca3e813 100644 --- a/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d.qdoc +++ b/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d.qdoc @@ -35,11 +35,11 @@ \title Editing 3D Scenes - You can use the 3D editor in the Design mode to edit files you created - using 3D graphics applications and stored in one of the supported formats. - You cannot create 3D models or other assets in the editor, but you can - \l{Importing 3D Assets}{import} the assets you need and work with them to - create scenes and states, as well as the transitions between them. + You can use \uicontrol {3D Editor} in the Design mode to edit files you + created using 3D graphics applications and stored in one of the supported + formats. You cannot create 3D models or other assets in the editor, but you + can \l{Importing 3D Assets}{import} the assets you need and work with them + to create scenes and states, as well as the transitions between them. When you import 3D scenes from files that you exported from 3D graphics tools, you also import the camera, light, model, and materials as 3D @@ -66,17 +66,17 @@ \li \l {Editing 3D Assets in Design Mode} \QDS opens QML files that contain 3D scenes in the Design mode and - the scenes in the 3D editor. You can add imported 3D assets + the scenes in \uicontrol {3D Editor}. You can add imported 3D assets to projects as 3D components. \li \l {Working in 3D Editor} - You can select 3D components in the 3D editor to move, rotate, and - scale them in the scene projected by the camera. + You can select 3D components in \uicontrol {3D Editor} to move, + rotate, and scale them in the scene projected by the camera. \li \l{Adding 3D Views} - You can drag and drop 3D components from the \uicontrol Library - to the scene or to the \uicontrol Navigator. You must add all - 3D components into a 3D view. + You can drag and drop 3D components from \uicontrol Library + to the scene or to \uicontrol Navigator. You must add all 3D + components into a 3D view. \li \l {Using 3D Components} You can speficy properties for 3D components, such as cameras, diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/mousearea3d.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/mousearea3d.cpp index 03ec0f56d99..1495bc4ea5d 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/mousearea3d.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/mousearea3d.cpp @@ -58,10 +58,7 @@ public: return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; } - QVector3D toVec3() const - { - return QVector3D(float(x), float(y), float(z)); - } + QVector3D toVec3() const { return {float(x), float(y), float(z)}; } DoubleVec3D normalized() const { @@ -82,6 +79,8 @@ public: return std::sqrt(len); } + DoubleVec3D operator-() { return {-x, -y, -z}; } + double x = 0.; double y = 0.; double z = 0.; @@ -119,6 +118,268 @@ DoubleVec3D operator/(const DoubleVec3D &v1, const DoubleVec3D &v2) return DoubleVec3D(v1.x / v2.x, v1.y / v2.y, v1.z / v2.z); } +// Limited functionality double precision matrix4x4 for cases where float calculations +// can suffer from rounding errors +class DoubleMat44 { +public: + DoubleMat44() + { + // Default is identity matrix + m[0][0] = 1.; + m[0][1] = 0.; + m[0][2] = 0.; + m[0][3] = 0.; + m[1][0] = 0.; + m[1][1] = 1.; + m[1][2] = 0.; + m[1][3] = 0.; + m[2][0] = 0.; + m[2][1] = 0.; + m[2][2] = 1.; + m[2][3] = 0.; + m[3][0] = 0.; + m[3][1] = 0.; + m[3][2] = 0.; + m[3][3] = 1.; + } + + DoubleMat44(const QMatrix4x4 &mat) + { + for (int i = 0; i < 4; ++i) { + for (int j = 0; j < 4; ++j) + m[i][j] = double(mat(j, i)); + } + } + + QMatrix4x4 toQMatrix4x4() + { + return QMatrix4x4(float(m[0][0]), float(m[1][0]), float(m[2][0]), float(m[3][0]), + float(m[0][1]), float(m[1][1]), float(m[2][1]), float(m[3][1]), + float(m[0][2]), float(m[1][2]), float(m[2][2]), float(m[3][2]), + float(m[0][3]), float(m[1][3]), float(m[2][3]), float(m[3][3])); + } + + static inline double matrixDet2(const double m[4][4], int col0, int col1, int row0, int row1) + { + return m[col0][row0] * m[col1][row1] - m[col0][row1] * m[col1][row0]; + } + + static inline double matrixDet3(const double m[4][4], int col0, int col1, int col2, + int row0, int row1, int row2) + { + return m[col0][row0] * matrixDet2(m, col1, col2, row1, row2) + - m[col1][row0] * matrixDet2(m, col0, col2, row1, row2) + + m[col2][row0] * matrixDet2(m, col0, col1, row1, row2); + } + + DoubleMat44 inverted() + { + DoubleMat44 inv; + + double det = matrixDet3(m, 0, 1, 2, 0, 1, 2); + if (det != 0.) { + det = 1. / det; + + inv.m[0][0] = matrixDet2(m, 1, 2, 1, 2) * det; + inv.m[0][1] = -matrixDet2(m, 0, 2, 1, 2) * det; + inv.m[0][2] = matrixDet2(m, 0, 1, 1, 2) * det; + inv.m[0][3] = 0; + inv.m[1][0] = -matrixDet2(m, 1, 2, 0, 2) * det; + inv.m[1][1] = matrixDet2(m, 0, 2, 0, 2) * det; + inv.m[1][2] = -matrixDet2(m, 0, 1, 0, 2) * det; + inv.m[1][3] = 0; + inv.m[2][0] = matrixDet2(m, 1, 2, 0, 1) * det; + inv.m[2][1] = -matrixDet2(m, 0, 2, 0, 1) * det; + inv.m[2][2] = matrixDet2(m, 0, 1, 0, 1) * det; + inv.m[2][3] = 0; + inv.m[3][0] = -inv.m[0][0] * m[3][0] - inv.m[1][0] * m[3][1] - inv.m[2][0] * m[3][2]; + inv.m[3][1] = -inv.m[0][1] * m[3][0] - inv.m[1][1] * m[3][1] - inv.m[2][1] * m[3][2]; + inv.m[3][2] = -inv.m[0][2] * m[3][0] - inv.m[1][2] * m[3][1] - inv.m[2][2] * m[3][2]; + inv.m[3][3] = 1; + } + return inv; + } + + DoubleVec3D transform(const DoubleVec3D &v) + { + DoubleVec3D ret; + + auto multCol = [&](int c, double d) { + ret.x += m[c][0] * d; + ret.y += m[c][1] * d; + ret.z += m[c][2] * d; + }; + + multCol(0, v.x); + multCol(1, v.y); + multCol(2, v.z); + multCol(3, 1.); + + return ret; + } + + static DoubleMat44 matrixMultiD(const QMatrix4x4& m1, const QMatrix4x4& m2) + { + DoubleMat44 m1d(m1); + DoubleMat44 m2d(m2); + + return matrixMultiD(m1d, m2d); + } + + static DoubleMat44 matrixMultiD(const DoubleMat44& m1, const DoubleMat44& m2) + { + DoubleMat44 m; + + m.m[0][0] = m1.m[0][0] * m2.m[0][0] + + m1.m[1][0] * m2.m[0][1] + + m1.m[2][0] * m2.m[0][2] + + m1.m[3][0] * m2.m[0][3]; + m.m[0][1] = m1.m[0][1] * m2.m[0][0] + + m1.m[1][1] * m2.m[0][1] + + m1.m[2][1] * m2.m[0][2] + + m1.m[3][1] * m2.m[0][3]; + m.m[0][2] = m1.m[0][2] * m2.m[0][0] + + m1.m[1][2] * m2.m[0][1] + + m1.m[2][2] * m2.m[0][2] + + m1.m[3][2] * m2.m[0][3]; + m.m[0][3] = m1.m[0][3] * m2.m[0][0] + + m1.m[1][3] * m2.m[0][1] + + m1.m[2][3] * m2.m[0][2] + + m1.m[3][3] * m2.m[0][3]; + + m.m[1][0] = m1.m[0][0] * m2.m[1][0] + + m1.m[1][0] * m2.m[1][1] + + m1.m[2][0] * m2.m[1][2] + + m1.m[3][0] * m2.m[1][3]; + m.m[1][1] = m1.m[0][1] * m2.m[1][0] + + m1.m[1][1] * m2.m[1][1] + + m1.m[2][1] * m2.m[1][2] + + m1.m[3][1] * m2.m[1][3]; + m.m[1][2] = m1.m[0][2] * m2.m[1][0] + + m1.m[1][2] * m2.m[1][1] + + m1.m[2][2] * m2.m[1][2] + + m1.m[3][2] * m2.m[1][3]; + m.m[1][3] = m1.m[0][3] * m2.m[1][0] + + m1.m[1][3] * m2.m[1][1] + + m1.m[2][3] * m2.m[1][2] + + m1.m[3][3] * m2.m[1][3]; + + m.m[2][0] = m1.m[0][0] * m2.m[2][0] + + m1.m[1][0] * m2.m[2][1] + + m1.m[2][0] * m2.m[2][2] + + m1.m[3][0] * m2.m[2][3]; + m.m[2][1] = m1.m[0][1] * m2.m[2][0] + + m1.m[1][1] * m2.m[2][1] + + m1.m[2][1] * m2.m[2][2] + + m1.m[3][1] * m2.m[2][3]; + m.m[2][2] = m1.m[0][2] * m2.m[2][0] + + m1.m[1][2] * m2.m[2][1] + + m1.m[2][2] * m2.m[2][2] + + m1.m[3][2] * m2.m[2][3]; + m.m[2][3] = m1.m[0][3] * m2.m[2][0] + + m1.m[1][3] * m2.m[2][1] + + m1.m[2][3] * m2.m[2][2] + + m1.m[3][3] * m2.m[2][3]; + + m.m[3][0] = m1.m[0][0] * m2.m[3][0] + + m1.m[1][0] * m2.m[3][1] + + m1.m[2][0] * m2.m[3][2] + + m1.m[3][0] * m2.m[3][3]; + m.m[3][1] = m1.m[0][1] * m2.m[3][0] + + m1.m[1][1] * m2.m[3][1] + + m1.m[2][1] * m2.m[3][2] + + m1.m[3][1] * m2.m[3][3]; + m.m[3][2] = m1.m[0][2] * m2.m[3][0] + + m1.m[1][2] * m2.m[3][1] + + m1.m[2][2] * m2.m[3][2] + + m1.m[3][2] * m2.m[3][3]; + m.m[3][3] = m1.m[0][3] * m2.m[3][0] + + m1.m[1][3] * m2.m[3][1] + + m1.m[2][3] * m2.m[3][2] + + m1.m[3][3] * m2.m[3][3]; + + return m; + } + + static DoubleMat44 rotationMatrix(const QQuaternion &rot) + { + DoubleMat44 rotMat; + double xp = double(rot.x()); + double yp = double(rot.y()); + double zp = double(rot.z()); + double wp = double(rot.scalar()); + + const double f2x = xp + xp; + const double f2y = yp + yp; + const double f2z = zp + zp; + const double f2xw = f2x * wp; + const double f2yw = f2y * wp; + const double f2zw = f2z * wp; + const double f2xx = f2x * xp; + const double f2xy = f2x * yp; + const double f2xz = f2x * zp; + const double f2yy = f2y * yp; + const double f2yz = f2y * zp; + const double f2zz = f2z * zp; + + rotMat.m[0][0] = 1. - (f2yy + f2zz); + rotMat.m[1][0] = f2xy - f2zw; + rotMat.m[2][0] = f2xz + f2yw; + rotMat.m[0][1] = f2xy + f2zw; + rotMat.m[1][1] = 1. - (f2xx + f2zz); + rotMat.m[2][1] = f2yz - f2xw; + rotMat.m[0][2] = f2xz - f2yw; + rotMat.m[1][2] = f2yz + f2xw; + rotMat.m[2][2] = 1. - (f2xx + f2yy); + + return rotMat; + } + + double m[4][4]; +}; + +static DoubleMat44 calcLocalTransform(const QQuick3DNode *node) +{ + DoubleVec3D pivotD(-node->pivot()); + const DoubleVec3D scaleD(node->scale()); + const DoubleVec3D posD(node->position()); + pivotD = pivotD * scaleD; + DoubleMat44 localTransform; + + localTransform.m[0][0] = scaleD.x; + localTransform.m[1][1] = scaleD.y; + localTransform.m[2][2] = scaleD.z; + + localTransform.m[3][0] = pivotD.x; + localTransform.m[3][1] = pivotD.y; + localTransform.m[3][2] = pivotD.z; + + DoubleMat44 rotMat = DoubleMat44::rotationMatrix(node->rotation()); + localTransform = DoubleMat44::matrixMultiD(rotMat, localTransform); + + localTransform.m[3][0] += posD.x; + localTransform.m[3][1] += posD.y; + localTransform.m[3][2] += posD.z; + + return localTransform; +} + +static DoubleMat44 calcGlobalTransform(const QQuick3DNode *node) +{ + DoubleMat44 localTrans = calcLocalTransform(node); + QQuick3DNode *parent = node->parentNode(); + if (parent) { + DoubleMat44 globalTrans = calcGlobalTransform(parent); + return DoubleMat44::matrixMultiD(globalTrans, localTrans); + } + return localTrans; +} + +static DoubleVec3D getNormalD(const DoubleMat44 &m) +{ + return DoubleVec3D(m.m[2][0], m.m[2][1], m.m[2][2]).normalized(); +} + MouseArea3D *MouseArea3D::s_mouseGrab = nullptr; MouseArea3D::MouseArea3D(QQuick3DNode *parent) @@ -333,6 +594,36 @@ void MouseArea3D::componentComplete() m_view3D->installEventFilter(this); } +static DoubleVec3D rayIntersectsPlaneD(const DoubleVec3D &rayPos0, + const DoubleVec3D &rayPos1, + const DoubleVec3D &planePos, + const DoubleVec3D &planeNormal) +{ + const DoubleVec3D rayDirection = rayPos1 - rayPos0; + const DoubleVec3D rayPos0RelativeToPlane = rayPos0 - planePos; + + const double dotPlaneRayDirection = DoubleVec3D::dotProduct(planeNormal, rayDirection); + const double dotPlaneRayPos0 = -DoubleVec3D::dotProduct(planeNormal, rayPos0RelativeToPlane); + + if (qFuzzyIsNull(dotPlaneRayDirection)) { + // The ray is is parallel to the plane. Note that if dotPlaneRayPos0 == 0, it + // additionally means that the line lies in plane as well. In any case, we + // signal that we cannot find a single intersection point. + return DoubleVec3D(0., 0., -1.); + } + + // Since we work with a ray (that has a start), distanceFromRayPos0ToPlane + // must be above 0. If it was a line segment (with an end), it also need to be less than 1. + // (Note: a third option would be a "line", which is different from a ray or segment in that + // it has neither a start, nor an end). Then we wouldn't need to check the distance at all. + // But that would also mean that the line could intersect the plane behind the camera, if + // the line were directed away from the plane when looking forward. + const double distanceFromRayPos0ToPlane = dotPlaneRayPos0 / dotPlaneRayDirection; + if (distanceFromRayPos0ToPlane <= 0.) + return DoubleVec3D(0., 0., -1.); + return (rayPos0 + distanceFromRayPos0ToPlane * rayDirection); +} + QVector3D MouseArea3D::rayIntersectsPlane(const QVector3D &rayPos0, const QVector3D &rayPos1, const QVector3D &planePos, @@ -342,29 +633,8 @@ QVector3D MouseArea3D::rayIntersectsPlane(const QVector3D &rayPos0, const DoubleVec3D rayPos1D(rayPos1); const DoubleVec3D planePosD(planePos); const DoubleVec3D planeNormalD(planeNormal); - const DoubleVec3D rayDirectionD = rayPos1D - rayPos0D; - const DoubleVec3D rayPos0RelativeToPlaneD = rayPos0D - planePosD; - const double dotPlaneRayDirection = DoubleVec3D::dotProduct(planeNormalD, rayDirectionD); - const double dotPlaneRayPos0 = -DoubleVec3D::dotProduct(planeNormalD, rayPos0RelativeToPlaneD); - - if (qFuzzyIsNull(dotPlaneRayDirection)) { - // The ray is is parallel to the plane. Note that if dotLinePos0 == 0, it - // additionally means that the line lies in plane as well. In any case, we - // signal that we cannot find a single intersection point. - return QVector3D(0.f, 0.f, -1.f); - } - - // Since we work with a ray (that has a start), distanceFromLinePos0ToPlane - // must be above 0. If it was a line segment (with an end), it also need to be less than 1. - // (Note: a third option would be a "line", which is different from a ray or segment in that - // it has neither a start, nor an end). Then we wouldn't need to check the distance at all. - // But that would also mean that the line could intersect the plane behind the camera, if - // the line were directed away from the plane when looking forward. - const double distanceFromRayPos0ToPlane = dotPlaneRayPos0 / dotPlaneRayDirection; - if (distanceFromRayPos0ToPlane <= 0.) - return QVector3D(0.f, 0.f, -1.f); - return (rayPos0D + distanceFromRayPos0ToPlane * rayDirectionD).toVec3(); + return rayIntersectsPlaneD(rayPos0D, rayPos1D, planePosD, planeNormalD).toVec3(); } // Get a new scale based on a relative scene distance along a drag axes. @@ -544,18 +814,28 @@ QVector3D MouseArea3D::getMousePosInPlane(const MouseArea3D *helper, if (!helper) helper = this; - const QVector3D mousePos1(float(mousePosInView.x()), float(mousePosInView.y()), 0); - const QVector3D rayPos0 = m_view3D->mapTo3DScene(mousePos1); - const QVector3D mousePos2(float(mousePosInView.x()), float(mousePosInView.y()), - rayPos0.length()); - const QVector3D rayPos1 = m_view3D->mapTo3DScene(mousePos2); - const QVector3D globalPlanePosition = helper->mapPositionToScene(QVector3D(0, 0, 0)); - const QVector3D intersectGlobalPos = rayIntersectsPlane(rayPos0, rayPos1, - globalPlanePosition, helper->forward()); - if (qFuzzyCompare(intersectGlobalPos.z(), -1)) - return intersectGlobalPos; + const DoubleVec3D mousePos1(float(mousePosInView.x()), float(mousePosInView.y()), 0); + const DoubleVec3D rayPos0 = m_view3D->mapTo3DScene(mousePos1.toVec3()); + DoubleVec3D rayPos1; + if (qobject_cast(m_view3D->camera())) { + rayPos1 = rayPos0 - rayPos0.length() * DoubleVec3D(m_view3D->camera()->cameraNode()->getDirection()); + } else { + DoubleVec3D dir; + DoubleVec3D camPos = m_view3D->camera()->scenePosition(); + dir = (rayPos0 - camPos).normalized(); + rayPos1 = rayPos0 + rayPos0.length() * dir; + } - return helper->mapPositionFromScene(intersectGlobalPos); + const DoubleVec3D globalPlanePosition = helper->mapPositionToScene(QVector3D(0, 0, 0)); + DoubleMat44 sceneTrans = calcGlobalTransform(helper); + const DoubleVec3D intersectGlobalPos = rayIntersectsPlaneD(rayPos0, rayPos1, + globalPlanePosition, + -getNormalD(sceneTrans)); + + if (qFuzzyCompare(intersectGlobalPos.z, -1.)) + return intersectGlobalPos.toVec3(); + + return sceneTrans.inverted().transform(intersectGlobalPos).toVec3(); } bool MouseArea3D::eventFilter(QObject *, QEvent *event) diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/AnimationSection.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/AnimationSection.qml index 6449de4fcc7..31ad4081d61 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/AnimationSection.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/AnimationSection.qml @@ -51,11 +51,13 @@ Section { Label { text: qsTr("Paused") tooltip: qsTr("Whether the animation is paused.") + disabledState: !backendValues.paused.isAvailable } CheckBox { text: backendValues.paused.valueToString backendValue: backendValues.paused + enabled: backendValue.isAvailable } Label { text: qsTr("Loops") diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/AnimationTargetSection.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/AnimationTargetSection.qml index a744c3173a7..87801f90509 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/AnimationTargetSection.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/AnimationTargetSection.qml @@ -56,6 +56,7 @@ Section { LineEdit { backendValue: backendValues.property Layout.fillWidth: true + showTranslateCheckBox: false } Label { text: qsTr("Properties") @@ -64,6 +65,7 @@ Section { LineEdit { backendValue: backendValues.properties Layout.fillWidth: true + showTranslateCheckBox: false } } diff --git a/src/libs/qmljs/qmljscheck.cpp b/src/libs/qmljs/qmljscheck.cpp index 175ea0341df..92e1c1e59cf 100644 --- a/src/libs/qmljs/qmljscheck.cpp +++ b/src/libs/qmljs/qmljscheck.cpp @@ -1835,7 +1835,10 @@ const Value *Check::checkScopeObjectMember(const UiQualifiedId *id) if (value) break; } - if (!value) { + + const bool isListElementScope = (!m_typeStack.isEmpty() && m_typeStack.last() == "ListElement"); + + if (!value && !isListElementScope) { addMessage(ErrInvalidPropertyName, id->identifierToken, propertyName); return nullptr; } diff --git a/src/plugins/clangrefactoring/baseclangquerytexteditorwidget.cpp b/src/plugins/clangrefactoring/baseclangquerytexteditorwidget.cpp index 05cb74f599c..29f53c71d1e 100644 --- a/src/plugins/clangrefactoring/baseclangquerytexteditorwidget.cpp +++ b/src/plugins/clangrefactoring/baseclangquerytexteditorwidget.cpp @@ -32,7 +32,7 @@ namespace ClangRefactoring { BaseClangQueryTextEditorWidget::BaseClangQueryTextEditorWidget(QWidget *parent) : TextEditor::TextEditorWidget(parent) { - setupFallBackEditor(Core::Id()); + setupFallBackEditor(Utils::Id()); setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); setHighlightCurrentLine(false); setLineNumbersVisible(false); diff --git a/src/plugins/cmakeprojectmanager/cmakesettingspage.cpp b/src/plugins/cmakeprojectmanager/cmakesettingspage.cpp index 61e3dba76fd..e26a0cb9706 100644 --- a/src/plugins/cmakeprojectmanager/cmakesettingspage.cpp +++ b/src/plugins/cmakeprojectmanager/cmakesettingspage.cpp @@ -343,8 +343,8 @@ void CMakeToolItemModel::removeCMakeTool(const Utils::Id &id) CMakeToolTreeItem *treeItem = cmakeToolItem(id); QTC_ASSERT(treeItem, return); - destroyItem(treeItem); m_removedItems.append(id); + destroyItem(treeItem); } void CMakeToolItemModel::apply() diff --git a/src/plugins/projectexplorer/appoutputpane.cpp b/src/plugins/projectexplorer/appoutputpane.cpp index 320cd5ac6e0..63a9377df74 100644 --- a/src/plugins/projectexplorer/appoutputpane.cpp +++ b/src/plugins/projectexplorer/appoutputpane.cpp @@ -154,8 +154,10 @@ void TabWidget::slotContextMenuRequested(const QPoint &pos) AppOutputPane::RunControlTab::RunControlTab(RunControl *runControl, Core::OutputWindow *w) : runControl(runControl), window(w) { - if (runControl && w) - w->setLineParsers(runControl->createOutputParsers()); + if (runControl && w) { + w->reset(); + runControl->setupFormatter(w->outputFormatter()); + } } AppOutputPane::AppOutputPane() : @@ -405,7 +407,8 @@ void AppOutputPane::createNewOutputWindow(RunControl *rc) if (tab.runControl) tab.runControl->initiateFinish(); tab.runControl = rc; - tab.window->setLineParsers(rc->createOutputParsers()); + tab.window->reset(); + rc->setupFormatter(tab.window->outputFormatter()); handleOldOutput(tab.window); diff --git a/src/plugins/projectexplorer/runcontrol.cpp b/src/plugins/projectexplorer/runcontrol.cpp index a7d3a075fa9..a5b45af2ef8 100644 --- a/src/plugins/projectexplorer/runcontrol.cpp +++ b/src/plugins/projectexplorer/runcontrol.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -824,7 +825,7 @@ void RunControlPrivate::showError(const QString &msg) q->appendMessage(msg + '\n', ErrorMessageFormat); } -QList RunControl::createOutputParsers() const +void RunControl::setupFormatter(OutputFormatter *formatter) const { QList parsers = OutputFormatterFactory::createFormatters(target()); if (const auto customParsersAspect @@ -834,7 +835,11 @@ QList RunControl::createOutputParsers() const parsers << parser; } } - return parsers; + formatter->setLineParsers(parsers); + Utils::FileInProjectFinder fileFinder; + fileFinder.setProjectDirectory(project()->projectDirectory()); + fileFinder.setProjectFiles(project()->files(Project::AllFiles)); + formatter->setFileFinder(fileFinder); } Utils::Id RunControl::runMode() const diff --git a/src/plugins/projectexplorer/runcontrol.h b/src/plugins/projectexplorer/runcontrol.h index 6926ec4c582..b609815363c 100644 --- a/src/plugins/projectexplorer/runcontrol.h +++ b/src/plugins/projectexplorer/runcontrol.h @@ -46,6 +46,7 @@ namespace Utils { class MacroExpander; class OutputLineParser; +class OutputFormatter; } // Utils namespace ProjectExplorer { @@ -238,7 +239,7 @@ public: Utils::FilePath targetFilePath() const; Utils::FilePath projectFilePath() const; - QList createOutputParsers() const; + void setupFormatter(Utils::OutputFormatter *formatter) const; Utils::Id runMode() const; const Runnable &runnable() const; diff --git a/src/plugins/qmldesigner/components/navigator/choosetexturepropertydialog.cpp b/src/plugins/qmldesigner/components/navigator/choosetexturepropertydialog.cpp new file mode 100644 index 00000000000..826ed580cae --- /dev/null +++ b/src/plugins/qmldesigner/components/navigator/choosetexturepropertydialog.cpp @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "choosetexturepropertydialog.h" +#include "nodemetainfo.h" +#include "ui_choosetexturepropertydialog.h" + +namespace QmlDesigner { + +// This dialog displays all texture properties of an object and allows the user to choose one +ChooseTexturePropertyDialog::ChooseTexturePropertyDialog(const ModelNode &node, QWidget *parent) + : QDialog(parent) + , m_ui(new Ui::ChooseTexturePropertyDialog) +{ + m_ui->setupUi(this); + setWindowTitle(tr("Select Texture Property")); + m_ui->label->setText(tr("Set texture to property:")); + setFixedSize(size()); + + connect(m_ui->listProps, &QListWidget::itemClicked, this, [this](QListWidgetItem *item) { + m_selectedProperty = item->isSelected() ? item->data(Qt::DisplayRole).toByteArray() : QByteArray(); + }); + + connect(m_ui->listProps, &QListWidget::itemDoubleClicked, this, [this](QListWidgetItem *item) { + Q_UNUSED(item) + QDialog::accept(); + }); + + fillList(node); +} + +ChooseTexturePropertyDialog::~ChooseTexturePropertyDialog() +{ + delete m_ui; +} + +TypeName ChooseTexturePropertyDialog::selectedProperty() const +{ + return m_selectedProperty; +} + +void ChooseTexturePropertyDialog::fillList(const ModelNode &node) +{ + // Fill the list with all properties of type Texture + const auto metaInfo = node.metaInfo(); + const auto propNames = metaInfo.propertyNames(); + const TypeName textureProp("QtQuick3D.Texture"); + QStringList nameList; + for (const auto &propName : propNames) { + if (metaInfo.propertyTypeName(propName) == textureProp) + nameList.append(QString::fromLatin1(propName)); + } + + if (!nameList.isEmpty()) { + QString defaultProp = nameList.first(); + + nameList.sort(); + for (const auto &propName : qAsConst(nameList)) { + QListWidgetItem *newItem = new QListWidgetItem(propName); + m_ui->listProps->addItem(newItem); + } + + // Select the default prop + m_ui->listProps->setCurrentRow(nameList.indexOf(defaultProp)); + m_selectedProperty = defaultProp.toLatin1(); + } +} + +} diff --git a/src/plugins/qmldesigner/components/navigator/choosetexturepropertydialog.h b/src/plugins/qmldesigner/components/navigator/choosetexturepropertydialog.h new file mode 100644 index 00000000000..7604e6f9427 --- /dev/null +++ b/src/plugins/qmldesigner/components/navigator/choosetexturepropertydialog.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include +#include + +#include + +namespace QmlDesigner { +namespace Ui { +class ChooseTexturePropertyDialog; +} + +class ChooseTexturePropertyDialog : public QDialog +{ + Q_OBJECT + +public: + explicit ChooseTexturePropertyDialog(const ModelNode &node, QWidget *parent = 0); + ~ChooseTexturePropertyDialog(); + + TypeName selectedProperty() const; + +private: + void fillList(const ModelNode &node); + + Ui::ChooseTexturePropertyDialog *m_ui; + TypeName m_selectedProperty; +}; +} diff --git a/src/plugins/qmldesigner/components/navigator/choosetexturepropertydialog.ui b/src/plugins/qmldesigner/components/navigator/choosetexturepropertydialog.ui new file mode 100644 index 00000000000..8643e866d5c --- /dev/null +++ b/src/plugins/qmldesigner/components/navigator/choosetexturepropertydialog.ui @@ -0,0 +1,110 @@ + + + QmlDesigner::ChooseTexturePropertyDialog + + + + 0 + 0 + 250 + 250 + + + + + 200 + 150 + + + + + 1000 + 1000 + + + + + + + false + + + false + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + + buttonBox + accepted() + QmlDesigner::ChooseTexturePropertyDialog + accept() + + + 240 + 240 + + + 157 + 274 + + + + + buttonBox + rejected() + QmlDesigner::ChooseTexturePropertyDialog + reject() + + + 240 + 240 + + + 286 + 274 + + + + + diff --git a/src/plugins/qmldesigner/components/navigator/navigator.pri b/src/plugins/qmldesigner/components/navigator/navigator.pri index 08432e7f861..7344f1bc5a0 100644 --- a/src/plugins/qmldesigner/components/navigator/navigator.pri +++ b/src/plugins/qmldesigner/components/navigator/navigator.pri @@ -5,7 +5,8 @@ SOURCES += navigatorview.cpp \ navigatorwidget.cpp \ nameitemdelegate.cpp \ iconcheckboxitemdelegate.cpp \ - navigatortreeview.cpp + navigatortreeview.cpp \ + choosetexturepropertydialog.cpp HEADERS += navigatorview.h \ navigatortreemodel.h \ @@ -13,6 +14,9 @@ HEADERS += navigatorview.h \ nameitemdelegate.h \ iconcheckboxitemdelegate.h \ navigatortreeview.h \ - navigatormodelinterface.h + navigatormodelinterface.h \ + choosetexturepropertydialog.h RESOURCES += navigator.qrc + +FORMS += choosetexturepropertydialog.ui diff --git a/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp b/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp index f86b3779335..c93b3145e90 100644 --- a/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp +++ b/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp @@ -25,6 +25,7 @@ #include "navigatortreemodel.h" #include "navigatorview.h" +#include "choosetexturepropertydialog.h" #include "qmldesignerplugin.h" #include @@ -51,6 +52,7 @@ #include #include #include +#include #include @@ -649,6 +651,10 @@ void NavigatorTreeModel::handleItemLibraryImageDrop(const QMimeData *mimeData, i // create a texture newModelNode = QmlItemNode::createQmlObjectNode(m_view, itemLibraryEntry, {}, targetProp, false); + + // Rename the node based on source image + QFileInfo fi(imagePath); + newModelNode.setIdWithoutRefactoring(m_view->generateNewId(fi.baseName(), "textureImage")); return newModelNode.isValid(); } return false; @@ -656,16 +662,21 @@ void NavigatorTreeModel::handleItemLibraryImageDrop(const QMimeData *mimeData, i if (targetNode.isSubclassOf("QtQuick3D.Material")) { // if dropping an image on a default material, create a texture instead of image - m_view->executeInTransaction("NavigatorTreeModel::handleItemLibraryImageDrop", [&] { - if (createTextureNode(targetProperty)) { - // Automatically set the texture to default property - // TODO: allow the user to choose which map property to set the texture for (QDS-2326) - if (targetNode.isSubclassOf("QtQuick3D.DefaultMaterial")) - targetNode.bindingProperty("diffuseMap").setExpression(newModelNode.validId()); - else if (targetNode.isSubclassOf("QtQuick3D.PrincipledMaterial")) - targetNode.bindingProperty("baseColorMap").setExpression(newModelNode.validId()); - } - }); + ChooseTexturePropertyDialog *dialog = nullptr; + if (targetNode.isSubclassOf("QtQuick3D.DefaultMaterial") || targetNode.isSubclassOf("QtQuick3D.PrincipledMaterial")) { + // Show texture property selection dialog + dialog = new ChooseTexturePropertyDialog(targetNode, Core::ICore::dialogParent()); + dialog->exec(); + } + if (!dialog || dialog->result() == QDialog::Accepted) { + m_view->executeInTransaction("NavigatorTreeModel::handleItemLibraryImageDrop", [&] { + if (createTextureNode(targetProperty) && dialog) { + // Automatically set the texture to selected property + targetNode.bindingProperty(dialog->selectedProperty()).setExpression(newModelNode.validId()); + } + }); + } + delete dialog; } else if (targetNode.isSubclassOf("QtQuick3D.TextureInput")) { // If dropping an image on a TextureInput, create a texture on the same level as // TextureInput, as the TextureInput doesn't support Texture children (QTBUG-86219) diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp index 8634f590ab6..56a17e3d11c 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp @@ -276,6 +276,7 @@ static QList prepareNonMcuProperties() { QList result; + //Builtins: const QList itemProperties = {"layer", "opacity", "gradient", "smooth", "antialiasing", "border", "baselineOffset", "focus", "activeFocusOnTab"}; const QList mouseAreaProperties = {"propagateComposedEvents", "preventStealing", "cursorShape", @@ -296,6 +297,19 @@ static QList prepareNonMcuProperties() "highlightResizeDuration", "preferredHighlightBegin", "layoutDirection", "preferredHighlightEnd", "highlightFollowsCurrentItem", "keyNavigationWraps", "snapMode", "highlightMoveVelocity", "highlightResizeVelocity"}; + //Animations: + const QList animationProperties = {"paused"}; + + //QtQuick.Controls: + const QList controlProperties = {"focusPolicy", "hoverEnabled", "wheelEnabled"}; + const QList abstractButtonProperties = {"display", "autoExclusive"}; + const QList buttonProperties = {"flat", "highlighted"}; + const QList dialProperties = {}; //nothing in propeditor + const QList progressBarProperties = {"indeterminate"}; + const QList radioButton = {}; //nothing in propeditor + const QList sliderProperties = {"live", "snapMode", "touchDragThreshold"}; + const QList swipeViewProperties = {}; //nothing in propeditor + const QList switchProperties = {}; //nothing in propeditor result.append(itemProperties); result.append(mouseAreaProperties); @@ -305,13 +319,25 @@ static QList prepareNonMcuProperties() result.append(paddingProperties); result.append(columnRowProperties); result.append(listViewProperties); - + result.append(animationProperties); + result.append(controlProperties); + result.append(abstractButtonProperties); + result.append(buttonProperties); + result.append(dialProperties); + result.append(progressBarProperties); + result.append(radioButton); + result.append(sliderProperties); + result.append(swipeViewProperties); + result.append(switchProperties); return result; } bool PropertyEditorValue::isAvailable() const { + if (!m_modelNode.isValid()) + return true; + const QList nonMcuProperties = prepareNonMcuProperties(); const QByteArray fontPrefix = {"font"}; diff --git a/src/plugins/qmldesigner/designercore/include/abstractview.h b/src/plugins/qmldesigner/designercore/include/abstractview.h index d0dcddb2eef..2412ed9700b 100644 --- a/src/plugins/qmldesigner/designercore/include/abstractview.h +++ b/src/plugins/qmldesigner/designercore/include/abstractview.h @@ -160,6 +160,7 @@ public: ModelNode modelNodeForId(const QString &id); bool hasId(const QString &id) const; QString generateNewId(const QString &prefixName) const; + QString generateNewId(const QString &prefixName, const QString &fallbackPrefix) const; ModelNode modelNodeForInternalId(qint32 internalId) const; bool hasModelNodeForInternalId(qint32 internalId) const; diff --git a/src/plugins/qmldesigner/designercore/model/abstractview.cpp b/src/plugins/qmldesigner/designercore/model/abstractview.cpp index 42e890fec93..7fa787ca0ea 100644 --- a/src/plugins/qmldesigner/designercore/model/abstractview.cpp +++ b/src/plugins/qmldesigner/designercore/model/abstractview.cpp @@ -504,40 +504,36 @@ QString firstCharToLower(const QString &string) return resultString; } -QString AbstractView::generateNewId(const QString &prefixName) const +QString AbstractView::generateNewId(const QString &prefixName, const QString &fallbackPrefix) const { - QString fixedPrefix = firstCharToLower(prefixName); - fixedPrefix.remove(' '); - - bool forceSuffix = false; - - if (!ModelNode::isValidId(fixedPrefix)) - forceSuffix = true; + // First try just the prefixName without number as postfix, then continue with 2 and further + // as postfix until id does not already exist. + // Properties of the root node are not allowed for ids, because they are available in the + // complete context without qualification. int counter = 0; - /* First try just the prefixName without number as postfix, then continue with 2 and further as postfix - * until id does not already exist. - * Properties of the root node are not allowed for ids, because they are available in the complete context - * without qualification. - * The id "item" is explicitly not allowed, because it is too likely to clash. - */ + QString newBaseId = QString(QStringLiteral("%1")).arg(firstCharToLower(prefixName)); + newBaseId.remove(QRegularExpression(QStringLiteral("[^a-zA-Z0-9_]"))); - QString newId = QString(QStringLiteral("%1")).arg(firstCharToLower(prefixName)); - if (forceSuffix) - QString(QStringLiteral("%1%2")).arg(firstCharToLower(prefixName)).arg(1); + if (newBaseId.isEmpty()) + newBaseId = fallbackPrefix; - newId.remove(QRegularExpression(QStringLiteral("[^a-zA-Z0-9_]"))); + QString newId = newBaseId; - while (!ModelNode::isValidId(newId) || hasId(newId) || rootModelNode().hasProperty(newId.toUtf8()) || newId == "item") { - counter += 1; - newId = QString(QStringLiteral("%1%2")).arg(firstCharToLower(prefixName)).arg(counter); - newId.remove(QRegularExpression(QStringLiteral("[^a-zA-Z0-9_]"))); + while (!ModelNode::isValidId(newId) || hasId(newId) || rootModelNode().hasProperty(newId.toUtf8())) { + ++counter; + newId = QString(QStringLiteral("%1%2")).arg(firstCharToLower(newBaseId)).arg(counter); } return newId; } +QString AbstractView::generateNewId(const QString &prefixName) const +{ + return generateNewId(prefixName, QStringLiteral("element")); +} + ModelNode AbstractView::modelNodeForInternalId(qint32 internalId) const { return ModelNode(model()->d->nodeForInternalId(internalId), model(), this); diff --git a/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp b/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp index fe42f2b7e0b..886e524b291 100644 --- a/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp +++ b/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp @@ -106,7 +106,8 @@ QmlItemNode QmlItemNode::createQmlItemNodeFromImage(AbstractView *view, const QS newQmlItemNode = QmlItemNode(view->createModelNode("QtQuick.Image", metaInfo.majorVersion(), metaInfo.minorVersion(), propertyPairList)); parentproperty.reparentHere(newQmlItemNode); - newQmlItemNode.setId(view->generateNewId(QLatin1String("image"))); + QFileInfo fi(relativeImageName); + newQmlItemNode.setId(view->generateNewId(fi.baseName(), "image")); newQmlItemNode.modelNode().variantProperty("fillMode").setEnumeration("Image.PreserveAspectFit");