
    ce#                       U d Z ddlmZ dgZddlZddlmZ ddlmZ ddlmZ ddl	m
Z
 dd	lmZ dd
lmZ  G d dej                  Z G d dej                  Z G d dej                  Z G d dej                  Z G d dej                  Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d  d!ej                  Z ej        ej         e
j!                  Z!d"e"d#<    ej        ej         e
j#                  Z#d"e"d$<    G d% d&ej$                  Z%dS )'zCommon widgets and their bases.    )annotations
IconButtonN)QtCore)QtGui)	QtWidgets)images)widgets)
singletonsc                      e Zd ZdZdS )r   z%Common control for icon-only buttons.N__name__
__module____qualname____doc__     Alib/python3.11/site-packages/anaconda_navigator/widgets/common.pyr   r      s        ////r   c                      e Zd ZdZdS )WarningIconz^
    Icon with exclamation sign.

    Used by :class:`~WarningLabel` and its derivatives.
    Nr   r   r   r   r   r      s           r   r   c                      e Zd ZdZdS )	ErrorIcon/
    Icon with exclamation sign in circle.
    Nr   r   r   r   r   r   "              r   r   c                      e Zd ZdZdS )InfoIconr   Nr   r   r   r   r   r   (   r   r   r   c                       e Zd ZdZ ej                    Zddddej        j        fd fdZ	e
dd            Zej        dd            Z xZS )LabelWithIconzm
    Combined label with icon at the beginning.

    Icon is shown only when the main text is not empty.
    N icontyping.Optional[widgets.QLabel]textstrtooltipbutton	alignment
typing.AnyreturnNonec                D   t                                                       || _        t          j                    | _        | j                            |           | j                            d           t          j                    | _        | j        	                    |           | j        j
                            | j                   t          j                    | _        | j                            | j        d|           | j                            | j        d|           |r!| j                            | j        d|           | j                            dddd           | j                            d           |                     | j                   || _        dS )/Initialize new :class:`~WarningLabel` instance.Tr         N)super__init___LabelWithIcon__iconr	   	LabelBase_LabelWithIcon__content
