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

/*!
    \page creator-editor-codepasting.html
    \previouspage creator-how-tos.html

    \ingroup creator-how-to-edit

    \title Paste and fetch code snippets

    To paste snippets of code or whole files to a server or fetch them from the
    server, use one of the following code pasting services:

    \list
        \li DPaste.com
        \li Pastebin.com
    \endlist

    For example, you might ask colleagues to review a change that you plan to
    submit to a version control system. If you use the Git version control
    system, create a \e{diff} view by going to \uicontrol Tools >
    \uicontrol Git > \uicontrol {Local Repository} > \uicontrol Diff.
    Then, upload its contents to the server by going to \uicontrol Tools >
    \uicontrol {Code Pasting} > \uicontrol {Paste Snippet}.

    The reviewers can retrieve the code snippet by selecting \uicontrol Tools >
    \uicontrol {Code Pasting} > \uicontrol {Fetch Snippet}. If they have the
    project currently opened in \QC, they can apply and test the change by
    going to \uicontrol Tools > \uicontrol Git > \uicontrol {Local Repository}
    > \uicontrol Patch > \uicontrol {Apply from Editor}.

    \section1 Paste snippets

    To paste a snippet of code onto the server:

    \list 1
        \li Go to \uicontrol Tools > \uicontrol {Code Pasting} >
            \uicontrol {Paste Snippet} or select \key {Alt+C,Alt+P}.
            \image {qtcreator-send-to-codepaster.webp} {Send to Codepaster dialog}
        \li In \uicontrol Protocol, select the code pasting service to use.
        \li In \uicontrol {Expires after}, specify the time to keep
            the pasted snippet on the server.
        \li In \uicontrol Username and \uicontrol Description, enter your
            username and add information about the pasted content.
        \li Check and edit the content to paste.
        \li Select \uicontrol Paste.
    \endlist

    By default, \QC copies the URL of the snippet to the
    clipboard and displays the URL in \uicontrol {General Messages}.

    To paste a \l{Compare files}{diff}, right-click a chunk and select
    \uicontrol {Send Chunk to CodePaster} in the context menu.

    \section1 Fetch snippets

    To fetch a snippet of code from the server:

    \list 1
        \li Go to \uicontrol Tools > \uicontrol {Code Pasting} >
            \uicontrol {Fetch Snippet} or select \key {Alt+C,Alt+F}.
        \li Select the snippet to fetch from the list.
    \endlist

    To fetch the content stored at a URL, select \uicontrol Tools >
    \uicontrol {Code Pasting} > \uicontrol {Fetch from URL}.

    \section1 Set code pasting preferences

    To set preferences for a code pasting service:

    \list 1
        \li Go to \preferences > \uicontrol {Code Pasting} > \uicontrol General.
            \image {qtcreator-code-pasting-options.png} {General tab in Code Pasting preferences}
        \li In \uicontrol {Default protocol}, select a code pasting service to
            use by default.
        \li In \uicontrol Username, enter your username.
        \li In \uicontrol {Expires after}, specify the time to keep
            the pasted snippet on the server.
        \li Select \uicontrol {Copy-paste URL to clipboard} to copy the URL of
            the post on the code pasting service to the clipboard when you paste
            a post.
        \li Select \uicontrol {Display General Messages after sending a post}
            to display the URL in \l{View output}{General Messages}
            when you paste a post.
    \endlist

    \section2 Set a shared network drive for code pasting

    Go to \preferences > \uicontrol {Code Pasting} > \uicontrol Fileshare to
    specify the path to a shared network drive.

    The code snippets are copied to the drive as simple files. You have to
    delete obsolete files from the drive manually.

    \sa {Compare files}, {Git}
*/
