ó
ø`9Sc           @   s{   d  Z  d d l Td d l Td d l m Z d   Z d   Z d   Z d   Z d d d	     YZ	 d
 e
 f d     YZ d S(   s0   Miscellaneous GUI-related classes and functions.iĸĸĸĸ(   t   *(   t   utilsc         C   s   t  j | d  y |  j   } | j d | j    | j   |  j   j   |  j   j   } | j d |  | j d |  j    Wd QXd S(   s|   Save 'window's size, position and maximization state to a 'QSettings'
    instance, under a subgroup with a predefined name.t   WindowGeometryt
   windowSizet	   windowPost   windowMaximizedN(	   R   t   SettingsGroupert   normalGeometryt   setValuet   sizet   topLeftt   geometryt   frameGeometryt   isMaximized(   t   windowt   settingsR   R   (    (    s   code\common\utils\gui.pyt   saveWindowSettings   s    c         C   sÃ   t  j | d  Ŧ | j d  rA |  j | j d  j    n  | j d  ro |  j | j d  j    n  | j d  rđ | j d  j   rĶ |  j	 t
 j  qđ |  j	 t
 j  n  Wd QXd S(   sx   Set 'window's size, position and maximization state according to the
    settings saved by 'saveWindowSettings', if any.R   R   R   R   N(   R   R   t   containst   resizet   valuet   toSizet   movet   toPointt   toBoolt   setWindowStatet   Qtt   WindowMaximizedt   WindowNoState(   R   R   (    (    s   code\common\utils\gui.pyt   loadWindowSettings-   s    c         C   sž   |  d k r" t  j   j t j  S|  d k rD t  j   j t j  S|  d k rf t  j   j t j  S|  d k r t  j   j t j  S|  d k rŠ t  j   j t j  St	 d |  d  S(   s    Load a 'QIcon' by its string ID.t   opent   questiont   infot   warningt   errors   code/media/icons/s   .png(
   t   qAppt   stylet   standardIcont   QStylet   SP_DirOpenIcont   SP_MessageBoxQuestiont   SP_MessageBoxInformationt   SP_MessageBoxWarningt   SP_MessageBoxCriticalt   QIcon(   t   iconName(    (    s   code\common\utils\gui.pyt   loadIconA   s    c         C   s=   x6 |  j    D]( } |  j |  j | t j  t j  q Wd S(   s}   Replace an icon's disabled pixmaps with normal ones, so that the icon
    will never appear in the disabled monochrome style.N(   t   availableSizest	   addPixmapt   pixmapR+   t   Normalt   Disabled(   t   iconR	   (    (    s   code\common\utils\gui.pyt   suppressDisabledIconAppearanceT   s    t   SignalBlockerc           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   s  Utility class that may be used with 'with' statement to temporarily
    block any of the signals emitted by the given list of 'QObject's.

    Pass the 'QObject's to block signals from to constructor, and use the
    returned instance as the argument for 'with' statement.c         G   s   | |  _  d  S(   N(   t
   widgetList(   t   selfR6   (    (    s   code\common\utils\gui.pyt   __init__f   s    c         C   s%   x |  j  D] } | j t  q
 Wd  S(   N(   R6   t   blockSignalst   True(   R7   t   widget(    (    s   code\common\utils\gui.pyt	   __enter__i   s    c         C   s%   x |  j  D] } | j t  q
 Wd  S(   N(   R6   R9   t   False(   R7   t   excTypet   excValuet	   tracebackR;   (    (    s   code\common\utils\gui.pyt   __exit__m   s    (   t   __name__t
   __module__t   __doc__R8   R<   RA   (    (    (    s   code\common\utils\gui.pyR5   _   s   		t   UnhidableWidgetItemc           B   s    e  Z d  Z d   Z d   Z RS(   sl   A widget layout item that occupies the same space regardless of whether
    its widget is visible or hidden.c         C   s   t  j |  |  d  S(   N(   t   QWidgetItemR8   (   R7   R;   (    (    s   code\common\utils\gui.pyR8   v   s    c         C   s   t  S(   N(   R=   (   R7   (    (    s   code\common\utils\gui.pyt   isEmptyy   s    (   RB   RC   RD   R8   RG   (    (    (    s   code\common\utils\gui.pyRE   r   s   	N(    (   RD   t   PyQt4.QtCoret   PyQt4.QtGuit   common.utilsR   R   R   R-   R4   R5   RF   RE   (    (    (    s   code\common\utils\gui.pyt   <module>   s   

				