Skip to content

Commit

Permalink
Testing
Browse files Browse the repository at this point in the history
  • Loading branch information
dalthviz committed Aug 22, 2023
1 parent 882d604 commit d389b16
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 8 additions & 2 deletions qtpy/QtCore.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"""Provides QtCore classes and functions."""
from typing import TYPE_CHECKING

from . import PYQT6, PYQT5, PYSIDE2, PYSIDE6
from packaging.version import parse

from . import PYQT6, PYQT5, PYSIDE2, PYSIDE6, QT_VERSION as _qt_version
from ._utils import possibly_static_exec, possibly_static_exec_

if PYQT5:
Expand Down Expand Up @@ -63,7 +65,7 @@
Qt.MidButton = Qt.MiddleButton

# Add removed definition for `Qt.ItemFlags` as an alias of `Qt.ItemFlag`
# passing as default value 0 in the same way PySide6 does.
# passing as default value 0 in the same way PySide6 6.5+ does.
# Note that for PyQt5 and PySide2 those definitions are two different classes
# (one is the flag definition and the other the enum definition)
Qt.ItemFlags = lambda value=0: Qt.ItemFlag(value)
Expand Down Expand Up @@ -111,6 +113,10 @@
QThread.exec_ = lambda self, *args, **kwargs: self.exec(*args, **kwargs)
QTextStreamManipulator.exec_ = lambda self, *args, **kwargs: self.exec(*args, **kwargs)

# Passing as default value 0 in the same way PySide6 6.3.2 does for the `Qt.ItemFlags` definition.
if parse(_qt_version) > parse('6.3'):
Qt.ItemFlags = lambda value=0: Qt.ItemFlag(value)

# For issue #153 and updated for issue #305
if PYQT5 or PYQT6:
QDate.toPython = lambda self, *args, **kwargs: self.toPyDate(*args, **kwargs)
Expand Down
6 changes: 5 additions & 1 deletion qtpy/QtWidgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def _directory_to_dir_(*args, **kwargs):
QLineEdit.getTextMargins = lambda self: (self.textMargins().left(), self.textMargins().top(), self.textMargins().right(), self.textMargins().bottom())

# Add removed definition for `QFileDialog.Options` as an alias of `QFileDialog.Option`
# passing as default value 0 in the same way PySide6 does.
# passing as default value 0 in the same way PySide6 6.5+ does.
# Note that for PyQt5 and PySide2 those definitions are two different classes
# (one is the flag definition and the other the enum definition)
QFileDialog.Options = lambda value=0: QFileDialog.Option(value)
Expand Down Expand Up @@ -111,6 +111,10 @@ def _directory_to_dir_(*args, **kwargs):
QDialog.exec_ = lambda self, *args, **kwargs: self.exec(*args, **kwargs)
QMenu.exec_ = lambda *args, **kwargs: possibly_static_exec(QMenu, *args, **kwargs)

# Passing as default value 0 in the same way PySide6 < 6.3.2 does for the `QFileDialog.Options` definition.
if parse(_qt_version) > parse('6.3'):
QFileDialog.Options = lambda value=0: QFileDialog.Option(value)


if PYSIDE2 or PYSIDE6:
QFileDialog.getExistingDirectory = _directory_to_dir(QFileDialog.getExistingDirectory)
Expand Down

0 comments on commit d389b16

Please sign in to comment.