
    c/                         d Z ddlZddlZddlmZmZmZ ddlmZm	Z	 ddl
mZmZ ddlmZmZmZ ddlmZ dd	lmZmZ d
diZdZddddddddddd
Zd Zd Zd Zd Zd!dZd Zd Zd Z  G d d ej!                  Z"dS )"z
qtawesome
=========

Font-Awesome and other iconic fonts for PyQt / PySide applications.

.. currentmodule:: qtawesome

.. autosummary::
   :toctree: _generate

   icon
   load_font
   charmap
   font
   set_defaults
    N)QtCore	QtWidgetsQtGui   )__version__version_info)PulseSpin)
IconicFontset_global_defaults	FontError)SYSTEM_FONTS)darklighticonic)
)fafontawesome4.7-webfont.ttfz#fontawesome4.7-webfont-charmap.json)fa5 fontawesome5-regular-webfont.ttfz)fontawesome5-regular-webfont-charmap.json)fa5sfontawesome5-solid-webfont.ttfz'fontawesome5-solid-webfont-charmap.json)fa5bfontawesome5-brands-webfont.ttfz(fontawesome5-brands-webfont-charmap.json)eielusiveicons-webfont.ttfz!elusiveicons-webfont-charmap.json)mdi materialdesignicons5-webfont.ttfz)materialdesignicons5-webfont-charmap.json)mdi6 materialdesignicons6-webfont.ttfz)materialdesignicons6-webfont-charmap.json)phphosphor.ttfzphosphor-charmap.json)riremixicon.ttfzremixicon-charmap.json)msccodicon.ttfzcodicon-charmap.json b06871f281fee6b241d60582ae9369b9 dc47e4089f5bcb25f241bdeb2de0fb58 5de19800fc9ae73438c2e5c61d041b48 513aa607d398efaccc559916c3431403 207966b04c032d5b873fd595a211582e b7d40e7ef80c1d4af6d94902af66e524 9a2f455e7cbce011368aee95d292613b 5b8dc57388b2d86243566b996cc3a789 888e61f04316f10bddfff7bee10c6dd0 d8565ee605ac4d2fa71fe018863337ca)
r   r   r   r   r   r   r   r!   r#   r%   c                     | j                                         D ]&}t          j                            |          }|s dS 'dS )zValidate instance's font ids are loaded to QFontDatabase.

    It is possible that QFontDatabase was reset or QApplication was recreated
    in both cases it is possible that font is not available.
    FT)fontidsvaluesr   QFontDatabaseapplicationFontFamilies)instfont_idfont_familiess      2lib/python3.11/site-packages/qtawesome/__init__.pyhas_valid_font_idsr9   T   sW     <&&((  +CC
 
  	55	4    c                     t           d         $t          t           d                   s
dt           d<   t           d         )t          st          D ]} | d         }t                              |d          }|)t          j                            t          j        	                    t          j        
                    t                              d|          }t          |d          5 }t          j        |                                                                          }ddd           n# 1 swxY w Y   ||k    rt#          d| d          t%          t           t           d<   t           d         S )z
    Return the singleton instance of IconicFont.

    Functions ``icon``, ``load_font``, ``charmap``, ``font`` and
    ``set_defaults`` all rebind to methods of the singleton instance of IconicFont.
    r   Nr   fontsrbzFont is corrupt at: '')	_resourcer9   _SYSTEM_FONTS_BUNDLED_FONTS_MD5_HASHESgetospathjoindirnamerealpath__file__openhashlibmd5read	hexdigestr   r   )fargsttf_filenamettf_hashttf_filepathfttf_calculated_hash_codes         r8   	_instancerU   d   s    	(#"9X#677#
 #	( : 	M' M M$Qx&??<>> !w||GOOBG$4$4X$>$>??\ +  + ,-- Q/6{16688/D/D/N/N/P/P,Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q+x7 M#$KL$K$K$KLLLM ).9	(Xs   (9D--D1	4D1	c                  H    t           d         i t           d         _        d S d S )Nr   )r?   
icon_cache r:   r8   reset_cacherY      s,     ,)+	(&&&, ,r:   c                  4     t                      j        | i |S )a  
    Return a QIcon object corresponding to the provided icon name(s).

    This function is the main interface of qtawesome.

    It can be used to create a QIcon instance from a single glyph
    or from a list of glyphs that are displayed on the top of each other.
    Such icon stacks are generally used to combine multiple glyphs to make
    more complex icons.

    Glyph names are specified by strings, of the form ``prefix.name``.
    The ``prefix`` corresponds to the font to be used and ``name`` is the
    name of the icon.

     - The prefix corresponding to Font-Awesome 4.x is 'fa'
     - The prefix corresponding to Font-Awesome 5.x (regular) is 'fa5'
     - The prefix corresponding to Font-Awesome 5.x (solid) is 'fa5s'
     - The prefix corresponding to Font-Awesome 5.x (brands) is 'fa5b'
     - The prefix corresponding to Elusive-Icons is 'ei'
     - The prefix corresponding to Material-Design-Icons 5.x is 'mdi'
     - The prefix corresponding to Material-Design-Icons 6.x is 'mdi6'
     - The prefix corresponding to Phosphor is 'ph'
     - The prefix corresponding to Remix-Icon is 'ri'
     - The prefix corresponding to Microsoft's Codicons is 'msc'

    When requesting a single glyph, options (such as color or positional offsets)
    can be passed as keyword arguments::

        import qtawesome as qta

        music_icon = qta.icon(
            'fa5s.music',
            color='blue',
            color_active='orange')

    When requesting multiple glyphs, the `options` keyword argument contains
    the list of option dictionaries to be used for each glyph::

        camera_ban = qta.icon('fa5s.camera', 'fa5s.ban', options=[{
                'scale_factor': 0.5,
                'active': 'fa5s.balance-scale'
            }, {
                'color': 'red',
                'opacity': 0.7
            }])

    Qt's ``QIcon`` object has four modes

        - ``Normal``: The user is not interacting with the icon, but the
          functionality represented by the icon is available.
        - ``Disabled``: The functionality corresponding to the icon is not
          available.
        - ``Active``: The functionality corresponding to the icon is available.
          The user is interacting with the icon, for example, moving the mouse
          over it or clicking it.
        - ``Selected``: The item represented by the icon is selected.

    The glyph for the Normal mode is the one specified with the main positional
    argument.

     - ``color``: icon color in the ``Normal`` mode.

    The following four options will apply to the icon regardless of the mode.

     - ``offset``: tuple (x, y) corresponding to the horizontal and vertical
       offsets for the glyph, specified as a proportion of the icon size.
     - ``animation``: animation object for the icon.
     - ``scale_factor``: multiplicative scale factor to be used for the glyph.

    The following options apply to the different modes of the icon

     - ``active``: name of the glyph to be used when the icon is ``Active``.
     - ``color_active``: the corresponding icon color.

     - ``disabled``: name of the glyph to be used when the icon is ``Disabled``.
     - ``color_disabled``: the corresponding icon color.

     - ``selected``: name of the glyph to be used when the icon is ``Selected``.
     - ``color_selected``: the corresponding icon color.

    Default values for these options can be specified via the function
    ``set_defaults``. If unspecified, the default defaults are::

        {
            'opacity': 1.0,
            'scale_factor': 1.0
            'color': QColor(50, 50, 50),
            'color_disabled': QColor(150, 150, 150),
        }

    If no default value is provided for ``active``, ``disabled`` or ``selected``
    the glyph specified for the ``Normal`` mode will be used.

    )rU   icon)nameskwargss     r8   r[   r[      s!    ~ 9;;U-f---r:   c                 J    t                                          | |||          S )a  
    Loads a font file and the associated charmap.

    If ``directory`` is passed, the files will be looked for in the qtawesome
    ``fonts`` directory.

    Parameters
    ----------
    prefix: str
        Prefix string to be used when accessing a given font set
    ttf_filename: str
        Ttf font filename
    charmap_filename: str
        Character map filename
    directory: str or None, optional
        Directory path for font and charmap files

    Example
    -------
    If you want to load a font ``myicon.tff`` with a ``myicon-charmap.json``
    charmap added to the qtawesome ``fonts`` directory (usually located at
    ``</path/to/lib/python>/site-packages/qtawesome/fonts/``) you can use::

        qta.load_font(
            'myicon',
            'myicon.ttf',
            'myicon-charmap.json'
        )

    However, if you want to load a font ``myicon.tff`` with a
    ``myicon-charmap.json`` charmap located in a specific path outside the
    qtawesome ``font`` directory like for example ``/path/to/myproject/fonts``
    you can use::

        qta.load_font(
            'myicon',
            'myicon.ttf',
            'myicon-charmap.json',
            directory='/path/to/myproject/fonts'
        )

    )rU   	load_font)prefixrP   charmap_filename	directorys       r8   r_   r_      s$    V ;;  7GSSSr:   c                 p    |                      d          \  }}t                      j        |         |         S )z
    Return the character map used for a given font.

    Returns
    -------
    return_value: dict
        The dictionary mapping the icon names to the corresponding unicode character.

    .)splitrU   charmap)prefixed_namer`   names      r8   rf   rf     s2     !&&s++LFD;;v&t,,r:   c                 F    t                                          | |          S )a  
    Return the font corresponding to the specified prefix.

    This can be used to render text using the iconic font directly::

        import qtawesome as qta
        from qtpy import QtWidgets

        label = QtWidgets.QLabel(unichr(0xf19c) + ' ' + 'Label')
        label.setFont(qta.font('fa', 16))

    Parameters
    ----------
    prefix: str
        prefix string of the loaded font
    size: int
        size for the font

    )rU   font)r`   sizes     r8   rj   rj   )  s    ( ;;FD)))r:   c                      t          di | S )z
    Set default options for icons.

    The valid keyword arguments are:

    'active', 'animation', 'color', 'color_active', 'color_disabled',
    'color_selected', 'disabled', 'offset', 'scale_factor', 'selected'.

    rX   )r   )r]   s    r8   set_defaultsrm   @  s     (((((r:   c                   8     e Zd ZdZ fdZd Zd Z fdZ xZS )
IconWidgetaN  
    IconWidget gives the ability to display an icon as a widget

    if supports the same arguments as icon()
    for example
    music_icon = qta.IconWidget('fa5s.music',
                                color='blue',
                                color_active='orange')

    it also have setIcon() and setIconSize() functions
    c                     t                                          |                    d                     d | _        t	          j        dd          | _        |                     t          |i |           d S )Nparent)rq      )	super__init__rC   _iconr   QSize_sizesetIconr[   )selfr\   r]   	__class__s      r8   rt   zIconWidget.__init__Z  si    

