Sindbad~EG File Manager

Current Path : /usr/share/hplip/ui5/__pycache__/
Upload File :
Current File : //usr/share/hplip/ui5/__pycache__/fabwindow.cpython-310.pyc

o

�/�a�^�@s�ddlTddlTddlmZmZddlTddlTddlmZdZ	zddl
m
Z
Wney8e�
d�dZ	YnwGd	d
�d
ee�ZGdd�de�Zd
S)�)�*�)�
to_unicode�from_unicode_to_str)�
Ui_MainWindowT)�faxz1Fax address book disabled - Python 2.3+ required.Fc@s
eZdZeeegeeeg�Ze�Zdd�Zdd�Z	dd�Z
dd�Zd	d
�Zdd�Z
d
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd;d,d-�Zd.d/�Zd0d1�Zd2d3�Z d4d5�Z!d6d7�Z"d<d9d:�Z#d8S)=�	FABWindowcCspt�||�|�|�td�|_d|_d|_d|_t�|_	|j	�
�|j	��|��|�
�t�d|j�dS)N�AllFr)�QMainWindow�__init__�setupUir�group�name�updating_group�
updating_name�UserSettings�
user_settings�load�debug�initDB�initUi�QTimer�
singleShot�updateUi)�self�parent�r�!/usr/share/hplip/ui5/fabwindow.pyr3s



zFABWindow.__init__c	Cszt��|_|j��}|D]}td�||dvr#||d�td��q|s;|j�dt��ddddtd�gd�dSdS)Nr	�groups�__�)	r�FaxAddressBook�db�get_all_recordsr�append�set�utils�gen_random_uuid)r�data�drrrrEs

�*�zFABWindow.initDBcCsT|�ttdd���|j�ttdd���|j�ttdd���|j�ttdd���|j�ttdd���|j�ttdd���|j	�ttd	d���|j
�ttd
d���|j�ttdd���|jj
�|j�|jj
�|j�|jj
�|j�|jj
�|j�|jj
�|j�|jj
�|j�|j	j
�|j�|jj
�|j�|jj
�|j�|j
j
�|j�|j�tj�|j�tj�|jj t!t!f�|j"�|j�#d�|j�$|j�%�d
�|j�&��'�|j�(d�|j�)t*j+�|j�&��'�|j�(d�|j�,d�|j�-d�|j�.d�|jj/�|j0�|jj/�|j1�|j2j3�|j4�|j5j3�|j6�|j7j8�|j9�|jj:�|j;�|j5�<t=|j5��|j2�<t>|j?|j2��|j�@tjA�|j�B|j�|j�B|j�|j�B|j�|j�B|j�|j�@tjA�|j�B|j�|j�B|j
�|j�B|j�|j�B|j	�|j�B|j�|j�C|j?�dS)N�hp_logo�128x128�	new_group�24x24�new_group_from_selection�rename_group�remove_group�new_user�remove_user�add_to_group�remove_from_groupF�T)D�
setWindowIcon�QIcon�load_pixmap�NewGroupAction�setIcon�NewGroupFromSelectionAction�RenameGroupAction�RemoveGroupAction�
NewNameAction�RemoveNameAction�AddToGroupAction�RemoveFromGroupAction�
QuitAction�	triggered�connect�close�NewGroupAction_triggered�%NewGroupFromSelectionAction_triggered�RenameGroupAction_triggered�RemoveGroupAction_triggered�NewNameAction_triggered�RemoveNameAction_triggered�ImportAction�ImportAction_triggered�RemoveFromGroupAction_triggered�AddToGroupAction_triggered�GroupTableWidget�setHorizontalScrollBarPolicy�Qt�ScrollBarAlwaysOff�NameTableWidget�Splitter�
splitterMoved�int�Splitter_splitterMoved�setChildrenCollapsible�setHandleWidth�handleWidth�verticalHeader�hide�setShowGrid�setSelectionMode�QAbstractItemView�SingleSelection�setDragEnabled�setAcceptDrops�setDropIndicatorShown�itemSelectionChanged�%GroupTableWidget_itemSelectionChanged�$NameTableWidget_itemSelectionChanged�NameLineEdit�editingFinished�NameLineEdit_editingFinished�FaxNumberLineEdit�!FaxNumberLineEdit_editingFinished�
NotesTextEdit�textChanged�NotesTextEdit_textChanged�namesAddedToGroup�"GroupTableWidget_namesAddedToGroup�setValidator�PhoneNumValidator�AddressBookNameValidatorr"�setContextMenuPolicy�ActionsContextMenu�	addAction�setDatabase�rrrrrRshzFABWindow.initUicCs<tst||�d��|��dS|��|��|��dS)Nz?<b>Fax support disabled.</b><p>Fax support requires Python 2.3.)�	fax_avail�	FailureUI�_FABWindow__trrE�updateGroupList�updateNameList�updateDetailsFrameryrrrr�szFABWindow.updateUicCs|jj��|��dS�N)rkri�emit�accept)r�errr�
closeEvent�szFABWindow.closeEventcCs,|j�d|j���|j�d|j���dS�Nr)rP�setColumnWidth�widthrT)r�pos�indexrrrrX�sz FABWindow.Splitter_splitterMovedc	Cs�d|_d\}}z�t�}|�|�d��|j��|j�d�|j�d|�|j�d|j�	��|j
��}|��|j�
t|��t|�d��}|�tjtjB�|j�dd|�d}|D]:}|td�kreq\t|t�rqtt|��}ntt|��}||jkr~|}|�tjtjBtjB�|j�|d|�|d7}q\Wd|_|dur�|�d�dS|dur�|�d�dSdSd|_|dur�|�d�w|dur�|�d�ww)NT�NN�Grouprrr	F)r�QTableWidgetItem�setTextr|rP�clear�setColumnCount�setHorizontalHeaderItemr�r�r"�get_all_groups�sort�setRowCount�len�setFlagsrR�ItemIsSelectable�
ItemIsEnabled�setItemr�
isinstancerW�strrr
�ItemIsDropEnabled�setSelected)r�all�k�
headerItemr�j�g�irrrr}�sP




