o
    ¹¼tfS  ã                   @   sè   d Z ddlZddlZddlmZmZmZmZmZm	Z	m
Z
 ddlmZ dd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Zejjeo?e d¡dddd„ ƒZejjejdkoWejdd… dkdddd„ ƒZejjepee dddd„ ƒZdd„ ZdS )zTest QtGui.é    N)ÚPYQT5ÚPYQT_VERSIONÚPYSIDE2ÚPYSIDE6ÚQtCoreÚQtGuiÚ	QtWidgets)Únot_using_condac                 C   s†   t jjdusJ ‚t jjdusJ ‚t  dd¡}t  |¡}t  |¡}| d¡}| d¡}|tddƒv s3J ‚d|  kr>dksAJ ‚ J ‚dS )	z)Test QFontMetrics and QFontMetricsF widthNÚtimesé   ÚTesté(   é>   é'   é?   )r   ZQFontMetricsÚwidthZQFontMetricsFÚQFontÚrange)ÚqtbotZfontZfont_metricsZfont_metricsFr   ZwidthF© r   ú^/var/www/html/software/conda/envs/catlas/lib/python3.10/site-packages/qtpy/tests/test_qtgui.pyÚtest_qfontmetrics_width   s   



 r   c                 C   s&   t jjdusJ ‚t  d¡}| ¡  dS )z'Test functions mapping for QtGui.QDrag.N)r   ZQDragÚexec_)r   Zdragr   r   r   Útest_qdrag_functions    s   
r   c                  C   sž   t jjdusJ ‚t j ¡ pt  tjtg¡} | dusJ ‚tj 	dt j ¡ j
¡ t j ¡  t j ¡ p7t  tjtg¡} | dus>J ‚tj 	dt j ¡ j
¡ |  ¡  dS )z"Test `QtGui.QGuiApplication.exec_`Néd   )r   ZQGuiApplicationr   ÚinstanceÚsysÚ
executableÚ__file__r   ZQTimerZ
singleShotÚquit)Zappr   r   r   Útest_QGuiApplication_exec_'   s   ÿ
ÿr    c                   C   sJ   t jdusJ ‚t jdusJ ‚t jdusJ ‚t jdusJ ‚t jdus#J ‚dS )z(Test what has been moved to QtGui in Qt6N)r   ZQActionZQActionGroupZQFileSystemModelZ	QShortcutZQUndoCommandr   r   r   r   Útest_what_moved_to_qtgui_in_qt68   s
   r!   c                 C   s<   t jjdusJ ‚t  d¡}| \}}| |¡ | ¡ sJ ‚dS )z/Test functions mapping for QtGui.QTextDocument.Nr   )r   ÚQTextDocumentÚprint_Úexists)Z
pdf_writerZtext_documentZprint_deviceZoutput_pathr   r   r   Útest_qtextdocument_functionsA   s
   

