qtutils: add hide_button_menu_indicator()
[git-cola.git] / cola / qtcompat.py
blob3af04290f2b484409659f8c3eb752ef9910c001a
1 from PyQt4 import QtGui
2 from PyQt4 import QtCore
4 def install():
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'):
27 return
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)