// Copyright (C) 2025 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

/*!
    \page creator-preferences-qtquick-code-style.html
    \previouspage creator-how-tos.html

    \ingroup creator-how-to-edit

    \title Specify Qt Quick code style

    You can use the built-in code formatter (deprecated) or an external tool,
    such as \l {qmlformat}, to automatically format QML files according to QML
    coding conventions.

    To specify QML code style globally:

    \list 1
        \li Go to \preferences > \uicontrol {Qt Quick} > \uicontrol {Code Style}.
        \li In \uicontrol {Custom settings}, select the settings to
            modify, and then select \uicontrol Copy.
            \image {qtcreator-preferences-qtquick-code-style.webp} {Code Style tab in Qt Quick preferences}
        \li Give a name to the settings, and select \uicontrol OK.
        \li In \uicontrol {Formatter Selection}, select the formatter to use.
    \endlist

    To override the global preferences for a particular project, select
    \uicontrol Projects > \uicontrol {Code Style}.

    \section1 Use the built-in formatter

    The built-in formatter has been deprecated in favor of the qmlformat tool or
    a custom formatter.

    To set global preferences for the built-in formatter:

    \list 1
        \li In \uicontrol {Formatter Selection}, select
            \uicontrol {Built-in formatter}.
        \li Specify how to interpret the \key Tab key
            presses and how to align continuation lines, as well as set the
            maximum line length for code lines.
    \endlist

    \section1 Use qmlformat

    To set global preferences for the \l {qmlformat} tool:

    \list 1
        \li In \uicontrol {Formatter Selection}, select \uicontrol {QMLFormat}.
            \image {qtcreator-preferences-qtquick-code-style-qmlformat.webp} {qmlformatter preferences in the Code Style tab in Qt Quick preferences}
        \li In \uicontrol {Global qmlformat Configuration}, set the code style.
            This field uses the same format as a \c .qmlformat.ini file and
            overrides the \c .qmlformat.ini file in the generic configuration
            location (\l{QStandardPaths::GenericConfigLocation}).
    \endlist

    The \l {qmlformat} tool searches for a \c .qmlformat.ini file in the same directory as the
    file being formatted. If it is not found, it searches the parent directories up to
    the root directory. If no \c .qmlformat.ini file is found, the global preferences
    are used. For more information, see the
    \l{qtqml-tooling-qmlformat.html#qmlformat-settings}{qmlformat configuration settings}.

    \note If a custom \c .qmlformat.ini file exists in the project directory or any
    parent directory, it takes precedence over the global configuration.

    \section1 Use a custom tool

    To use a custom tool that is compatible with qmlformat:

    \list 1
        \li In \uicontrol {Formatter Selection}, select
            \uicontrol {Custom formatter}.
            \image {qtcreator-preferences-qtquick-code-style-custom-formatter.webp}{Custom formatter preferences in the Code Style tab in Qt Quick preferences}
        \li In \uicontrol Command, enter the path to the tool.
        \li In \uicontrol Arguments, enter options for running the tool.
        \li View the code style set in a \c .qmlformat.ini file on the right.
    \endlist

    \sa {Automatically format QML/JS files}, {Find preferences},
    {Indent text or code}, {Specify code style}
*/
