
    Je                         d Z ddlZddlZddlmZmZmZmZ ddlm	Z	m
Z
 ddlmZ ddlmZ ddlmZmZ ddlmZmZmZmZmZmZ dd	lmZ dd
lmZmZ  ej<                  e      Z  G d de      Z!y)z#
Status widget for Spyder updates.
    N)QPointQtSignalSlot)QMenuQLabel)_)StatusBarWidget)
is_pynsistrunning_in_mac_app)UpdateInstallerDialog	NO_STATUSDOWNLOADING_INSTALLER
INSTALLINGPENDINGCHECKING)ima)add_actionscreate_actionc                        e Zd ZdZ ed      ZdZ e       Z	  ee	      Z
	 eZ fdZ fdZd Zd Zd Zd	 Zd
 Zd Zd Z e       d        Z xZS )ApplicationUpdateStatusz0Status bar widget for application update status.zApplication update statusapplication_update_statusc                    | j                   | _        t        |   |d       t	        |       | _        t        |       | _        | j                  j                  t        j                  t        j                  z         | j                  j                  | j                         | j                  j!                  | j"                         | j
                  j$                  j!                  | j&                         | j
                  j(                  j!                  | j*                         | j
                  j,                  j!                  | j,                         y )NT)show_spinner)BASE_TOOLTIPtooltipsuper__init__r   	installerr   menucustom_widgetsetAlignmentr   
AlignRightAlignVCentersetFont	text_fontsig_clickedconnect show_installation_dialog_or_menusig_download_progressset_download_progresssig_installation_status	set_valuesig_install_on_close_requested)selfparent	__class__s     K/usr/lib/python3/dist-packages/spyder/plugins/application/widgets/status.pyr   z ApplicationUpdateStatus.__init__8   s    ((d3 /t4 $K	 	''(GH""4>>2 	  !F!FG 	,,44&&	(..66NN	55==//	1    c                    |t         k(  s	|t        k(  rt        d      | _        |t         k(  rO| j                  j                          | j                  j                          | j                  j                          nN| j                  j                          | j                  j                          | j                  j                          | j                  j                          n|t        k(  rV|| _        | j                  j                          | j                  j                          | j                  j                          nw| j                  | _        | j                  r| j                  j                          | j                  r4| j                  j                          | j                  j                          | j                  d       | j                          d| }t        j!                  d|        t"        | I  |       y)z!Return update installation state.zfUpdate installation will continue in the background.
Click here to show the installation dialog again.TzSpyder: zApplication Update Status: N)r   r   r	   r   spinnerhidestopr!   showstartr   r   r   
setVisibleupdate_tooltiploggerdebugr   r-   )r/   valuer1   s     r2   r-   z!ApplicationUpdateStatus.set_valueS   sx   ))Uj-@ - .DL --!!#!!#""'')""'')!!#""$NN!g DL##%LLLL,,DL!!""'')||!!#!!#5'"25':;% r3   c                     | j                   S )z*Reimplementation to get a dynamic tooltip.)r   r/   s    r2   get_tooltipz#ApplicationUpdateStatus.get_tooltipu   s    ||r3   c                 ,    t        j                  d      S )Nspyder_about)r   iconr@   s    r2   get_iconz ApplicationUpdateStatus.get_icony   s    xx''r3   c                 :    | j                   j                  |       y N)r   start_installationr/   latest_releases     r2   rH   z*ApplicationUpdateStatus.start_installation|   s    )).9r3   c                 p    d}|dkD  rt        ||z  dz        }| j                  j                  | d       y )Nr   d   %)roundr!   setText)r/   current_valuetotalpercentage_progresss       r2   r+   z-ApplicationUpdateStatus.set_download_progress   sA    19"'u)<(C"D""&9%:!#<=r3   c                 d    | j                  t               | j                  j                  |       y rG   )r-   r   r   save_latest_releaserI   s     r2   set_status_pendingz*ApplicationUpdateStatus.set_status_pending   s     w**>:r3   c                     | j                  t               | j                  j                          | j                  j	                          y rG   )r-   r   r5   r8   r9   r@   s    r2   set_status_checkingz+ApplicationUpdateStatus.set_status_checking   s.    x r3   c                     | j                  t               | j                  j                          | j                  j	                          y rG   )r-   r   r5   r6   r7   r@   s    r2   set_no_statusz%ApplicationUpdateStatus.set_no_status   s.    y!r3   c                 :   | j                   j                  d      d   j                         }| j                  | j                  k(  s8|t
        k(  s/t               s
t               r| j                  j                          y	|t
        k(  r/t               s
t               r| j                  j                          y	|t        k(  r| j                  j                          t        | t        d      | j                   j"                        }t%        | j                  |g       | j'                         }t(        j*                  dk(  rdnd}| j-                  |j/                         t1        d|j3                          |z
        z         }| j                  j5                  |       y	y	)
z!Show installation dialog or menu.:zCheck for updates...)text	triggerednt      iN)r>   splitstripr   r   r   r   r   r   r8   continue_installationr   r    clearr   r	   sig_check_for_updates_requestedemitr   contentsRectosnamemapToGlobaltopLeftr   heightpopup)r/   r>   check_for_updates_actionrect	os_heightposs         r2   r)   z8ApplicationUpdateStatus.show_installation_dialog_or_menu   s5    

  %b)//1!2!22W$\%7%9NN!w|13NN002iIIOO'4-.>>CC($
 		$<#=>$$&DWW_"I""dkkm^i-G!HHJCIIOOC   r3   )__name__
__module____qualname____doc__r	   r   IDr   rf   strr.   r   CUSTOM_WIDGET_CLASSr   r-   rA   rE   rH   r+   rU   rW   rY   r   r)   __classcell__)r1   s   @r2   r   r   "   s    :01L	$B&,h# &,C[" !16 !D(:>;

 
V! !r3   r   )"rv   loggingri   qtpy.QtCorer   r   r   r   qtpy.QtWidgetsr   r   spyder.api.translationsr	   spyder.api.widgets.statusr
   spyder.config.baser   r   *spyder.plugins.application.widgets.installr   r   r   r   r   r   spyder.utils.icon_managerr   spyder.utils.qthelpersr   r   	getLoggerrs   r<   r    r3   r2   <module>r      s\   
  	 1 0 ( & 5 =  * = 
		8	$H!o H!r3   