
    \g`5                        d Z ddlZddlZddlZddlZddlZddlmZ ddlm	Z	 ddl
mZ dZ ej        e          Zej                            ej                            ej                            e                              Zej                            ed          Zej                            ed          Zej                            ed	          Zej                            ed
          Zej                            ed          Zej                            ed          ZdZe                    dd          ZdZdZ dZ!ej                            ee          Z"ej                            ee          Z#ej                            ee          Z$ej                            ee           Z%ej                            ee!          Z&dZ'd Z(d Z)d Z*d Z+d!dZ,d Z-d Z.d Z/d Z0d Z1d"d Z2dS )#a`  The most complete dark/light style sheet for Qt applications (Qt4, Qt5,
PySide, PySide2, PyQt4, PyQt5, QtPy, PyQtGraph, Qt.Py) for Python 2/3 and C++.

Python 2, as well as Qt4 (PyQt4 and PySide), will not be supported anymore.
They still there as it is, but no back-compatibility, fixes, nor features
will be implemented.

We still preparing the portability to Qt6 since we need changes in
`QtPy <https://github.com/spyder-ide/qtpy>`__ dependency project.

Check the `documentation <https://qdarkstylesheet.readthedocs.io/en/stable>`__
to see how to set the desirable theme palette.

This module provides a function to load the stylesheets transparently
with the right resources file.

First, start importing our module

.. code-block:: python

    import qdarkstyle

Then you can get stylesheet provided by QDarkStyle for various Qt wrappers
as shown below

.. code-block:: python

    # PySide
    dark_stylesheet = qdarkstyle.load_stylesheet_pyside()
    # PySide 2
    dark_stylesheet = qdarkstyle.load_stylesheet_pyside2()
    # PyQt4
    dark_stylesheet = qdarkstyle.load_stylesheet_pyqt()
    # PyQt5
    dark_stylesheet = qdarkstyle.load_stylesheet_pyqt5()

Alternatively, from environment variables provided by QtPy, PyQtGraph, Qt.Py

.. code-block:: python

    # QtPy
    dark_stylesheet = qdarkstyle.load_stylesheet()
    # PyQtGraph
    dark_stylesheet = qdarkstyle.load_stylesheet(qt_api=os.environ('PYQTGRAPH_QT_LIB'))
    # Qt.Py
    dark_stylesheet = qdarkstyle.load_stylesheet(qt_api=Qt.__binding__)

Finally, set your QApplication with it

.. code-block:: python

    app.setStyleSheet(dark_stylesheet)

Enjoy!

    N)DarkPalette)LightPalette)Palettez3.0.2examplezdocs/images
qdarkstyleqssrcsvgz	style.qssz.qssz.qrcz	main.scssz_styles.scssz_variables.scsszThis function will be deprecated in v3.0.
Please, set the wanted binding by using QtPy environment variable QT_API,
then use load_stylesheet() or use load_stylesheet()
passing the argument qt_api='wanted_binding'.c                     d}t          j                                                    dk    rd                    | j                  }|rt
                              d           |S )zh
    Apply OS-only specific stylesheet pacthes.

    Returns:
        str: stylesheet string (css).
     darwinz
        QDockWidget::title
        {{
            background-color: {color};
            text-align: center;
            height: 12px;
        }}
        QTabBar::close-button {{
            padding: 2px;
        }}
        )colorzFound OS patches to be applied.)platformsystemlowerformatCOLOR_BACKGROUND_4_loggerinfo)paletteos_fixs     3lib/python3.11/site-packages/qdarkstyle/__init__.py_apply_os_patchesr   o   sh     F  H,,
 F3F44 	  86777M    c                  B    d} | rt                               d           | S )z}
    Apply binding-only specific stylesheet patches for the same OS.

    Returns:
        str: stylesheet string (css).
    r   z$Found binding patches to be applied.)r   r   )binding_fixs    r   _apply_binding_patchesr      s*     K =;<<<r   c                     d}|                      d          \  }}}t          |          t          |          t          |          }}}|dk    r|dk    rd}|rt                              d           |S )z
    Apply version-only specific stylesheet patches for the same binding.

    Args:
        qt_version (str): Qt string version.

    Returns:
        str: stylesheet string (css).
    r   .      zP
        QMenu::item {
            padding: 4px 24px 4px 6px;
        }
        z$Found version patches to be applied.)splitintr   r   )
