
    o'e                     F    d dl Z G d de          Z G d de          ZdS )    Nc                   $    e Zd ZdZd Zd Zd ZdS )	IconCachezzMaintain a cache of icons.  If an icon is used more than once by a GUI
    then ensure that only one copy is created.
    c                 >    || _         || _        d| _        g | _        dS )zInitialise the cache. N)_object_factory_qtgui_module	_base_dir_cache)selfobject_factoryqtgui_modules      4lib/python3.11/site-packages/PyQt5/uic/icon_cache.py__init__zIconCache.__init__   s&      .)    c                     || _         dS )z? Set the base directory to be used for all relative filenames. N)r	   )r   base_dirs     r   set_base_dirzIconCache.set_base_dir'   s     "r   c                 x   |j                             d          }|7| j                            dd| j                            |          fd          S |j        dS t          || j                  }	 | j        	                    |          }n# t          $ r d}Y nw xY w|dk    r| j        |         }nd}t          | j                  }|dk    r|t          |          z  }| j                            d	|d
d          }|                    || j                   | j                            |           |j        S )z2Return an icon described by the given iconset tag.themeNzQIcon.fromThemeiconF)is_attributer   QIcon )attribgetr   createQObjectasStringtext_IconSetr	   r
   index
ValueErrorlenstrset_iconr   appendr   )r   iconsetr   isetidxnamer   s          r   get_iconzIconCache.get_icon,   sa    ""7++'556GT1::5AAD!& 6 ( ( (
 <400	+##D))CC 	 	 	CCC	 !88;s#DD Ddk""CQwwC '55gtR!& 6 ( (DMM$ 2333Kt$$$ys   3B BBN)__name__
__module____qualname____doc__r   r   r+   r   r   r   r   r      sK           " " "
% % % % %r   r   c                   :    e Zd ZdZd Zed             Zd Zd ZdS )r    zAAn icon set, ie. the mode and state and the pixmap used for each.c                     |                      |j        |          | _        d| _        i | _        |D ]7}|j        }||                      ||          }|| j        |j        <   d| _        8d| _        dS )z(Initialise the icon set from an XML tag.TNF)
_file_namer   	_fallback_use_fallback_rolestagr   )r   r'   r   i	file_names        r   r   z_IconSet.__init__W   s     x@@!  	' 	'AI$ OOIx@@	!*DK!&D 			r   c                     |                      dd          } |dk    rK| d         dk    r?t          j                            |           s t          j                            ||           } | S )z: Convert a relative filename if we have a base directory. \z\\r   r   :)replaceospathisabsjoin)fnamer   s     r   r2   z_IconSet._file_namel   sX     dF++r>>eAh#oobgmmE6J6JoGLL511Er   c                 B   | j         r|                    | j                   n| j                                        D ]\  }}|                    d          r|dd         }|j        j        }n-|                    d          r|dd         }|j        j        }n^t          |j        |
                                          }|r+|                    |                    |          ||           |                    |                                ||           || _        dS )z%Save the icon and set its attributes.offNon)r4   addFiler3   r5   itemsendswithr   OffOngetattrtitle	addPixmapQPixmapr   )r   r   r   rolepixmapmodestates          r   r%   z_IconSet.set_iconw   s#     	HLL(((( $ 1 1 3 3 H Hf=='' 9D(.2EE]]4(( 9D(.1EE|14::<<@@ HNN<#7#7#?#?uMMMMNN<#7#7#9#94GGGG			r   c                     t          |t          |                     st          S | j        r|j        r| j        |j        k    S dS |j        rdS | j        |j        k    S )z#Compare two icon sets for equality.F)
isinstancetypeNotImplementedr4   r3   r5   )r   others     r   __eq__z_IconSet.__eq__   sk     %d,, 	"!! 	" 9~885 	5{el**r   N)	r,   r-   r.   r/   r   staticmethodr2   r%   rY   r   r   r   r    r    T   sb        KK  *   \  2+ + + + +r   r    )os.pathr=   objectr   r    r   r   r   <module>r]      sy   . 7 7 7 7 7 7 7 7tK+ K+ K+ K+ K+v K+ K+ K+ K+ K+r   