tests: use pytest fixtures in git_test
[git-cola.git] / qtpy / QtGui.py
blob071be132b2c3780af1adf59ab85e92e7ce34d72f
1 # -*- coding: utf-8 -*-
3 # Copyright © 2014-2015 Colin Duquesnoy
4 # Copyright © 2009- The Spyder Development Team
6 # Licensed under the terms of the MIT License
7 # (see LICENSE.txt for details)
9 """
10 Provides QtGui classes and functions.
11 .. warning:: Only PyQt4/PySide QtGui classes compatible with PyQt5.QtGui are
12 exposed here. Therefore, you need to treat/use this package as if it were
13 the ``PyQt5.QtGui`` module.
14 """
15 import warnings
17 from . import PYQT5, PYQT4, PYSIDE, PYSIDE2, PythonQtError
20 if PYQT5:
21 from PyQt5.QtGui import *
22 elif PYSIDE2:
23 from PySide2.QtGui import *
24 elif PYQT4:
25 try:
26 # Older versions of PyQt4 do not provide these
27 from PyQt4.QtGui import (QGlyphRun, QMatrix2x2, QMatrix2x3,
28 QMatrix2x4, QMatrix3x2, QMatrix3x3,
29 QMatrix3x4, QMatrix4x2, QMatrix4x3,
30 QMatrix4x4, QTouchEvent, QQuaternion,
31 QRadialGradient, QRawFont, QStaticText,
32 QVector2D, QVector3D, QVector4D,
33 qFuzzyCompare)
34 except ImportError:
35 pass
36 from PyQt4.Qt import QKeySequence, QTextCursor
37 from PyQt4.QtGui import (QAbstractTextDocumentLayout, QActionEvent, QBitmap,
38 QBrush, QClipboard, QCloseEvent, QColor,
39 QConicalGradient, QContextMenuEvent, QCursor,
40 QDoubleValidator, QDrag,
41 QDragEnterEvent, QDragLeaveEvent, QDragMoveEvent,
42 QDropEvent, QFileOpenEvent, QFocusEvent, QFont,
43 QFontDatabase, QFontInfo, QFontMetrics,
44 QFontMetricsF, QGradient, QHelpEvent,
45 QHideEvent, QHoverEvent, QIcon, QIconDragEvent,
46 QIconEngine, QImage, QImageIOHandler, QImageReader,
47 QImageWriter, QInputEvent, QInputMethodEvent,
48 QKeyEvent, QLinearGradient,
49 QMouseEvent, QMoveEvent, QMovie,
50 QPaintDevice, QPaintEngine, QPaintEngineState,
51 QPaintEvent, QPainter, QPainterPath,
52 QPainterPathStroker, QPalette, QPen, QPicture,
53 QPictureIO, QPixmap, QPixmapCache, QPolygon,
54 QPolygonF, QRegExpValidator, QRegion, QResizeEvent,
55 QSessionManager, QShortcutEvent, QShowEvent,
56 QStandardItem, QStandardItemModel,
57 QStatusTipEvent, QSyntaxHighlighter, QTabletEvent,
58 QTextBlock, QTextBlockFormat, QTextBlockGroup,
59 QTextBlockUserData, QTextCharFormat,
60 QTextDocument, QTextDocumentFragment,
61 QTextDocumentWriter, QTextFormat, QTextFragment,
62 QTextFrame, QTextFrameFormat, QTextImageFormat,
63 QTextInlineObject, QTextItem, QTextLayout,
64 QTextLength, QTextLine, QTextList, QTextListFormat,
65 QTextObject, QTextObjectInterface, QTextOption,
66 QTextTable, QTextTableCell, QTextTableCellFormat,
67 QTextTableFormat, QTransform,
68 QValidator, QWhatsThisClickedEvent, QWheelEvent,
69 QWindowStateChangeEvent, qAlpha, qBlue,
70 qGray, qGreen, qIsGray, qRed, qRgb,
71 qRgba, QIntValidator)
73 # QDesktopServices has has been split into (QDesktopServices and
74 # QStandardPaths) in Qt5
75 # It only exposes QDesktopServices that are still in pyqt5
76 from PyQt4.QtGui import QDesktopServices as _QDesktopServices
78 class QDesktopServices():
79 openUrl = _QDesktopServices.openUrl
80 setUrlHandler = _QDesktopServices.setUrlHandler
81 unsetUrlHandler = _QDesktopServices.unsetUrlHandler
83 def __getattr__(self, name):
84 attr = getattr(_QDesktopServices, name)
86 new_name = name
87 if name == 'storageLocation':
88 new_name = 'writableLocation'
89 warnings.warn(("Warning QDesktopServices.{} is deprecated in Qt5"
90 "we recommend you use QDesktopServices.{} instead").format(name, new_name),
91 DeprecationWarning)
92 return attr
93 QDesktopServices = QDesktopServices()
95 elif PYSIDE:
96 from PySide.QtGui import (QAbstractTextDocumentLayout, QActionEvent, QBitmap,
97 QBrush, QClipboard, QCloseEvent, QColor,
98 QConicalGradient, QContextMenuEvent, QCursor,
99 QDoubleValidator, QDrag,
100 QDragEnterEvent, QDragLeaveEvent, QDragMoveEvent,
101 QDropEvent, QFileOpenEvent, QFocusEvent, QFont,
102 QFontDatabase, QFontInfo, QFontMetrics,
103 QFontMetricsF, QGradient, QHelpEvent,
104 QHideEvent, QHoverEvent, QIcon, QIconDragEvent,
105 QIconEngine, QImage, QImageIOHandler, QImageReader,
106 QImageWriter, QInputEvent, QInputMethodEvent,
107 QKeyEvent, QKeySequence, QLinearGradient,
108 QMatrix2x2, QMatrix2x3, QMatrix2x4, QMatrix3x2,
109 QMatrix3x3, QMatrix3x4, QMatrix4x2, QMatrix4x3,
110 QMatrix4x4, QMouseEvent, QMoveEvent, QMovie,
111 QPaintDevice, QPaintEngine, QPaintEngineState,
112 QPaintEvent, QPainter, QPainterPath,
113 QPainterPathStroker, QPalette, QPen, QPicture,
114 QPictureIO, QPixmap, QPixmapCache, QPolygon,
115 QPolygonF, QQuaternion, QRadialGradient,
116 QRegExpValidator, QRegion, QResizeEvent,
117 QSessionManager, QShortcutEvent, QShowEvent,
118 QStandardItem, QStandardItemModel,
119 QStatusTipEvent, QSyntaxHighlighter, QTabletEvent,
120 QTextBlock, QTextBlockFormat, QTextBlockGroup,
121 QTextBlockUserData, QTextCharFormat, QTextCursor,
122 QTextDocument, QTextDocumentFragment,
123 QTextFormat, QTextFragment,
124 QTextFrame, QTextFrameFormat, QTextImageFormat,
125 QTextInlineObject, QTextItem, QTextLayout,
126 QTextLength, QTextLine, QTextList, QTextListFormat,
127 QTextObject, QTextObjectInterface, QTextOption,
128 QTextTable, QTextTableCell, QTextTableCellFormat,
129 QTextTableFormat, QTouchEvent, QTransform,
130 QValidator, QVector2D, QVector3D, QVector4D,
131 QWhatsThisClickedEvent, QWheelEvent,
132 QWindowStateChangeEvent, qAlpha, qBlue,
133 qGray, qGreen, qIsGray, qRed, qRgb, qRgba,
134 QIntValidator)
135 # QDesktopServices has has been split into (QDesktopServices and
136 # QStandardPaths) in Qt5
137 # It only exposes QDesktopServices that are still in pyqt5
138 from PySide.QtGui import QDesktopServices as _QDesktopServices
140 class QDesktopServices():
141 openUrl = _QDesktopServices.openUrl
142 setUrlHandler = _QDesktopServices.setUrlHandler
143 unsetUrlHandler = _QDesktopServices.unsetUrlHandler
145 def __getattr__(self, name):
146 attr = getattr(_QDesktopServices, name)
148 new_name = name
149 if name == 'storageLocation':
150 new_name = 'writableLocation'
151 warnings.warn(("Warning QDesktopServices.{} is deprecated in Qt5"
152 "we recommend you use QDesktopServices.{} instead").format(name, new_name),
153 DeprecationWarning)
154 return attr
155 QDesktopServices = QDesktopServices()
156 else:
157 raise PythonQtError('No Qt bindings could be found')