8 4 4555
\"b))
T5+F++,,,,,r:   c                 n    || _         |                     |                    | j                             dS )z
        set a new icon()

        Parameters
        ----------
        _icon: qtawesome.icon
            icon to set
        N)ru   	setPixmappixmaprw   )ry   ru   s     r8   rx   zIconWidget.setIcon`  s1     
u||DJ//00000r:   c                     || _         dS )z~
        set icon size

        Parameters
        ----------
        size: QtCore.QSize
            size of the icon
        N)rw   )ry   rk   s     r8   setIconSizezIconWidget.setIconSizel  s     


r:   c                     | j         r2|                     | j                             | j                              t	                      j        |i |S N)ru   r|   r}   rw   rs   update)ry   argsr]   rz   s      r8   r   zIconWidget.updatew  sL    : 	:NN4:,,TZ88999uww~t.v...r:   )	__name__
__module____qualname____doc__rt   rx   r   r   __classcell__)rz   s   @r8   ro   ro   M  sy        
 
- - - - -
1 
1 
1	 	 	/ / / / / / / / /r:   ro   r   )#r   rK   rD   qtpyr   r   r   _versionr   r   	animationr	   r
   iconic_fontr   r   r   r   r@   stylesr   r   r?   rA   rB   r9   rU   rY   r[   r_   rf   rj   rm   QLabelro   rX   r:   r8   <module>r      s   $  				 * ) ) ) ) ) ) ) ) ) 0 / / / / / / / " " " " " " " " C C C C C C C C C C 6 6 6 6 6 6         	H #E(J&H'I B(J(J675      D, , ,
_. _. _.D+T +T +T +T\- - -* * *.
) 
) 
)-/ -/ -/ -/ -/! -/ -/ -/ -/ -/r:   