r%   z5.9zaA specific setup with at least sip 4.9.9 is needed for PyQt5 5.9.*to work with scoped enum access)Úreasonc                   C   s\   t jjt jjjksJ ‚t jjt jjjksJ ‚t jjt jj	jks!J ‚t j
jt j
jjks,J ‚dS )z:Test scoped and unscoped enum access for qtpy.QtWidgets.*.N)r   ZQColorZRgbZSpecr   ZAllUppercaseZCapitalizationZQIconZNormalZModeZQImageZFormat_InvalidZFormatr   r   r   r   Útest_enum_accessJ   s   r'   Údarwiné   )é   é   z"Stalls on macOS CI with Python 3.7c                 C   sè   G dd„ dt jƒ}|ƒ }| dd¡ | ¡  |  |¡ |  |t dd¡¡ |  |tj	j
¡ W d  ƒ n1 s8w   Y  dD ]}d	D ]}ttt|ƒ|ƒsOJ ‚qCq?d
D ]
}ttj|ƒs]J ‚qSdD ]}dD ]}ttt|ƒ|ƒspJ ‚qdq`dS )z€
    Test `QMouseEvent.pos` and related functions removed in Qt 6,
    and `QMouseEvent.position`, etc., missing from Qt 5.
    c                   @   s    e Zd Zdejddfdd„ZdS )z2test_QSomethingEvent_pos_functions.<locals>.WindowÚeventÚreturnNc                 S   s  |  ¡ | ¡  |  t dd¡¡ksJ ‚| ¡  ¡ | ¡ ksJ ‚| ¡  ¡ | ¡ ks+J ‚|  ¡  ¡ | ¡ ks7J ‚|  ¡  ¡ | ¡ ksCJ ‚| 	¡  ¡ | ¡  ¡ ksQJ ‚| 	¡  ¡ | ¡  ¡ ks_J ‚| 
¡  ¡ |  ¡  ¡ ksmJ ‚| 
¡  ¡ |  ¡  ¡ ks{J ‚| ¡  d S )Nr   )Ú	globalPosÚposZmapToParentr   ÚQPointÚxÚyÚglobalXÚglobalYÚpositionÚglobalPositionÚaccept)Úselfr,   r   r   r   ÚmouseDoubleClickEventb   s   

ÿzHtest_QSomethingEvent_pos_functions.<locals>.Window.mouseDoubleClickEvent)Ú__name__Ú
__module__Ú__qualname__r   ZQMouseEventr9   r   r   r   r   ÚWindowa   s    r=   i@  éð   é*   é6   N)ZQNativeGestureEventZQEnterEventZQTabletEvent)r/   r1   r2   r.   r3   r4   r5   r6   )r/   r1   r2   r5   )Z
QDropEventZQDragMoveEventZQDragEnterEvent)r/   ZposFr5   )r   ZQMainWindowZsetMinimumSizeÚshowZwaitExposedZ	mouseMover   r0   ZmouseDClickZQtZ
LeftButtonÚhasattrÚgetattrr   ZQHoverEvent)r   r=   ZwindowÚ_classZ	_functionr   r   r   Ú"test_QSomethingEvent_pos_functionsW   s&   
þ
öÿÿrE   zPySide{2,6} specific testc                  C   sâ   t  d¡} t  | ¡}| t jj¡rJ ‚|jt jjt jjds J ‚| ¡ dks(J ‚| t jj¡s1J ‚|jt jjdt jjds?J ‚| ¡ dksGJ ‚| t jj¡sPJ ‚| 	¡ | 
¡ ksZJ ‚| t jjt jjd¡sgJ ‚| ¡ dksoJ ‚dS )	z+Test monkeypatched QTextCursor.movePositionzfoo bar baz)ÚmodeZfoor)   )ÚnrF   zfoo bar r*   N)r   r"   ZQTextCursorZmovePositionZStartZ	EndOfWordZ
KeepAnchorZselectedTextZ	WordRightr5   ÚanchorZNextWord)ÚdocÚcursorr   r   r   Útest_qtextcursor_moveposition’   s.   


þ
ýýrK   c                   C   sÖ   t jdusJ ‚t jdusJ ‚t jdusJ ‚t jdusJ ‚t jdus#J ‚t jdus*J ‚t jdus1J ‚t jdus8J ‚t j	dus?J ‚t j
dusFJ ‚t jdusMJ ‚t jdusTJ ‚t jdus[J ‚t jdusbJ ‚t jdusiJ ‚dS )zÁ
    Test for presence of QOpenGL* classes.

    These classes were members of QtGui in Qt5, but moved to QtOpenGL in Qt6.
    QtPy makes them available in QtGui to maintain compatibility.
    N)r   ZQOpenGLBufferZQOpenGLContextZQOpenGLContextGroupZQOpenGLDebugLoggerZQOpenGLDebugMessageZQOpenGLFramebufferObjectZQOpenGLFramebufferObjectFormatZQOpenGLPixelTransferOptionsZQOpenGLShaderZQOpenGLShaderProgramZQOpenGLTextureZQOpenGLTextureBlitterZQOpenGLVersionProfileZQOpenGLVertexArrayObjectZQOpenGLWindowr   r   r   r   Útest_opengl_imports´   s   rL   )Ú__doc__r   ZpytestZqtpyr   r   r   r   r   r   r   Zqtpy.tests.utilsr	   r   r   r    r!   r%   ÚmarkZskipifÚ
startswithr'   ÚplatformÚversion_inforE   rK   rL   r   r   r   r   Ú<module>   s4    $			þ
þ
7þ