setToolTipsetWordWrap_LabelWithIcon__buttonsetTextsig_clickedconnectsig_button_clickedr   QHBoxLayout_LabelWithIcon__layout	addWidgetsetContentsMargins
setSpacing	setLayoutr!   )selfr   r!   r#   r$   r%   	__class__s         r   r.   zLabelWithIcon.__init__7   s^    	48:A:K:M:M!!'***""4(((9@9J9L9Lf%%%!))$*ABBB=F=R=T=TQ	:::9=== 	AM##DM1i@@@((Aq!444  ###t}%%%			r   c                4    | j                                         S )zContent of the main label.)r1   r!   r?   s    r   r!   zLabelWithIcon.textX   s     ~""$$$r   valuec                    | j                             |           | j                            t	          |                     dS )zUpdate `text` value.N)r1   r5   r/   
setVisiblebool)r?   rC   s     r   r!   zLabelWithIcon.text]   s<     	u%%%tE{{+++++r   )r   r    r!   r"   r#   r"   r$   r"   r%   r&   r'   r(   )r'   r"   )rC   r"   r'   r(   )r   r   r   r   r   Signalr8   QtAlignTopr.   propertyr!   setter__classcell__r@   s   @r   r   r   .   s          ' 59$*I$6      B % % % X% 
[, , , [, , , , ,r   r   c                  B     e Zd ZdZdddej        j        fd fdZ xZS )WarningLabelzu
    Combined label with warning icon at the beginning.

    Icon is shown only when the main text is not empty.
    r   r!   r"   r#   r$   r%   r&   r'   r(   c                l    t                                          t                      ||||           dS )r*   r   r!   r#   r$   r%   N)r-   r.   r   r?   r!   r#   r$   r%   r@   s        r   r.   zWarningLabel.__init__k   s4     	kmm$PVbklllllr   
r!   r"   r#   r"   r$   r"   r%   r&   r'   r(   	r   r   r   r   r   rH   rI   r.   rL   rM   s   @r   rO   rO   d   sj          $*I$6m m m m m m m m m m mr   rO   c                  B     e Zd ZdZdddej        j        fd fdZ xZS )WarningBlockz<Same as :class:`~WarningLabel`, but with colored background.r   r!   r"   r#   r$   r%   r&   r'   r(   c                R    t                                          ||||           dS )z/Initialize new :class:`~WarningBlock` instance.r!   r#   r$   r%   Nr-   r.   rR   s        r   r.   zWarningBlock.__init__y   ,     	dGFiXXXXXr   rS   rT   rM   s   @r   rV   rV   v   sf        FF $*I$6Y Y Y Y Y Y Y Y Y Y Yr   rV   c                  B     e Zd ZdZdddej        j        fd fdZ xZS )
ErrorLabelzs
    Combined label with error icon at the beginning.

    Icon is shown only when the main text is not empty.
    r   r!   r"   r#   r$   r%   r&   r'   r(   c                l    t                                          t                      ||||           dS )z-Initialize new :class:`~ErrorLabel` instance.rQ   N)r-   r.   r   rR   s        r   r.   zErrorLabel.__init__   s3     	ikkgf`ijjjjjr   rS   rT   rM   s   @r   r\   r\      sj          $*I$6k k k k k k k k k k kr   r\   c                  B     e Zd ZdZdddej        j        fd fdZ xZS )
ErrorBlockz:Same as :class:`~ErrorLabel`, but with colored background.r   r!   r"   r#   r$   r%   r&   r'   r(   c                R    t                                          ||||           dS )z-Initialize new :class:`~ErrorBlock` instance.rX   NrY   rR   s        r   r.   zErrorBlock.__init__   rZ   r   rS   rT   rM   s   @r   r_   r_      sf        DD $*I$6Y Y Y Y Y Y Y Y Y Y Yr   r_   c                  B     e Zd ZdZdddej        j        fd fdZ xZS )	InfoLabelzr
    Combined label with info icon at the beginning.

    Icon is shown only when the main text is not empty.
    r   r!   r"   r#   r$   r%   r&   r'   r(   c                l    t                                          t                      ||||           dS )z,Initialize new :class:`~InfoLabel` instance.rQ   N)r-   r.   r   rR   s        r   r.   zInfoLabel.__init__   s3     	hjjtWV_hiiiiir   rS   rT   rM   s   @r   rb   rb      sj          $*I$6j j j j j j j j j j jr   rb   c                  B     e Zd ZdZdddej        j        fd fdZ xZS )	InfoBlockz9Same as :class:`~InfoLabel`, but with colored background.r   r!   r"   r#   r$   r%   r&   r'   r(   c                R    t                                          ||||           dS )z,Initialize new :class:`~InfoBlock` instance.rX   NrY   rR   s        r   r.   zInfoBlock.__init__   rZ   r   rS   rT   rM   s   @r   re   re      sf        CC $*I$6Y Y Y Y Y Y Y Y Y Y Yr   re   c                  >     e Zd ZdZd fdZdddZdd	Zdd
Z xZS )TeamEditionServerAlertzHShow combined labels with icon about connectivity problems to TE Server.r'   r(   c                R   t                                                       t          dt          j        j                  | _        t          ddt          j	         dt          j        j                  | _
        t          j                    | _        t          j                    }|                    | j                   |                    | j
                   | j
        j                            | j                   |                     |           |                                  d S )Nzm<b>Anaconda Server cannot be reached.</b> Some actions may not work as expected until connection is restored.)r!   r%   z><b>Connection to Anaconda Anaconda Server server restored.</b>z