qt_versionversion_fixmajorminorpatchs        r   _apply_version_patchesr)      s}     K$**3//E5%e**c%jj#e**%5Ezzerkk  =;<<<r   c                 V   |j         } ||          }|                                 }t                              d           |rL|                                }|                    |j        |j        |           |                    |           dS t          	                    d           dS )z
    Apply application level fixes on the QPalette.

    The import names args must be passed here because the import is done
    inside the load_stylesheet() function, as QtPy is only imported in
    that moment for setting reasons.
    z(Found application patches to be applied.zNo QCoreApplication instance found. Application patches not applied. You have to call load_stylesheet function after instantiation of QApplication to take effect. N)
COLOR_ACCENT_3instancer   r   r   setColorNormalLink
setPalettewarn)QCoreApplicationQPaletteQColorr   r   qcolorappapp_palettes           r   _apply_application_patchesr8      s     "EVE]]F 
#
#
%
%CLL;<<<
 GkkmmX_hmVDDD{##### F 	G 	G 	G 	G 	Gr   r   c                     | r| t           j        d<   ddlm}m}m} ddlm}m} ddl	m
} |ddlm} t          }nU|j        dk    rddlm} t          }n<|j        d	k    rddlm} t           }n#t#          d
           t%          j        d           t           j                            t,                    }	dt           j                            |	|j        t0                    z   }
t2                              d|
z              ||
          }|                                r\|                    |j        |j        z              ||          }|                                }t2                               d           n$d}tC          d"                    |
                    t2                              d           |tG          |          z  }|tI                      z  }|tK          |          z  }tM          ||||           |S )a  
    Load the stylesheet based on QtPy abstraction layer environment variable.

    If the argument is not passed, it uses the current QT_API environment
    variable to make the imports of Qt bindings. If passed, it sets this
    variable then make the imports.

    Args:
        qt_api (str): qt binding name to set QT_API environment variable.
                      Default is ''. Possible values are pyside, pyside2
                      pyqt4, pyqt5. Not case sensitive.
        palette (Palette): Palette class that inherits from Palette.

    Note:
        - Note that the variable QT_API is read when first imported. So,
          pay attention to the import order.
        - If you are using another abstraction layer, i.e PyQtGraph to do
          imports on Qt things you must set both to use the same Qt
          binding (PyQt, PySide).
        - OS, binding and binding version number, and application specific
          patches are applied in this order.

    Returns:
        str: stylesheet string (css).
    QT_APIr   )r2   QFileQTextStream)r4   r3   )
QT_VERSIONN)style_rcdarklightz'Not recognized ID for palette! Exiting!   :zReading QSS file in: %szQSS file sucessfuly loaded.r   z*Unable to find QSS file '{}' in resources.z#Checking patches for being applied.)'osenvironqtpy.QtCorer2   r;   r<   
qtpy.QtGuir4   r3   qtpyr=   qdarkstyle.darkr>   r   IDqdarkstyle.lightr   printsysexitpathbasenamePACKAGE_PATHjoinQSS_FILEr   debugexistsopenReadOnlyTextreadAllr   FileNotFoundErrorr   r   r   r)   r8   )qt_apir   r2   r;   r<   r4   r3   r=   r>   package_dirqss_rc_pathqss_filetext_stream
stylesheets                 r   _load_stylesheetr`      sH   6  &%
8 A@@@@@@@@@++++++++ ,,,,,,	v		,,,,,,	w		------7888 '""<00K['*hGGGKMM+k9::: u[!!H 	Eenuz1222!k(++ ((**
23333
 !006{0C0CE E 	E MM7888 #G,,,J (***J (444J /67KKKr   c                  `   d}d}	 | d         }n# t           $ r Y nw xY w|                    dd          }|r| s&t          |           dk    st          |          dk    rt          d          |s| st	          d          }n*d	|v st          |t                    r|                    d	|          }|r%t	          d
