a
     ³Šay  ã                   @   sD   d Z ddlmZmZmZ ddlmZ ddlmZ G dd„ deƒZ	dS )z,Spyder completion plugin configuration page.é    )Ú	QGroupBoxÚQVBoxLayoutÚQGridLayout)Ú_)ÚPluginConfigPagec                       s0   e Zd Zg f‡ fdd„	Zdd„ Zdd„ Z‡  ZS )ÚCompletionConfigPagec                    s   t ƒ  ||¡ || _d S ©N)ÚsuperÚ__init__Ú	providers)ÚselfZpluginÚparentr   ©Ú	__class__© úAlib/python3.9/site-packages/spyder/plugins/completion/confpage.pyr
      s    zCompletionConfigPage.__init__c              
      sÂ  | j }ttdƒƒ}tƒ }|tdƒdƒ| _| | j¡ | |¡ | jj | j	¡ g | _
tƒ }ttdƒƒ| _t| jƒD ]B\}\}}|tdƒ |¡d|fdd}| ||d	¡ | j
 |¡ qr| j |¡ | jtd
ƒd dd	ddtdƒd}	|tdƒddd}
|tdƒddd}| jtdƒd dddtdƒdd‰ |tdƒdƒ}|tdƒdƒ}| jtdƒd d d	ddtd!ƒdd"}| jtd#ƒd d$d	ddtd%ƒdd"}ttd&ƒƒ| _tƒ }| |
d	d	¡ | |dd	¡ | |d'd	¡ | |d(d	¡ | ˆ jd)d	¡ | ˆ jd)d¡ | |jd*d	¡ | |jd*d¡ | |jd+d	¡ | |jd+d¡ | |	jd,d	¡ | |	jd,d¡ | d'd+¡ | j |¡ ‡ fd-d.„}|j |¡ tƒ }| |¡ | | j¡ | | j¡ | d¡ |  |¡ d S )/NzPlugin statusz0Enable code completion and linting in the editorÚenableZ	ProviderszEnable {0} providerZenabled_providersT)Údefaultr   z.Time to wait for all providers to return (ms):Úcompletions_wait_for_msi'  é
   zABeyond this timeout the first available provider will be returned)Úmin_Úmax_ÚstepÚtipzShow completion detailsZcompletions_hintZeditor)ÚsectionzShow completions on the flyZautomatic_completionsz4Show automatic completions after characters entered:Z!automatic_completions_after_charsé   zDefault is 3)r   r   r   r   zEnable code snippetsZenable_code_snippetszHNotify me when Kite can provide missing completions (but is unavailable)Zkite_call_to_actionz4Show automatic completions after keyboard idle (ms):Zautomatic_completions_after_mszDefault is 300 milliseconds)r   r   r   r   r   z1Show completion details after keyboard idle (ms):Zcompletions_hint_after_mszDefault is 500 millisecondsZCompletionsé   é   é   é   é   é   c                    s   ˆ j  | ¡ ˆ j | ¡ d S r   )ÚplabelÚ
setEnabledÚspinbox)Ústate©Zcompletions_after_charactersr   r   Ú#disable_completion_after_charactersc   s    zLCompletionConfigPage.setup_page.<locals>.disable_completion_after_characters)Zcreate_checkboxr   r   r   Zcompletion_boxZ	addWidgetZ	setLayoutZtoggledZconnectÚenable_disable_pluginZprovider_checkboxesr   Úproviders_groupÚ	enumerater   ÚformatÚappendZcreate_spinboxÚcompletions_groupr"   r$   ZsetColumnStretchZ
addStretch)r   ZnewcbZplugin_state_groupZplugin_state_layoutZproviders_layoutÚiZprovider_keyZprovider_nameÚcbr   Zcompletion_hint_boxZautomatic_completion_boxZcode_snippets_boxZkite_cta_boxZcompletions_after_idleZcompletions_hint_after_idleZcompletions_layoutr'   Zlayoutr   r&   r   Ú
setup_page   s¦    þ
ÿýýýýÿýýýÿ

zCompletionConfigPage.setup_pagec                 C   s\   | j  |¡ | j |¡ | jd urX| j ¡ }d}||k rX| j |¡}| |¡ |d7 }q0d S )Nr   )r)   r#   r-   ZtabsÚcountZwidget)r   r%   Znum_tabsÚindexZ
tab_widgetr   r   r   r(   q   s    


z*CompletionConfigPage.enable_disable_plugin)Ú__name__Ú
__module__Ú__qualname__r
   r0   r(   Ú__classcell__r   r   r   r   r      s   [r   N)
Ú__doc__Zqtpy.QtWidgetsr   r   r   Zspyder.config.baser   Zspyder.api.preferencesr   r   r   r   r   r   Ú<module>   s   