<img src="z" height="16" width="16">)r!   r$   r%   )r-   r.   r_   r   rH   AlignVCentererror_labelre   r   BLOCK_CLOSE_ICON_PATH
info_labelQTimer_TeamEditionServerAlert__timerr   QVBoxLayoutr;   r8   r7   hide_allr>   )r?   layoutr@   s     r   r.   zTeamEditionServerAlert.__init__   s    5?V i,6
 6
 6
 4=QW <WWWi,4
 4
 4

 5;MOO6?6K6M6M)***)))*224=AAAvr     limittyping.Optional[int]c                B   | j                                         s| j                                          dS |                                  | j                                          | j                                         |r"| j                            || j                   dS dS )z#Show info label for `limit` secondsN)rk   	isVisiblehideshowrm   ro   
singleShotrq   )r?   rt   s     r   	show_infoz TeamEditionServerAlert.show_info   s    ))++ 	!!###F		 	:L##E4=99999	: 	:r   c                    |                                   | j                                          | j                                         dS )zShow error labelN)ry   rk   rm   rx   rB   s    r   
show_errorz!TeamEditionServerAlert.show_error   >    		r   c                    |                                   | j                                          | j                                          dS )zHide all labels.N)rx   rk   rm   rB   s    r   rq   zTeamEditionServerAlert.hide_all   r~   r   )r'   r(   )rs   )rt   ru   r'   r(   )	r   r   r   r   r.   r{   r}   rq   rL   rM   s   @r   rh   rh      s        RR     2
: 
: 
: 
: 
:          r   rh   z/typing.Final[singletons.Singleton[QtGui.QIcon]]PASSWORD_HIDDENPASSWORD_VISIBLEc                  8     e Zd ZdZddd fd
Zdd fdZ xZS )LineEditz<Custom QLineEdit with additional toggles for password entry.F)show_toggleargsr&   r   rF   r'   r(   c               4     t                      j        |  d}|rL                     t          j        t
          j        j                  }|j        	                     fd           | _
        |r&                     t
          j        j                   dS dS )z+Initialize new :class:`~LineEdit` instance.Nc                ,                                     S N)setEchoMode)_r?   s    r   <lambda>z#LineEdit.__init__.<locals>.<lambda>  s    d6F6F6H6H r   )r-   r.   	addActionr   instancer   	QLineEditTrailingPosition	triggeredr7   _toggle_actionr   Password)r?   r   r   toggle_actionr@   s   `   r   r.   zLineEdit.__init__  s    $<@ 	J NN?+CYEXEijjM#++,H,H,H,HIIIP] 	;Y09:::::	; 	;r   Nmoderu   c                   |J|                                  t          j        j        k    rt          j        j        }nt          j        j        }t                                          |           | j        dS |t          j        j        k    r&| j                            t          j
                   dS | j                            t          j
                   dS )z*Set how text should be echoed to the user.N)echoModer   r   r   Normalr-   r   r   setIconr   r   r   )r?   r   r@   s     r   r   zLineEdit.setEchoMode  s    <}})"5">>> *1 *3D!!!&F9&///''(@AAAAA''(8(ABBBBBr   )r   r&   r   rF   r'   r(   r   )r   ru   r'   r(   )r   r   r   r   r.   r   rL   rM   s   @r   r   r     s~        FF>C ; ; ; ; ; ; ; ;C C C C C C C C C C Cr   r   )&r   
__future__r   __all__typingqtpyr   r   r   anaconda_navigator.staticr   anaconda_navigatorr	   anaconda_navigator.utilsr
   QPushButtonr   QLabelr   r   r   QFramer   rO   rV   r\   r_   rb   re   QWidgetrh   SingleInstanceOfQIconr   __annotations__r   r   r   r   r   r   <module>r      s  
 & % % " " " " " ".                    , , , , , , & & & & & & / / / / / /0 0 0 0 0& 0 0 0    )"       	        y   3, 3, 3, 3, 3,I$ 3, 3, 3,lm m m m m= m m m$Y Y Y Y Y< Y Y Yk k k k k k k k$Y Y Y Y Y Y Y Yj j j j j j j j$Y Y Y Y Y	 Y Y Y2 2 2 2 2Y. 2 2 2j D_:C^	K
D D     E`JD_	K
E E     C C C C Cy" C C C C Cr   