����zFABWindow.updateGroupListcCs�|js?|j��}|r*t|d���|_|j�|jtd�k�|j�|jtd�k�n|j�d�|j�d�d|_|�	�dSdS)Nrr	F)
rrP�
selectedItemsr�textr
r=�
setEnabledr<r~)r�selected_itemsrrrrf�s
�z/FABWindow.GroupTableWidget_itemSelectionChangedcCs�|js}|j��}t|�}|dkr,d|_|j�d�|j�d�|j�d�|j	�d�nK|dkrWt
|d���|_|j�d�|j�d�|j�|jt
d�k�|j	�d�n |j�d�|j�d�|j�|jt
d�k�|j	�d�d|_|�
�dSdS)NrFrTr	)rrTr�r�rr?r�r;rAr@rr�r
r)rr��num_selected_itemsrrrrg�s,
�z.FABWindow.NameTableWidget_itemSelectionChangedc		Cs�d|_d\}}z�t�}|�|�d��|j��|j�d�|j�d|�|j�d|j�	��|j
�|j�}dd�|D�}|�
�|j�t|��t|�D]7\}}t|t�r]tt|��}ntt|��}|�tjtjBtjB�|j�|d|�||jkr~|}|dkr�|}qMWd|_|dur�|�d�dS|dur�|�d�dSd|_|j�d�|j�d�|j �d�|j!�d�|�"�dSd|_|dur�|�d�w|dur�|�d�wd|_|j�d�|j�d�|j �d�|j!�d�|�"�w)	NTr��NamerrcSsg|]	}|�d�s|�qS)r)�
startswith��.0�nrrr�
<listcomp>sz,FABWindow.updateNameList.<locals>.<listcomp>F)#rr�r�r|rTr�r�r�r�r�r"�
group_membersr
r�r�r��	enumerater�rWr�rr�rRr�r��ItemIsDragEnabledr�rr�r?r�r;rAr@r)	r�mr�r��names�filtered_namesr�r�r�rrrr~s^


���
zFABWindow.updateNameListcCs@|j��}t|�D]}|j�|d�}|�|t|���k�q	dSr�)rT�rowCount�range�itemr�rr�)rr�rows�rr�rrr�selectByName@s

�zFABWindow.selectByNamecCs�|jdur"|j�d�|j�t��|j�t��|j�t��dS|j�d�|j�	|j�}|j�|j�|j�|d�|j�|d�dS)NFTr�notes)
r�	NameFramer�rhr�r�rkrmr"�get)rr(rrrrGs
zFABWindow.updateDetailsFramecCs�|jdurYt|j���}||jkr[t�||�d�d|j|ftjtjBtj�tjkrP|j	�
|j|�t�d|j|f�|j
tttf�t|j|�|��dS|j�|j�dSdSdS)NzRename?zRename '%s' to '%s'?zRename %s to %s)rrrhr��QMessageBox�questionr|�Yes�Nor"�rename�logr�databaseChangedrWr�r��FAB_NAME_RENAMEr~r�)r�new_namerrrrjVs

