QtCore.py 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. # -*- coding: utf-8 -*-
  2. #
  3. # Copyright © 2014-2015 Colin Duquesnoy
  4. # Copyright © 2009- The Spyder Development Team
  5. #
  6. # Licensed under the terms of the MIT License
  7. # (see LICENSE.txt for details)
  8. """
  9. Provides QtCore classes and functions.
  10. """
  11. from . import PYQT5, PYSIDE2, PYQT4, PYSIDE, PythonQtError
  12. if PYQT5:
  13. from PyQt5.QtCore import *
  14. from PyQt5.QtCore import pyqtSignal as Signal
  15. from PyQt5.QtCore import pyqtSlot as Slot
  16. from PyQt5.QtCore import pyqtProperty as Property
  17. from PyQt5.QtCore import QT_VERSION_STR as __version__
  18. # For issue #153
  19. from PyQt5.QtCore import QDateTime
  20. QDateTime.toPython = QDateTime.toPyDateTime
  21. # Those are imported from `import *`
  22. del pyqtSignal, pyqtSlot, pyqtProperty, QT_VERSION_STR
  23. elif PYSIDE2:
  24. from PySide2.QtCore import *
  25. try: # may be limited to PySide-5.11a1 only
  26. from PySide2.QtGui import QStringListModel
  27. except:
  28. pass
  29. import PySide2.QtCore
  30. __version__ = PySide2.QtCore.__version__
  31. elif PYQT4:
  32. from PyQt4.QtCore import *
  33. # Those are things we inherited from Spyder that fix crazy crashes under
  34. # some specific situations. (See #34)
  35. from PyQt4.QtCore import QCoreApplication
  36. from PyQt4.QtCore import Qt
  37. from PyQt4.QtCore import pyqtSignal as Signal
  38. from PyQt4.QtCore import pyqtSlot as Slot
  39. from PyQt4.QtCore import pyqtProperty as Property
  40. from PyQt4.QtGui import (QItemSelection, QItemSelectionModel,
  41. QItemSelectionRange, QSortFilterProxyModel,
  42. QStringListModel)
  43. from PyQt4.QtCore import QT_VERSION_STR as __version__
  44. from PyQt4.QtCore import qInstallMsgHandler as qInstallMessageHandler
  45. # QDesktopServices has has been split into (QDesktopServices and
  46. # QStandardPaths) in Qt5
  47. # This creates a dummy class that emulates QStandardPaths
  48. from PyQt4.QtGui import QDesktopServices as _QDesktopServices
  49. class QStandardPaths():
  50. StandardLocation = _QDesktopServices.StandardLocation
  51. displayName = _QDesktopServices.displayName
  52. DesktopLocation = _QDesktopServices.DesktopLocation
  53. DocumentsLocation = _QDesktopServices.DocumentsLocation
  54. FontsLocation = _QDesktopServices.FontsLocation
  55. ApplicationsLocation = _QDesktopServices.ApplicationsLocation
  56. MusicLocation = _QDesktopServices.MusicLocation
  57. MoviesLocation = _QDesktopServices.MoviesLocation
  58. PicturesLocation = _QDesktopServices.PicturesLocation
  59. TempLocation = _QDesktopServices.TempLocation
  60. HomeLocation = _QDesktopServices.HomeLocation
  61. DataLocation = _QDesktopServices.DataLocation
  62. CacheLocation = _QDesktopServices.CacheLocation
  63. writableLocation = _QDesktopServices.storageLocation
  64. # Those are imported from `import *`
  65. del pyqtSignal, pyqtSlot, pyqtProperty, QT_VERSION_STR, qInstallMsgHandler
  66. elif PYSIDE:
  67. from PySide.QtCore import *
  68. from PySide.QtGui import (QItemSelection, QItemSelectionModel,
  69. QItemSelectionRange, QSortFilterProxyModel,
  70. QStringListModel)
  71. from PySide.QtCore import qInstallMsgHandler as qInstallMessageHandler
  72. del qInstallMsgHandler
  73. # QDesktopServices has has been split into (QDesktopServices and
  74. # QStandardPaths) in Qt5
  75. # This creates a dummy class that emulates QStandardPaths
  76. from PySide.QtGui import QDesktopServices as _QDesktopServices
  77. class QStandardPaths():
  78. StandardLocation = _QDesktopServices.StandardLocation
  79. displayName = _QDesktopServices.displayName
  80. DesktopLocation = _QDesktopServices.DesktopLocation
  81. DocumentsLocation = _QDesktopServices.DocumentsLocation
  82. FontsLocation = _QDesktopServices.FontsLocation
  83. ApplicationsLocation = _QDesktopServices.ApplicationsLocation
  84. MusicLocation = _QDesktopServices.MusicLocation
  85. MoviesLocation = _QDesktopServices.MoviesLocation
  86. PicturesLocation = _QDesktopServices.PicturesLocation
  87. TempLocation = _QDesktopServices.TempLocation
  88. HomeLocation = _QDesktopServices.HomeLocation
  89. DataLocation = _QDesktopServices.DataLocation
  90. CacheLocation = _QDesktopServices.CacheLocation
  91. writableLocation = _QDesktopServices.storageLocation
  92. import PySide.QtCore
  93. __version__ = PySide.QtCore.__version__
  94. else:
  95. raise PythonQtError('No Qt bindings could be found')