1 from PyQt4
import QtGui
2 from PyQt4
import QtCore
5 if not hasattr(QtGui
.QHBoxLayout
, 'setContentsMargins'):
6 QtGui
.QHBoxLayout
.setContentsMargins
= lambda *args
: True
8 if not hasattr(QtGui
.QVBoxLayout
, 'setContentsMargins'):
9 QtGui
.QVBoxLayout
.setContentsMargins
= lambda *args
: True
11 if not hasattr(QtGui
.QKeySequence
, 'Preferences'):
12 QtGui
.QKeySequence
.Preferences
= 'Ctrl+O'
14 if not hasattr(QtGui
.QGraphicsItem
, 'mapRectToScene'):
15 QtGui
.QGraphicsItem
.mapRectToScene
= _map_rect_to_scene
17 if not hasattr(QtCore
.QCoreApplication
, 'setStyleSheet'):
18 QtCore
.QCoreApplication
.setStyleSheet
= lambda *args
: None
21 def add_search_path(prefix
, path
):
22 if hasattr(QtCore
.QDir
, 'addSearchPath'):
23 QtCore
.QDir
.addSearchPath(prefix
, path
)
25 def set_common_dock_options(window
):
26 if not hasattr(window
, 'setDockOptions'):
28 nested
= QtGui
.QMainWindow
.AllowNestedDocks
29 tabbed
= QtGui
.QMainWindow
.AllowTabbedDocks
30 animated
= QtGui
.QMainWindow
.AnimatedDocks
31 window
.setDockOptions(nested | tabbed | animated
)
34 def _map_rect_to_scene(self
, rect
):
35 """Only available in newer PyQt4 versions"""
36 return self
.sceneTransform().mapRect(rect
)