|          }|st	          d	|          }n$t	          d|          }|st	          d|          }t          j        t          t                     nd|v st          |t                    r(|                    d|          }t	          ||          }nOd|v st          |t                    r'|                    d|          }t	          |          }nt          d          |S )a  
    Load the stylesheet. Takes care of importing the rc module.

    Args:
        pyside (bool): True to load the PySide (or PySide2) rc file,
                       False to load the PyQt4 (or PyQt5) rc file.
                       Default is False.
        or

        qt_api (str): Qt binding name to set QT_API environment variable.
                      Default is '', i.e PyQt5 the default QtPy binding.
                      Possible values are pyside, pyside2 pyqt4, pyqt5.
                      Not case sensitive.

        or

        palette (Palette): Class (not instance) that inherits from Palette.

    Raises:
        TypeError: If arguments do not match: type, keyword name nor quantity.

    Returns:
        str: the stylesheet string.
    r   Nr   r      zload_stylesheet() takes zero, one or two arguments: (new) string type qt_api='pyqt5' or (old) boolean type pyside='False' or (new) palette type palette=Palette.pyqt5rZ   pysidepyside2)rZ   r   pyqt4rZ   )r   zload_stylesheet() takes only zero, one or two arguments: (new) string type qt_api='pyqt5' or (new) palette type palette=Palette or (old) boolean type pyside='False'.)
IndexErrorgetlen	TypeErrorr`   
isinstanceboolwarningsr1   DEPRECATION_MSGDeprecationWarningstr
issubclassr   )argskwargsr_   argr   re   rZ   palette_args           r   load_stylesheetrw   -  s   4 J
C1g   
 jjD))G 	 ?4 ?CIIMMS[[1__ > ? ? 	?  #>$ #>%W555

 
V		z#t44	Hc** 	O)GLLLJ P-XwOOO
 *'JJJJ O-WgNNN
 	o'9:::: 
V		z#s33	Hc**%VWEEE

 
f		
3 8 8	jjC00%k:::

  = > > 	>
 s    
c                  "    t          d          S )zp
    Load the stylesheet for use in a PySide application.

    Returns:
        str: the stylesheet string.
    re   rd   r`    r   r   load_stylesheet_pysider{     s     8,,,,r   c                  "    t          d          S )zq
    Load the stylesheet for use in a PySide2 application.

    Returns:
        str: the stylesheet string.
    rf   rd   ry   rz   r   r   load_stylesheet_pyside2r}     s     9----r   c                  "    t          d          S )zo
    Load the stylesheet for use in a PyQt4 application.

    Returns:
        str: the stylesheet string.
    rg   rd   ry   rz   r   r   load_stylesheet_pyqtr          7++++r   c                  "    t          d          S )zo
    Load the stylesheet for use in a PyQt5 application.

    Returns:
        str: the stylesheet string.
    rc   rd   ry   rz   r   r   load_stylesheet_pyqt5r     r   r   Fc                     t          j        t          t                     | r/t	          t
          j                            dd                    }nt	                      }|S )a"  
    Load the stylesheet from QT_API (or PYQTGRAPH_QT_LIB) environment variable.

    Args:
        is_pyqtgraph (bool): True if it is to be set using PYQTGRAPH_QT_LIB.

    Raises:
        KeyError: if PYQTGRAPH_QT_LIB does not exist.

    Returns:
        str: the stylesheet string.
    PYQTGRAPH_QT_LIBNrd   )rn   r1   ro   rp   r`   rC   rD   ri   )is_pyqtgraphr_   s     r    load_stylesheet_from_environmentr     sT     M/#5666 (%RZ^^<NPT-U-UVVV

%''
r   )r   N)F)3__doc__loggingrC   r   rL   rn   qdarkstyle.dark.paletter   qdarkstyle.light.paletter   qdarkstyle.paletter   __version__	getLogger__name__r   rN   dirnameabspath__file__	REPO_PATHrQ   EXAMPLE_PATHIMAGES_PATHrP   QSS_PATHRC_PATHSVG_PATHrR   replaceQRC_FILEMAIN_SCSS_FILESTYLES_SCSS_FILEVARIABLES_SCSS_FILEQSS_FILEPATHQRC_FILEPATHMAIN_SCSS_FILEPATHSTYLES_SCSS_FILEPATHVARIABLES_SCSS_FILEPATHro   r   r   r)   r8   r`   rw   r{   r}   r   r   r   rz   r   r   <module>r      s  7 7t  				  



  0 / / / / / 1 1 1 1 1 1 & & & & & &
'
H
%
% GOOBGOOBGOOH,E,EFFGG	w||Iy11gll9m44w||I|447<<e,,
',,|T
*
*7<<e,, FF++! '  w||L(33w||L(33W\\(N;; w||H.>?? ',,x1DEE 1  <    :G G G8U U U UpS S Sl- - -. . ., , ,, , ,     r   