B
    nôb\  ã               @   sª   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
mZmZmZmZmZmZmZmZ ddlmZ ddlmZ d	Zd
ZG dd„ de
ƒZdd„ Zedkr¦eƒ  dS )zShortcut Summary dialogé    )Ú
itemgetter)Úgroupby)ÚQt)ÚQFont)	ÚQDialogÚQLabelÚQGridLayoutÚ	QGroupBoxÚQVBoxLayoutÚQHBoxLayoutÚQDesktopWidgetÚQScrollAreaÚQWidget)Ú_)Úiter_shortcutsé   é   c               @   s"   e Zd ZdZddd„Zdd„ ZdS )ÚShortcutsSummaryDialoga  
    Dialog window listing the spyder and plugins shortcuts.

    It contains all the shortcuts avalaible through iter_shortcuts
    function

    The shortcuts are dysplayed in different columns, and grouped by
    context (global, editor, console...)
    Nc             C   s´  t j| |d tdƒ| _|  ¡ \}}|d }tt|tƒtƒ}|d|  |d  }d}|  	|¡ t
ƒ }| |¡ | d¡ t
ƒ }| |¡ t
ƒ }	|	 |d ¡ |	 d¡ t| jƒ}
|
 tj¡ |
 |	¡ tƒ }d	}d }tttƒ ƒtd	ƒd
}x(|D ]\}}xt|ƒD ]\}\}}}|d	kr(tƒ }|d	krF|d	krF| |¡ |d	ksZ|d	kr–|dkrhd}t| ¡ ƒ}| |¡ tƒ }| |¡ |d7 }t| ¡  dd¡ƒ}| |¡ t|ƒ}| |¡ | ||d	¡ | ||d¡ |d7 }||kr| |¡ | |¡ d	}qW qòW | |¡ |  ¡  | |¡ t!ƒ | _"| j" |¡ t#ƒ | _$| j$ %| j"¡ |  &tj'¡ |  (d¡ tƒ | _)| j) |
¡ | j) | j$¡ |  | j)¡ |  *d	d	||¡ d S )N)ÚparentzSpyder Keyboard ShortCutséP   r   r   z{
            QDialog {
              margin:0px;
              padding:0px;
              border-radius: 2px;
            }Té   r   )Úkeyr   ZGlobalé   ú gffffffî?)+r   Ú__init__r   Z_shortcuts_summary_titleÚget_screen_resolutionÚmaxÚminÚMAX_FONT_SIZEÚMIN_FONT_SIZEZsetStyleSheetr   ZsetPointSizeZsetBoldr   ZsetAlignmentr   ZAlignCenterZsetFontr   r   Úsortedr   r   Ú	enumerater
   Z	addWidgetr	   Ú
capitalizer   Z	setLayoutÚreplaceZ	addLayoutZ
addStretchr   Zscroll_widgetr   Zscroll_areaZ	setWidgetZsetWindowFlagsZFramelessWindowHintZsetWindowOpacityZ_layoutZsetGeometry)Úselfr   ÚwidthÚheightZ	font_sizeZshortcuts_columnZstyleZ
font_namesZfont_keystrZ
font_titleZtitle_labelZcolumns_layoutZadded_shortcutsÚgroupZ	shortcutsÚcontextZgroup_shortcutsÚiÚnameZkeystrZcolumn_layoutZgroup_layoutZ
label_nameZlabel_keystr© r+   ú>lib/python3.7/site-packages/spyder/widgets/shortcutssummary.pyr   '   s|    










 









zShortcutsSummaryDialog.__init__c             C   s$   t ƒ }| | ¡ ¡}| ¡ | ¡ fS )z3Return the screen resolution of the primary screen.)r   ZavailableGeometryZprimaryScreenr%   r&   )r$   ZwidgetZgeometryr+   r+   r,   r   ‘   s    z,ShortcutsSummaryDialog.get_screen_resolution)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r+   r+   r+   r,   r      s   	
jr   c              C   s.   ddl m}  | ƒ }td ƒ}| ¡  | ¡  d S )Nr   )Úqapplication)Zspyder.utils.qthelpersr1   r   ZshowZexec_)r1   ZappZdlg_shortcutsr+   r+   r,   Útest˜   s
    r2   Ú__main__N)r0   Úoperatorr   Ú	itertoolsr   Zqtpy.QtCorer   Z
qtpy.QtGuir   Zqtpy.QtWidgetsr   r   r   r	   r
   r   r   r   r   Zspyder.config.baser   Zspyder.config.guir   r   r   r   r2   r-   r+   r+   r+   r,   Ú<module>   s   ,{