3
N ŸZ  ã               @   sV   d dl T d dlmZ ddlT d dlT d dlT d dlZddlmZ G dd„ de	eƒZ
dS )é    )Ú*)Údeviceé   N)Ú	Ui_Dialogc               @   sV   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„ Z
ddd„ZdS )ÚPrintTestPageDialogc             C   s<   t j| |ƒ || _d| _| j| ƒ | jƒ  tjd| jƒ d S )NÚ r   )	ÚQDialogÚ__init__Úprinter_nameÚ
device_uriZsetupUiÚinitUiZQTimerZ
singleShotÚupdateUi)ÚselfÚparentr
   © r   ú+/usr/share/hplip/ui5/printtestpagedialog.pyr	   &   s    
zPrintTestPageDialog.__init__c             C   sš   | j jdƒ | jj| jdƒƒ | jjj| jƒ | j	jj| j
ƒ | jjj| jƒ | jjj| jƒ tjtjtjƒ | jr‚| jj| jƒ | jttddƒƒƒ d S )NTzPrint Test PageZhp_logoZ128x128)ZHPLIPTestPageRadioButtonZ
setCheckedÚ	LoadPaperZsetButtonNameÚ_PrintTestPageDialog__trZCancelButtonZclickedZconnectÚCancelButton_clickedÚPrintTestpageButtonÚPrintTestpageButton_clickedÚPrinterNameComboZ"PrinterNameComboBox_currentChangedÚPrinterNameCombo_currentChangedÚPrinterNameComboBox_noPrintersÚsignalÚSIGINTÚSIG_DFLr
   ZsetInitialPrinterZsetWindowIconZQIconZload_pixmap)r   r   r   r   r   1   s    zPrintTestPageDialog.initUic             C   s   | j jƒ  | jjƒ  d S )N)r   r   r   )r   r   r   r   r   G   s    
zPrintTestPageDialog.updateUic             C   s   t | | jdƒƒ | jƒ  d S )NzA<b>No printers found.</b><p>Please setup a printer and try again.)Ú	FailureUIr   Úclose)r   r   r   r   r   M   s    z2PrintTestPageDialog.PrinterNameComboBox_noPrintersc             C   sæ   t jttjƒƒ | jjdƒ d}z¶ytj| j	| j
ƒ}W n2 tk
rh } ztjd|j ƒ W Y d d }~X n6X y|jƒ  W n tk
r”   tjdƒ Y n
X |jƒ }| jj|ƒ |sÌt jƒ  t| | jd| j
 ƒƒ |jƒ  W d t jƒ  X d S )NFzDevice error (%s).z>Unable to print to printer. Please check device and try again.zW<b>Unable to communicate with printer %s.</b><p>Please check the printer and try again.)ÚQApplicationÚsetOverrideCursorÚQCursorÚQtÚ
WaitCursorr   Z
setEnabledr   ÚDevicer   r
   ÚErrorÚlogÚerrorÚmsgÚopenÚisIdleAndNoErrorÚrestoreOverrideCursorr   r   r   )r   ÚokÚdÚer   r   r   ÚupdatePrintButtonR   s&    "z%PrintTestPageDialog.updatePrintButtonc             C   s   | j ƒ  d S )N)r   )r   r   r   r   r   o   s    z(PrintTestPageDialog.CancelButton_clickedc             C   s   || _ || _| jƒ  d S )N)r
   r   r/   )r   r   r
   r   r   r   r   s   s    z3PrintTestPageDialog.PrinterNameCombo_currentChangedc              C   sü   t jttjƒƒ d}z€ytj| j| jƒ}W n2 t	k
r\ } zt
jd|j ƒ W Y d d }~X n6X y|jƒ  W n t	k
rˆ   t
jdƒ Y n
X |jƒ }W d t jƒ  X |rÚt jttjƒƒ z|j| jƒ W d t jƒ  X | jƒ  nt| | jd| j ƒƒ |jƒ  d S )NFzDevice error (%s).z>Unable to print to printer. Please check device and try again.ze<b>A error occured sending the test page to printer %s.</b><p>Please check the printer and try again.)r   r    r!   r"   r#   r   r$   r   r
   r%   r&   r'   r(   r)   r*   r+   ZprintTestPager   r   r   )r   r,   r-   r.   r   r   r   r   z   s*    "


z/PrintTestPageDialog.PrintTestpageButton_clickedNc             C   s   t jd||ƒS )Nr   )ZqAppÚ	translate)r   ÚsÚcr   r   r   Z__trœ   s    zPrintTestPageDialog.__tr)N)Ú__name__Ú
__module__Ú__qualname__r	   r   r   r   r/   r   r   r   r   r   r   r   r   r   %   s   "r   )Zbase.gÚbaser   Zui_utilsZPyQt5.QtCoreZPyQt5.QtGuir   Zprinttestpagedialog_baser   r   r   r   r   r   r   Ú<module>   s   