���z&FABWindow.NameLineEdit_editingFinishedcCs>|jdur|j�|jdt|j����|j�t|j�dSdS)Nr)	rr"�
set_key_valuerrkr�r�r��FAB_NAME_DETAILS_CHANGEDryrrrrles
�z+FABWindow.FaxNumberLineEdit_editingFinishedcCs2|jdur|j�|jdt|j������dSdS)Nr�)rr"r�rrm�document�toPlainTextryrrrroks
$�z#FABWindow.NotesTextEdit_textChangedcCs"|jdur|j�t|j�dSdSr�)rr�r�r�ryrrr�NotesTextEdit_editingFinishedps
�z'FABWindow.NotesTextEdit_editingFinishedc	Cs�d}t�||�d�|�d��\}}t|�}|td�kr%t||�d��d}|rT|j�dt��ddddtd�|gd�||_	t
�d|j	�|j�
t|j	�|��dSdS)	NF�Enter New Group Name�Name for New Group:r	zO<b>Sorry, the group name cannot be 'All'.</b><p>Please choose a different name.rr zNew empty group %s)�QInputDialog�getTextr|rr{r"r%r&r'r
r�rr�r��
FAB_GROUP_ADDr})r�okr�rrrrFus(�z"FABWindow.NewGroupAction_triggeredcCs�dd�|j��D�}|r[d}t�||�d�|�d��\}}t|�}|j��}||vr4t||�d��d}|r]|j�	||�||_
t�d|j
d�
|�f�|j�t|j
�|��dSdSdS)	NcS�g|]}t|����qSr�rr�r�rrrr���zCFABWindow.NewGroupFromSelectionAction_triggered.<locals>.<listcomp>Fr�r��r<b>Sorry, the group name cannot be the same as an existing group (or 'All').</b><p>Please choose a different name.zNew group %s with names %s�,)rTr�r�r�r|rr"r�r{�
update_groupsr
r�r�joinr�r�r�r})r�selected_namesr�r�rrrrrG�s"
�z/FABWindow.NewGroupFromSelectionAction_triggeredcCs�|j��}|r^t|d���}d}t�||�d�d|�\}}t|�}|j��}||vr6t	||�d��d}|r`|j�
||�t�d||f�|j
tttf�t||�||_|��dSdSdS)NrFzRename GroupzNew Name for Group '%s':r�zRename group %s to %s)rPr�rr�r�r�r|r"r�r{r/r�rr�rWr�r��FAB_GROUP_RENAMEr
r})rr��	old_groupr�r,rrrrrH�s$

�z%FABWindow.RenameGroupAction_triggeredcCs@|j�|j�t�d|j�|j�t|j�d|_|��dS)NzRemove group %s)	r"�delete_groupr
r�rr�r��FAB_GROUP_REMOVEr}ryrrrrI�s
z%FABWindow.RemoveGroupAction_triggeredcCs@d}t�||�d�|�d��\}}|rt|�}|�|�dSdS)NFzEnter New Namez	New Name:)r�r�r|r�addName)rr��trrrrJ�s�z!FABWindow.NewNameAction_triggeredr c	Csr|jtd�kr
td�g}ntd�|jg}|j�|ddd||d�||_t�d|j�|j�t	|j�|�
�dS)Nr	r zNew name %s)r
rr"r%rr�rr�r��FAB_NAME_ADDr~)rrrr�rrrr��szFABWindow.addNamecCs`dd�|j��D�}|r.|D]}|j�|�t�d|�|j�t|�qd|_	|�
�dSdS)NcSr�rr�r�rrrr��r�z8FABWindow.RemoveNameAction_triggered.<locals>.<listcomp>zRemoving name %s)rTr�r"�deleter�rr�r��FAB_NAME_REMOVErr~)rr�r�rrrrK�s�z$FABWindow.RemoveNameAction_triggeredcCshdd�|j��D�}|r2t�dd�|�|jf�|j�|j|�|j�	t
|j�d|_|��dSdS)NcSr�r)r�r�r�rrrr��r�z=FABWindow.RemoveFromGroupAction_triggered.<locals>.<listcomp>z%s leaving group %sr�)
rTr�r�rr�r
r"r4r�r��FAB_GROUP_MEMBERSHIP_CHANGEDrr})rr�rrrrN�s�z)FABWindow.RemoveFromGroupAction_triggeredcCs^t|j�|d����|_|j�|j|�t�dd�	|�|jf�|j
�t|j�|�
�dS)Nr�Adding %s to group %sr�)rrPr�r�r
r"r3r�rr�r�r�r�r})r�row�itemsrrrrq�s
z,FABWindow.GroupTableWidget_namesAddedToGroupcCs�dd�|j��D�}|rdd}|j��}|rZdd�|D�}|��t||�}|��tjkrV|j	}|rX|j�
||�||_	t�dd�
|�|j	f�|j�t|j	�|��dSdSdSt||�d��dSdS)NcSr�rr�r�rrrr��r�z8FABWindow.AddToGroupAction_triggered.<locals>.<listcomp>FcSsg|]
}|td�kr|�qS)r	)r)r�r�rrrr��sr�r�zt<b>There are no groups to join.</b><p>Use <i>New Group from Selection</i> to create a new group using these name(s).)rTr�r"r�r��
JoinDialog�exec_�QDialog�Acceptedr
r3r�rr�r�r�r�r}r{r|)rr�r��
all_groups�dlgr
rrrrO�s(

��z$FABWindow.AddToGroupAction_triggeredcCs�tt�||�d�|jjd��}|rPttj�	|��}t
�d|�||j_|j��|rR|�
d�r9|j�|�\}}n|j�|�\}}|sJt||�dS|��dSdSdS)Nz'Import fax addresses from LDIF or vCardz"vCard (*.vcf);;LDIF (*.ldif *.ldi)z
result: %sz.vcf)r��QFileDialog�getOpenFileNamer|r�working_dirr�os�path�dirnamer�r�save�endswithr"�import_vcard�import_ldifr{r)r�result�working_directoryr��	error_strrrrrMs&�

