3
NZ]                 @   sv   d dl Z d dlZd dlZd dlT d dlmZmZmZmZ ddl	T d dl
T d dlT ddlmZ dZG dd deeZdS )	    N)*)deviceutilspkitos_utils   )	Ui_Dialogz>http://hplipopensource.com/hplip-web/install/manual/index.htmlc               @   sN   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dddZ
dS )UpgradeDialogc             C   s8   t j| | || _|| _d| _| j| || | j  d S )NF)QDialog__init__distro_tiermsgresultZsetupUiinitUi)selfparentr   r    r   %/usr/share/hplip/ui5/upgradedialog.pyr   +   s    zUpgradeDialog.__init__c             C   s   | j jj| j | jjj| j | jjt j| j	 | j
jt j| j | jjt j| j tjtjtj | jttdd d S )NZhp_logoZ128x128)
NextButtonZclickedZconnectNextButton_clickedZCancelButtonCancelButton_clickedinstallRadioBttonZtoggledboolinstallRadioBtton_toggledremindRadioBttonremindRadioBtton_toggleddontRemindRadioBttondontRemindRadioBtton_toggledsignalSIGINTSIG_DFLZsetWindowIconZQIconZload_pixmap)r   r   r   r   r   4   s    zUpgradeDialog.initUic             C   s&   |dkr| j jd n| j jd d S )NTF)r   
setChecked)r   radio_enabledr   r   r   r   B   s    z'UpgradeDialog.installRadioBtton_toggledc             C   s>   |dkr"| j jd | jjd n| j jd | jjd d S )NTF)r   r!   daysSpinBox
setEnabled)r   r"   r   r   r   r   I   s
    z&UpgradeDialog.remindRadioBtton_toggledc             C   s&   |dkr| j jd n| j jd d S )NTF)r   r!   )r   r"   r   r   r   r   R   s    z*UpgradeDialog.dontRemindRadioBtton_toggledc             C   s2  | j j r8tjd tjddd d}t| | j| n| jj rt	| j
j }tjdt|  tj t|d d d  }tjdd	t	t| ntjd
| j  | jjd | jdkrtjd tjt nTtj }|d k	otjdr|d }tj| d| _ntjd|  t| | jd | j  d S )Nz6HPLIP Upgrade, selected Don't remind again radiobuttonZupgradeZnotify_upgradeZfalsez^Check for HPLIP updates is disabled. To enable it again, change 'Settings' in 'HP systemtray' z:HPLIP Upgrade, selected remind later radiobutton  days= %d   <   Zpending_upgrade_timez;HPLIP Upgrade, selected Install radiobutton  distro_type=%dFr   z$OK pressed for tier 2 distro pressedz
hp-upgradez 'hp-upgrade -w'Tz3Failed to run hp-upgrade command from terminal =%s zFailed to run hp-upgrade)r   Z	isCheckedlogdebugZ	user_confsetZ	SuccessUI_UpgradeDialog__trr   strr#   valueinttimer   r   r$   r   ZopenURLMANUAL_INSTALL_LINKZget_terminalZwhichr   Zexecuter   errorZ	FailureUIclose)r   r   Zschedule_daysZ	next_timeZterminal_cmdcmdr   r   r   r   Y   s.    





z UpgradeDialog.NextButton_clickedc             C   s   t jd | j  d S )Nz	User exit)r'   r(   r1   )r   r   r   r   r   z   s    
z"UpgradeDialog.CancelButton_clickedNc             C   s   t jd||S )Nr	   )ZqApp	translate)r   scr   r   r   Z__tr~   s    zUpgradeDialog.__tr)N)__name__
__module____qualname__r   r   r   r   r   r   r   r*   r   r   r   r   r	   *   s   		!r	   )osr.   r   Zbase.gbaser   r   r   r   Zui_utilsZPyQt5.QtCoreZPyQt5.QtGuiZupgradedialog_baser   r/   r
   r	   r   r   r   r   <module>   s   