
    =	f                     p    d dl  ddl d dlmZ d dlmZ d dl d dl d dl d Z	dZ
dZ G d de      Zy)	    )*   )device)
to_unicode   c                   p    e Zd Z e       Z e       Z ee      Zd Zd Z	d Z
d Zd Zd Zd Zd Zdd
Zy	)DeviceUriComboBoxc                 2   t         j                  | |       d| _        d | _        d| _        t
        | _        d | _        d | _        t               | _
        | j                  j                          | j                  j                          | j                          y )N F)QWidget__init__
device_uriinitial_deviceupdating#DEVICEURICOMBOBOX_TYPE_PRINTER_ONLYtypfilterdevicesUserSettingsuser_settingsloaddebuginitUi)selfparents     )/usr/share/hplip/ui5/deviceuricombobox.pyr   zDeviceUriComboBox.__init__-   st    v&"6)^!  "    c                    t        |       }|j                  d       t        |       | _        | j                  j                  d       |j	                  | j                         t        ddt        j                  t        j                        }|j                  |       t        |       | _
        t        t        j                  t        j                        }|j                  d       |j                  d       |j                  | j                  j!                         j#                                | j                  j%                  |       | j                  j                  d       |j	                  | j                         | j                  j'                  | j)                  d             | j                  j*                  d   j-                  | j.                         y )N
HBoxLayout	NameLabel   r   ComboBoxzDevice:zconst QString &)QHBoxLayoutsetObjectNameQLabelr    	addWidgetQSpacerItemQSizePolicyMinimumaddItem	QComboBoxr"   	Expanding	PreferredsetHorizontalStretchsetVerticalStretchsetHeightForWidth
sizePolicyhasHeightForWidthsetSizePolicysetText_DeviceUriComboBox__trcurrentIndexChangedconnectComboBox_currentIndexChanged)r   r   
SpacerItemr1   s       r   r   zDeviceUriComboBox.initUi=   sM    &
  .$$[1T^^, R)<)<k>Q>QR
:&!$ !6!68M8MN
''*%%a($$T]]%=%=%?%Q%Q%ST##J/##J/T]]+tyy34 	))*;<DDTEfEfgr   c                 :    |t         t        t        fv r|| _        y y N)r   DEVICEURICOMBOBOX_TYPE_FAX_ONLY&DEVICEURICOMBOBOX_TYPE_PRINTER_AND_FAXr   )r   r   s     r   setTypezDeviceUriComboBox.setTypeZ   s&    629; ; DH;r   c                     || _         y r;   )r   )r   r   s     r   	setFilterzDeviceUriComboBox.setFiltera   s	    r   c                     || _         y r;   )r   )r   r   s     r   setInitialDevicez"DeviceUriComboBox.setInitialDevicee   s
    (r   c                 .   | j                   t        k(  rdg}nE| j                   t        k(  r.dg}| j                  j	                  | j                  d             nddg}t        j                  || j                        | _	        t        | j                        S )NhphpfaxzFax Device:)r   r   r<   r    r4   r5   r   getSupportedCUPSDevicesr   r   len)r   	be_filters     r   
setDeviceszDeviceUriComboBox.setDevicesi   sw    88::IXX88 	INN""499]#;< wI55iM4<<  r   c                    | j                   | j                          i | _        | j                   r| j                  | j                  j
                  | _        d| _        	 d}t        | j                         D ]G  \  }}| j                  j                  ||       | j                  /|| j                  k(  s?d | _        |}I | j                  j                  d       d| _        | j                  j                  |       t        | j                         dk(  r| j                  j                          y y | j                  j                          y # d| _        w xY w)NTr   Fr   )r   rI   device_indexr   r   last_used_device_urir   	enumerater"   
insertItemsetCurrentIndexrG   DeviceUriComboBox_oneDeviceemitDeviceUriComboBox_noDevices)r   kids       r   updateUizDeviceUriComboBox.updateUix   s    <<OO<<""*&*&8&8&M&M# DM&%dll3 DAqMM,,Q2**61@S@S;S.2+ --b1 %MM))!,4<< A%00557 & ,,113 !&s    AE &E 6&E 	Ec                    | j                   ry t        |      | _        | j                  r[| j                  | j                  _        | j                  j                          | j                  j                  | j                         y y r;   )r   r   r   r   rM   save DeviceUriComboBox_currentChangedrR   )r   ts     r   r8   z.DeviceUriComboBox.ComboBox_currentIndexChanged   sa    ==$Q-??6:ooD3##% 1166tG r   Nc                 0    t         j                  d||      S )Nr	   )qApp	translate)r   scs      r   __trzDeviceUriComboBox.__tr   s    ~~1!A66r   r;   )__name__
__module____qualname__
pyqtSignalrQ   rS   strrZ   r   r   r>   r@   rB   rI   rW   r8   r5    r   r   r	   r	   )   sL    ",,",,'1#$ h:)!!4FH7r   r	   N)base.gui_utilsbaser   base.sixextr   PyQt5.QtCorePyQt5.QtGuiPyQt5.QtWidgetsr   r<   r=   r   r	   rg   r   r   <module>ro      s@   2    #    '( #"# )* &@7 @7r   