Addon Manager: Protect refs to QRegularExpressionValidator

This commit is contained in:
Chris Hennes
2022-09-11 17:00:44 -05:00
parent 8ccd6a1cec
commit 74469a8978
2 changed files with 17 additions and 3 deletions

View File

@@ -30,9 +30,24 @@ import FreeCAD
import FreeCADGui
from PySide2.QtWidgets import QFileDialog, QDialog
from PySide2.QtGui import QDesktopServices, QRegularExpressionValidator
from PySide2.QtGui import QDesktopServices
from PySide2.QtCore import QUrl, QFile, QRegularExpression, QIODevice
try:
from PySide2.QtGui import (
QRegularExpressionValidator,
)
from PySide2.QtCore import QRegularExpression
RegexWrapper = QRegularExpression
RegexValidatorWrapper = QRegularExpressionValidator
except ImportError:
from PySide2.QtGui import (
QRegExpValidator,
)
from PySide2.QtCore import QRegExp
RegexWrapper = QRegExp
RegexValidatorWrapper = QRegExpValidator
translate = FreeCAD.Qt.translate
@@ -243,7 +258,7 @@ class LicenseSelector:
)
)
info_dlg.yearLineEdit.setValidator(
QRegularExpressionValidator(QRegularExpression("^[12]\\d{3}$"))
RegexValidatorWrapper(RegexWrapper("^[12]\\d{3}$"))
)
info_dlg.yearLineEdit.setText(str(date.today().year))
result = info_dlg.exec()

View File

@@ -26,7 +26,6 @@ import keyword
from PySide2.QtGui import (
QValidator,
QRegularExpressionValidator,
)
# QRegularExpressionValidator was only added at the very end of the PySide2