creator-mime-types.qdoc 3.99 KB
Newer Older
1 2
/****************************************************************************
**
Eike Ziller's avatar
Eike Ziller committed
3 4
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
**
**
** GNU Free Documentation License
**
** 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.
**
**
****************************************************************************/

// **********************************************************************
// NOTE: the sections are not ordered by their logical order to avoid
// reshuffling the file each time the index order changes (i.e., often).
// Run the fixnavi.pl script to adjust the links to the index order.
// **********************************************************************

/*!
26
    \contentspage {Qt Creator Manual}
27
    \previouspage creator-editor-fakevim.html
28
    \page creator-mime-types.html
29
    \nextpage creator-modeling.html
30 31 32 33 34 35 36 37 38 39 40 41 42

    \title Editing MIME Types

    \QC uses the \l{http://en.wikipedia.org/wiki/Internet_media_type}
    {Internet media type} (MIME type) of the file to determine which mode and
    editor to use for opening the file. For example, \QC opens C++ source and
    header files in the C++ editor, and Qt widget based UI files (.ui) in \QD.

    To identify the MIME type of a file, \QC uses matching by pattern and
    matching by contents. First, \QC looks at the filename to check whether it
    matches the patterns specified for any MIME type. If no match is found, it
    checks the contents of the file for magic headers specified for the file.

43 44 45 46 47 48 49 50
    The magic headers can contain the following types of values: string, host,
    big-endian, little-endian, and byte. \QC interprets the values according to
    the
    \l{http://standards.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html}
    {Shared MIME-info Database specification}.

    \QC searches for the value within a specified range in the files and takes
    the priority of the magic header into account. If you specify wide search
51 52 53 54 55 56 57 58 59 60 61 62
    ranges, openging files in \QC might take a long time. Therefore, you are
    advised to use the recommended values for the range and priority of the
    magic header.

    If your files do not match the predefined MIME types, you can edit the
    MIME types to add filename extensions and magic headers. You cannot add
    new MIME types, however.

    To edit MIME types:

    \list 1

63
        \li Select \uicontrol {Tools > Options > Environment > MIME Types}.
64 65 66

            \image qtcreator-mime-types.png "MIME Types"

67
        \li In \uicontrol {MIME Type}, select a MIME type.
68

69
        \li In \uicontrol Patterns, add the filename extension for the type of files
70 71
            that you want to identify as having this MIME type.

72
        \li Click \uicontrol Add to add \uicontrol {Magic Headers}.
73 74 75

            \image qtcreator-mime-types-magic-header.png "Magic Header"

76
        \li In the \uicontrol Value field, specify a text string or bytes that
77 78
            appear in the files.

79
        \li In the \uicontrol Type field, select the type of the value.
80

81 82 83 84 85 86
        \li In the \uicontrol Mask field, specify the number to combine the
            value in the file with using the AND operator before comparing it to
            the specified value. You can specify any numbers as masks for
            numerical types, whereas masks for strings must be in base 16, and
            start with 0x.

87 88 89
            \note You are recommended not to change the range and priority,
            because it might cause problems when opening files in \QC.

90
        \li Click \uicontrol OK.
91 92 93 94

    \endlist

    To revert all the changes you have made to the MIME type definitions,
95
    select \uicontrol {Reset All}.
96

97
    \note If you now select \uicontrol OK or \uicontrol Apply, you permanently lose all
98 99 100 101
    your own patterns and magic headers. The changes are reverted the next
    time you start \QC.

*/