ó
Ò:\c        	   @` sÁ   d  Z  d d l m Z m Z m Z d d l Z d d l Z d d l m Z m	 Z	 d d l
 m Z m Z m Z d d „ Z d d „ Z d d d d d d d e j d	 „ Z d d
 „ Z d „  Z d S(   u   Qt utilities.i    (   t   absolute_importt   divisiont   unicode_literalsN(   t   Qtt   QTimer(   t   QActiont   QApplicationt   QMenui
   c         C` sŒ   t  j ƒ  } | d k r7 t  d g ƒ } | j d ƒ n  t j j d ƒ } | d k	 rˆ t | ƒ } | j j	 | j
 ƒ | j |  d ƒ n  | S(   u   Create QApplication instance.u   Anaconda-Navigatoru   TEST_CIiè  N(   R   t   instancet   Nonet   setApplicationNamet   ost   environt   getR   t   timeoutt   connectt   quitt   start(   t	   test_timet   appt   test_cit   timer_shutdown(    (    sA   lib/python2.7/site-packages/anaconda_navigator/utils/qthelpers.pyt   qapplication   s    c         C` s  d } t |  j ƒ  ƒ } | r@ | d } | j ƒ  r@ d } q@ n  xÑ | D]É } | d k rŽ | d k	 rŽ | d k r~ |  j ƒ  q
|  j | ƒ n| t | t ƒ rÌ | d k r¹ |  j | ƒ q
|  j	 | | ƒ n> t | t
 ƒ r
| d k r÷ |  j | ƒ q
|  j | | ƒ n  | } qG Wd S(   u   Add actions to a menu.iÿÿÿÿN(   R	   t   listt   actionst   isSeparatort   addSeparatort   insertSeparatort
   isinstanceR   t   addMenut
   insertMenuR   t	   addActiont   insertAction(   t   targetR   t   insert_beforet   previous_actiont   target_actionst   action(    (    sA   lib/python2.7/site-packages/anaconda_navigator/utils/qthelpers.pyt   add_actions&   s(    
c
         C` s  t  | |  ƒ }
 | d k	 r. |
 j j | ƒ n  | d k	 rZ |
 j j | ƒ |
 j t ƒ n  | d k	 rv |
 j | ƒ n  | d k	 r’ |
 j | ƒ n  | d k	 r» |
 j	 | ƒ |
 j
 | ƒ n  | d k	 r× |
 j | ƒ n  | d k	 ró |
 j | ƒ n  |
 j |	 ƒ |
 S(   u   Create a QAction.N(   R   R	   t	   triggeredR   t   toggledt   setCheckablet   Truet   setIcont   setShortcutt
   setToolTipt   setStatusTipt   setDatat   setMenuRolet   setShortcutContext(   t   parentt   textt   shortcutt   icont   tipR(   R'   t   datat   menurolet   contextR%   (    (    sA   lib/python2.7/site-packages/anaconda_navigator/utils/qthelpers.pyt   create_actionA   s&    c         C` s*   |  d k r t j ƒ  n t j |  ƒ d S(   u   Update application pointer.N(   R	   R   t   restoreOverrideCursort   setOverrideCursor(   t   cursor(    (    sA   lib/python2.7/site-packages/anaconda_navigator/utils/qthelpers.pyt   update_pointerf   s    c         C` s@   t  j d k r4 t j d |  ƒ r) d |  Sd |  Sn d |  Sd S(   uC   Select the right file uri scheme according to the operating system.u   ntu
   ^[a-zA-Z]:u   file:///u   file://N(   R   t   namet   ret   search(   t   fname(    (    sA   lib/python2.7/site-packages/anaconda_navigator/utils/qthelpers.pyt   file_urin   s
    (   t   __doc__t
   __future__R    R   R   R   R@   t   qtpy.QtCoreR   R   t   qtpy.QtWidgetsR   R   R   R   R	   R&   t   WindowShortcutR:   R>   RC   (    (    (    sA   lib/python2.7/site-packages/anaconda_navigator/utils/qthelpers.pyt   <module>   s"   