3
N ŸZž  ã               @   s`   d dl T ddlT d dlmZ d dlmZ d dlT d dlT d dlT d Z	dZ
dZG dd„ deƒZdS )	é    )Ú*é   )Údevice)Ú
to_unicodeé   c               @   sj   e Zd Zeƒ Zeƒ Zeeƒ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 )ÚDeviceUriComboBoxc             C   sX   t j| |ƒ d| _d | _d| _t| _d | _d | _t	ƒ | _
| j
jƒ  | j
jƒ  | jƒ  d S )NÚ F)ÚQWidgetÚ__init__Ú
device_uriÚinitial_deviceÚupdatingÚ#DEVICEURICOMBOBOX_TYPE_PRINTER_ONLYÚtypÚfilterÚdevicesZUserSettingsÚuser_settingsÚloadÚdebugÚinitUi)ÚselfÚparent© r   ú)/usr/share/hplip/ui5/deviceuricombobox.pyr
   -   s    

zDeviceUriComboBox.__init__c             C   sÞ   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ƒ d S )NÚ
HBoxLayoutÚ	NameLabelé   r   ÚComboBoxzDevice:zconst QString &)ZQHBoxLayoutZsetObjectNameZQLabelr   Z	addWidgetZQSpacerItemZQSizePolicyZMinimumZaddItemZ	QComboBoxr   Z	ExpandingZ	PreferredZsetHorizontalStretchZsetVerticalStretchZsetHeightForWidthÚ
sizePolicyZhasHeightForWidthZsetSizePolicyÚsetTextÚ_DeviceUriComboBox__trZcurrentIndexChangedZconnectÚComboBox_currentIndexChanged)r   r   Z
SpacerItemr   r   r   r   r   =   s"    





zDeviceUriComboBox.initUic             C   s   |t ttfkr|| _d S )N)r   ÚDEVICEURICOMBOBOX_TYPE_FAX_ONLYÚ&DEVICEURICOMBOBOX_TYPE_PRINTER_AND_FAXr   )r   r   r   r   r   ÚsetTypeZ   s    zDeviceUriComboBox.setTypec             C   s
   || _ d S )N)r   )r   r   r   r   r   Ú	setFiltera   s    zDeviceUriComboBox.setFilterc             C   s
   || _ d S )N)r   )r   r   r   r   r   ÚsetInitialDevicee   s    z"DeviceUriComboBox.setInitialDevicec             C   sX   | j tkrdg}n,| j tkr6dg}| jj| jdƒƒ nddg}tj|| jƒ| _	t
| j	ƒS )NZhpZhpfaxzFax Device:)r   r   r"   r   r   r    r   ZgetSupportedCUPSDevicesr   r   Úlen)r   Z	be_filterr   r   r   Ú
setDevicesi   s    

zDeviceUriComboBox.setDevicesc             C   sÎ   | j d kr| jƒ  i | _| j rÀ| jd kr2| jj| _d| _zXd}xBt| j ƒD ]4\}}| jj	||ƒ | jd k	rJ|| jkrJd | _|}qJW | jj
dƒ W d d| _X | jj
|ƒ t| j ƒdkrÊ| jjƒ  n
| jjƒ  d S )NTr   r   Féÿÿÿÿ)r   r(   Zdevice_indexr   r   Úlast_used_device_urir   Ú	enumerater   Z
insertItemZsetCurrentIndexr'   ÚDeviceUriComboBox_oneDeviceÚemitÚDeviceUriComboBox_noDevices)r   ÚkÚiÚdr   r   r   ÚupdateUix   s(    


zDeviceUriComboBox.updateUic             C   s@   | j r
d S t|ƒ| _| jr<| j| j_| jjƒ  | jj| jƒ d S )N)r   r   r   r   r*   ZsaveÚ DeviceUriComboBox_currentChangedr-   )r   Útr   r   r   r!   ›   s    


z.DeviceUriComboBox.ComboBox_currentIndexChangedNc             C   s   t jd||ƒS )Nr   )ZqAppÚ	translate)r   ÚsÚcr   r   r   Z__tr¨   s    zDeviceUriComboBox.__tr)N)Ú__name__Ú
__module__Ú__qualname__Z
pyqtSignalr,   r.   Ústrr3   r
   r   r$   r%   r&   r(   r2   r!   r    r   r   r   r   r   )   s   #r   N)Zbase.gZui_utilsÚbaser   Zbase.sixextr   ZPyQt5.QtCoreZPyQt5.QtGuiZPyQt5.QtWidgetsr   r"   r#   r	   r   r   r   r   r   Ú<module>   s   