ó
‹²,]c           @   sE  d  Z  d d l m Z d d l m Z m Z m Z d d l m Z m	 Z	 m
 Z
 d d l m Z m Z 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 d l m Z d	 e f d
 „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ  d e f d „  ƒ  YZ! d „  Z" e# d k rAe" ƒ  n  d S(   s   
Helper widgets.
iÿÿÿÿ(   t   PYQT5(   t   QPointt   QSizet   Qt(   t   QAbstractTextDocumentLayoutt   QPaintert   QTextDocument(   t   QApplicationt	   QCheckBoxt	   QLineEditt   QMessageBoxt   QSpacerItemt   QStylet   QStyledItemDelegatet   QStyleOptionViewItemt   QToolButtont   QToolTipt   QVBoxLayout(   t   _(   t   icon_manager(   t   get_std_icont   HelperToolButtonc           B   s;   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sF   Subclasses QToolButton, to provide a simple tooltip on mousedown.
    c         C   s7   t  j |  ƒ |  j t d ƒ ƒ d } |  j | ƒ d  S(   Nt   MessageBoxInformations  
            QToolButton {
              border: 1px solid grey;
              padding:0px;
              border-radius: 2px;
              background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                  stop: 0 #f6f7fa, stop: 1 #dadbde);
            }
            (   R   t   __init__t   setIconR   t   setStyleSheet(   t   selft   style(    (    s;   lib/python2.7/site-packages/spyder/widgets/helperwidgets.pyR      s    	c         C   s   | |  _  d  S(   N(   t	   _tip_text(   R   t   text(    (    s;   lib/python2.7/site-packages/spyder/widgets/helperwidgets.pyt
   setToolTip+   s    c         C   s   |  j  S(   N(   R   (   R   (    (    s;   lib/python2.7/site-packages/spyder/widgets/helperwidgets.pyt   toolTip.   s    c         C   s   t  j ƒ  d  S(   N(   R   t   hideText(   R   t   event(    (    s;   lib/python2.7/site-packages/spyder/widgets/helperwidgets.pyt   mousePressEvent1   s    c         C   s/   t  j |  j t d |  j ƒ  ƒ ƒ |  j ƒ d  S(   Ni    (   R   t   showTextt   mapToGlobalR   t   heightR   (   R   R!   (    (    s;   lib/python2.7/site-packages/spyder/widgets/helperwidgets.pyt   mouseReleaseEvent4   s    !(   t   __name__t
   __module__t   __doc__R   R   R   R"   R&   (    (    (    s;   lib/python2.7/site-packages/spyder/widgets/helperwidgets.pyR      s   				t   MessageCheckBoxc           B   sM   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 RS(   s†   
    A QMessageBox derived widget that includes a QCheckBox aligned to the right
    under the message and on top of the buttons.
    c         O   s¸   t  t |  ƒ j | | Ž  t ƒ  |  _ d } t ƒ  } | j t | | ƒ ƒ | j |  j d t	 j
 ƒ | j t | | ƒ ƒ |  j ƒ  } t r¡ | j | d d ƒ n | j | d d ƒ d  S(   Ni	   i    i   i   (   t   superR*   R   R   t	   _checkboxR   t   addItemR   t	   addWidgetR   t
   AlignRightt   layoutR    t	   addLayout(   R   t   argst   kwargst   sizet   check_layoutR0   (    (    s;   lib/python2.7/site-packages/spyder/widgets/helperwidgets.pyR   >   s    	c         C   s   |  j  j ƒ  S(   N(   R,   t	   isChecked(   R   (    (    s;   lib/python2.7/site-packages/spyder/widgets/helperwidgets.pyt
   is_checkedS   s    c         C   s   |  j  j | ƒ S(   N(   R,   t
   setChecked(   R   t   value(    (    s;   lib/python2.7/site-packages/spyder/widgets/helperwidgets.pyt   set_checkedV   s    c         C   s   |  j  j | ƒ d  S(   N(   R,   t
   setVisible(   R   R9   (    (    s;   lib/python2.7/site-packages/spyder/widgets/helperwidgets.pyt   set_check_visibleY   s    c         C   s   |  j  j ƒ  d  S(   N(   R,   t	   isVisible(   R   (    (    s;   lib/python2.7/site-packages/spyder/widgets/helperwidgets.pyt   is_check_visible\   s    c         C   s   |  j  j ƒ  d  S(   N(   R,   R   (   R   (    (    s;   lib/python2.7/site-packages/spyder/widgets/helperwidgets.pyt   checkbox_text_   s    c         C   s   |  j  j | ƒ d  S(   N(   R,   t   setText(   R   R   (    (    s;   lib/python2.7/site-packages/spyder/widgets/helperwidgets.pyt   set_checkbox_textb   s    (
   R'   R(   R)   R   R7   R:   R<   R>   R?   RA   (    (    (    s;   lib/python2.7/site-packages/spyder/widgets/helperwidgets.pyR*   9   s   						t   HTMLDelegatec           B   s,   e  Z d  Z d d „ Z d „  Z d „  Z RS(   s‡   With this delegate, a QListWidgetItem or a QTableItem can render HTML.

    Taken from https://stackoverflow.com/a/5443112/2399799
    i    c         C   s#   t  t |  ƒ j | ƒ | |  _ d  S(   N(   R+   RB   R   t   _margin(   R   t   parentt   margin(    (    s;   lib/python2.7/site-packages/spyder/widgets/helperwidgets.pyR   k   s    c   	      C   s¸  t  | ƒ } |  j | | ƒ | j d  k r7 t j ƒ  n | j j ƒ  } t ƒ  } | j |  j ƒ | j	 | j
 ƒ d | _
 | j t j | | ƒ t j ƒ  } | j t j | ƒ } | j ƒ  t | j d ƒ rt| j ƒ  d k r"| j j r| j | j ƒ  t d d ƒ ƒ qq| j | j ƒ  ƒ q”| j j rQ| j | j ƒ  t d d ƒ ƒ q”| j | j ƒ  t d d ƒ ƒ n  | j | j ƒ  t d	 d
 ƒ ƒ | j ƒ  j | | ƒ | j ƒ  d  S(   Nt    t
   files_listt   oxygent   qtcurvet   breezei   i÷ÿÿÿi   i    iýÿÿÿ(   RH   RI   RJ   (   R   t   initStyleOptiont   widgett   NoneR   R   R   t   setDocumentMarginRC   t   setHtmlR   t   drawControlR   t   CE_ItemViewItemR   t   PaintContextt   subElementRectt   SE_ItemViewItemTextt   savet   hasattrt
   objectNameRG   t	   translatet   topLeftR   t   documentLayoutt   drawt   restore(	   R   t   paintert   optiont   indext   optionsR   t   doct   ctxt   textRect(    (    s;   lib/python2.7/site-packages/spyder/widgets/helperwidgets.pyt   painto   s.    		
### c         C   sX   t  | ƒ } |  j | | ƒ t ƒ  } | j | j ƒ t | j ƒ  | j ƒ  j ƒ  d ƒ S(   Ni   (	   R   RK   R   RO   R   R   t
   idealWidthR4   R%   (   R   R^   R_   R`   Ra   (    (    s;   lib/python2.7/site-packages/spyder/widgets/helperwidgets.pyt   sizeHint“   s
    	(   R'   R(   R)   R   Rd   Rf   (    (    (    s;   lib/python2.7/site-packages/spyder/widgets/helperwidgets.pyRB   f   s   	$t   IconLineEditc           B   sD   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sC   Custom QLineEdit that includes an icon representing the validation.c         O   s–   t  t |  ƒ j | | Ž  t |  _ t |  _ t j d ƒ |  _ t j d ƒ |  _	 t j d ƒ |  _
 t j ƒ  j ƒ  |  _ |  j ƒ  d |  _ t |  _ d  S(   Nt   todot   warningt	   todo_listi    (   R+   Rg   R   t   Truet   _statust   _status_sett   imat   icont   _valid_icont   _invalid_icont	   _set_iconR   R   RW   t   _application_stylet   _refresht   _paint_countt   Falset   _icon_visible(   R   R2   R3   (    (    s;   lib/python2.7/site-packages/spyder/widgets/helperwidgets.pyR       s    		
	c         C   sc   |  j  ƒ  } d } d } |  j d k r0 | } n | } | j d | ƒ } |  j | ƒ |  j ƒ  d S(   si   After an application style change, the paintEvent updates the
        custom defined stylesheet.
        s°   QLineEdit {{
                                 border: none;
                                 padding-right: {padding}px;
                                 }}
                   sÐ   QLineEdit {{background: transparent;
                                   border: none;
                                   padding-right: {padding}px;
                                   }}
                     RH   t   paddingN(   R%   Rs   t   formatR   t   update(   R   Rx   t   css_baset
   css_oxygent   css_templatet   css(    (    s;   lib/python2.7/site-packages/spyder/widgets/helperwidgets.pyRt   ­   s    	c         C   s!   t  |  _ |  j ƒ  |  j ƒ  d S(   s   Show the status icon.N(   Rv   Rw   t   repaintRz   (   R   (    (    s;   lib/python2.7/site-packages/spyder/widgets/helperwidgets.pyt   hide_status_iconÅ   s    	
c         C   s!   t  |  _ |  j ƒ  |  j ƒ  d S(   s   Hide the status icon.N(   Rk   Rw   R   Rz   (   R   (    (    s;   lib/python2.7/site-packages/spyder/widgets/helperwidgets.pyt   show_status_iconË   s    	
c         C   s*   | |  _  | |  _ |  j ƒ  |  j ƒ  d S(   s@   Update the status and set_status to update the icons to display.N(   Rl   Rm   R   Rz   (   R   R9   t	   value_set(    (    s;   lib/python2.7/site-packages/spyder/widgets/helperwidgets.pyt   update_statusÑ   s    		
c   	      C   sI  t  t |  ƒ j | ƒ t |  ƒ } |  j ƒ  } t | j ƒ  d ƒ } | j ƒ  | } | j ƒ  | } |  j rã |  j	 r— |  j
 r— |  j j | | ƒ } n6 |  j	 r¸ |  j j | | ƒ } n |  j j | | ƒ } | j | | | ƒ n  t j ƒ  j ƒ  } |  j | k r| |  _ |  j ƒ  n  |  j d k  rE|  j d 7_ |  j ƒ  n  d S(   sV   Qt Override.

        Include a validation icon to the left of the line edit.
        i   i   i   N(   R+   Rg   t
   paintEventR   t   geometryt   intR%   t   widthRw   Rl   Rm   Rr   t   pixmapRp   Rq   t
   drawPixmapR   R   RW   Rs   Rt   Ru   (	   R   R!   R]   t   rectt   spacet   ht   wRˆ   t   application_style(    (    s;   lib/python2.7/site-packages/spyder/widgets/helperwidgets.pyR„   Ø   s(    			(	   R'   R(   R)   R   Rt   R€   R   Rƒ   R„   (    (    (    s;   lib/python2.7/site-packages/spyder/widgets/helperwidgets.pyRg      s   					c          C   s   d d l  m }  |  ƒ  } t ƒ  } | j t d ƒ ƒ | j d ƒ | j d ƒ | j t j	 ƒ | j
 t j	 ƒ | j t j ƒ | j ƒ  d  S(   Niÿÿÿÿ(   t   qapplications   Spyder updatess   Testing checkboxs   Check for updates on startup?(   t   spyder.utils.qthelpersR   R*   t   setWindowTitleR   R@   RA   t   setStandardButtonsR
   t   Okt   setDefaultButtonR   t   Informationt   exec_(   R   t   appt   box(    (    s;   lib/python2.7/site-packages/spyder/widgets/helperwidgets.pyt   test_msgcheckboxú   s    		t   __main__N($   R)   t   qtpyR    t   qtpy.QtCoreR   R   R   t
   qtpy.QtGuiR   R   R   t   qtpy.QtWidgetsR   R   R	   R
   R   R   R   R   R   R   R   t   spyder.config.baseR   t   spyder.utilsR   Rn   R   R   R   R*   RB   Rg   R™   R'   (    (    (    s;   lib/python2.7/site-packages/spyder/widgets/helperwidgets.pyt   <module>	   s   L-7]	