3
NZ(                 @   s   d dl Zd dlT d dlmZ d dlmZ d dlT d dlm	Z	 ddl
T d dlT d dlT ddlmZ ddlmZ G d	d
 d
eeZdS )    N)*)device)cups)
to_unicode   )	Ui_Dialog)&DEVICEURICOMBOBOX_TYPE_PRINTER_AND_FAXc               @   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 )
InfoDialogc             C   s6   t j| | || _| j|  | j  tjd| j d S )Nr   )QDialog__init__
device_uriZsetupUiinitUiZQTimerZ
singleShotupdateUi)selfparentr    r   "/usr/share/hplip/ui5/infodialog.pyr   +   s
    
zInfoDialog.__init__c             C   s   | j jj| j | jjj| j | jjj| j | jtt	dd | j
rX| jj| j
 | jjt | jd| jdg| _| jdd | jd| jd| jd| jd	| jd
g| _d S )NZhp_logoZ128x128ZKeyZValuez	Date/Timez
Event CodeZDescriptionZUserzCUPS Job IDz
Doc. Title)ZCancelButtonZclickedZconnectCancelButton_clickedDeviceComboBoxDeviceUriComboBox_noDevices DeviceUriComboBox_currentChangedZsetWindowIconZQIconZload_pixmapr   ZsetInitialDeviceZsetTyper   _InfoDialog__trheadershistory_headers)r   r   r   r   r   5   s    
zInfoDialog.initUic             C   s   | j j  d S )N)r   r   )r   r   r   r   r   J   s    zInfoDialog.updateUic          0   C   sP  t jttj | jj  | jjd | jjd tj	tj
B }x| jj dkr\| jjd q@W | jj  | jjd | jjt| j | jj| j ytj| jd }W n2 tk
r   t j  t| | jd| j  d S X | jj  | jjt| j | jj| j t|jj }|j  | jjt| xht|D ]\\}}tt|}|j | | jj!|d| tt|j| }|j | | jj!|d| q4W | jj"d | jj"d | jj#d | jj$d zy|j%  |j&  W n@ tk
r } z"t j  t| | jd| j  d S d }~X nX t|j'j }|j  | jjt| xht|D ]\\}}tt|}|j | | jj!|d| tt|j'| }|j | | jj!|d| qNW | jj"d | jj"d | jj#d | jj$d W d |j(  X | j)j  | j)jd |j*t+kr | jd| j,d< n| jd| j,d< | j)jt| j, | j)j| j, |j- }	|	j.  | j)jt|	 xt|	D ]\}}
t/ }|j0t1|
j2 t3|}tj4|
j5d}x\t||
j6t7|
j5||
j8t7|
j9|
j:gD ]0\}}tt|}|j | | j)j!||| qW qzW | j)j"d | j)j"d | j)j#d | j)j$d t;j< }x|D ]}|j| jkrRt= }|j>t|j? t@|}|j>td|j?  tA|}|jBd |jCtDjE |jFtDjG |jHtDjI |jJtDjK |jLtjM |j>td	|j?  |jN|dddd | jjO|t|j? |jt| j |j| j t;jP  t;jQ|j? tRt;jS }yt%tTjUjVd
}W nF tWk
r } z(tXjYt| tdt| |d< W Y d d }~X nBX |jZ }x6|j[ D ]}|j?|kr||d< P qW | jd|d< t|j }|j  |jt| xt|D ]\}}tt|}|j | |j!|d| |dkrt1|| }|t;j\krt| jd| }nL|t;j]krt| jd| }n,|t;j^krt| jd| }ntt|}ntt|| }|j | |j!|d| q$W |j"d |j"d |j#d |j$d qRW t;j_  | jj`d t j  d S )Nr      z <b>Unable to open device %s.</b>r   TZFaxZPrinterzGridLayout-%szTable-%sz~/.cups/lpoptionsz(%s)Zlpoptions_file_dataz	(no data)zprinter-statez	idle (%s)zbusy/printing (%s)zstopped (%s))aZQApplicationZsetOverrideCursorZQCursorZQtZ
WaitCursorZDynamicTableWidgetclearZsetRowCountZsetColumnCountZItemIsSelectableZItemIsEnabledZ	TabWidgetcountZ	removeTablenr   ZsetHorizontalHeaderLabelsr   ZDevicer   ErrorZrestoreOverrideCursor	FailureUIr   ZStaticTableWidgetlistZmqkeyssort	enumerateZQTableWidgetItemstrZsetFlagsZsetItemZresizeColumnToContentsZsetSortingEnabledZ	sortItemsopenZqueryDeviceZdqcloseZHistoryTableWidgetZdevice_typeZDEVICE_TYPE_FAXr   ZqueryHistoryreverseZ	QDateTimeZ	setTime_tintZtimedateZ	value_strZqueryStringZ
event_codeZprinter_namer   ZusernameZjob_idtitler   ZgetPrintersZQWidgetZsetObjectNamenameZQGridLayoutZQTableWidgetZsetAlternatingRowColorsZsetSelectionModeZQAbstractItemViewZSingleSelectionZsetSelectionBehaviorZ
SelectRowsZsetVerticalScrollModeZScrollPerItemZsetHorizontalScrollModeZScrollPerPixelZsetGridStyleZDotLineZ	addWidgetZaddTabZresetOptionsZopenPPDdictZ
getOptionsospath
expanduserIOErrorlogdebugread
splitlinesZIPP_PRINTER_STATE_IDLEZIPP_PRINTER_STATE_PROCESSINGZIPP_PRINTER_STATE_STOPPEDZclosePPDZsetCurrentIndex)r   flagsdZmq_keysrowkeyieZdq_keyshistoryhZdtZesscoltZprinterspZTabZ
GridLayoutZTableZcurrent_optionsftextr!   stater   r   r   updateInfoTableO   s   












&





zInfoDialog.updateInfoTablec             C   s   || _ | j  d S )N)r   rB   )r   r   r   r   r   r   #  s    z+InfoDialog.DeviceUriComboBox_currentChangedc             C   s   t | | jd | j  d S )Nz<b>No devices found.</b>)r   r   r&   )r   r   r   r   r   (  s    z&InfoDialog.DeviceUriComboBox_noDevicesc             C   s   | j   d S )N)r&   )r   r   r   r   r   -  s    zInfoDialog.CancelButton_clickedNc             C   s   t jd||S )Nr	   )ZqApp	translate)r   scr   r   r   Z__tr4  s    zInfoDialog.__tr)N)__name__
__module____qualname__r   r   r   rB   r   r   r   r   r   r   r   r   r	   *   s   
 Ur	   )os.pathr,   Zbase.gbaser   Zprntr   Z
base.codesZbase.sixextr   Zui_utilsZPyQt5.QtCoreZPyQt5.QtGuiZinfodialog_baser   Zdeviceuricomboboxr   r
   r	   r   r   r   r   <module>   s   