�z FABWindow.ImportAction_triggeredNcCst�d|�d�|�S)Nrzutf-8)�qApp�	translate�encode)r�s�crrr�__tr�zFABWindow.__tr)r r�)$�__name__�
__module__�__qualname__�
pyqtSignalrWr�r�rirrrrr�rXr}rfrgr~r�rrjrlror�rFrGrHrIrJr�rKrNrqrOrMr|rrrrr.s>
E
20


rc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
r�cCs t�||�d|_|�|�dS)Nr )r�rr
r)rrrrrrr&szJoinDialog.__init__cCs|�d�|�ttdddd�����|����t|�|_|j�d�t	�|_
|j
�d�t|�|_|j�d�|j
�
|j�t|�|_ttjtj�}|�d�|�d�|�|j�����|j�|�|j�d�|j
�
|j�|j�|j
ddd	d
�tddtjtj�}|j�|d	dd	d	�td
dtjtj�}|j�|ddd	d	�t|�|_|j�d�|j�
|jdd	d	d	�t|�|_|j�d�|j�
|jddd	d	�|jj t!�"|j#�t$|�D]\}}|dkr�||_%|j�&||�q�|jj'�"|j(�|jj'�"|j)�|�*�dS)N�Dialogri�k�
gridlayout�
hboxlayout�label�comboBoxr���(��r5�pushButton_2�
pushButton)+�
setObjectName�resize�QSize�QRect�size�
expandedTo�minimumSizeHint�QGridLayoutr�QHBoxLayoutr�QLabelr�	addWidget�	QComboBox�GroupJoinComboBox�QSizePolicy�	Expanding�Fixed�setHorizontalStretch�setVerticalStretch�setHeightForWidth�
sizePolicy�hasHeightForWidth�
setSizePolicy�	addLayout�QSpacerItem�Minimum�addItem�QPushButton�
JoinButton�CancelButton�currentIndexChangedrWrD�%GroupJoinComboBox_currentIndexChangedr�r
�
insertItem�clickedr��reject�
retranslateUi)rrr#�
spacerItem�spacerItem1r�r�rrrr,sH
&






zJoinDialog.setupUicCst|j���|_dSr�)rr�currentTextr
)rr�rrrr.`r�z0JoinDialog.GroupJoinComboBox_currentIndexChangedcCsj|�t�dddtj��|j�t�dddtj��|j�t�dddtj��|j�t�dddtj��dS)Nrz
Join GroupzGroup to Join:�Join�Cancel)�setWindowTitle�QApplicationr��UnicodeUTF8rr�r+r,ryrrrr2dszJoinDialog.retranslateUiN)rrrrrr.r2rrrrr�%s
4r�N)�base.g�ui_utils�base.sixextrr�PyQt5.QtCore�PyQt5.QtGui�fabwindow_baserrzr�ImportErrorr��errorr
rr�r�rrrr�<module>s$
�z

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists