mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-06-11 07:11:52 +02:00
[core] avoid direct includes to PySide2
This commit is contained in:
parent
06372bc89e
commit
887b33490e
4 changed files with 9 additions and 7 deletions
|
@ -8,13 +8,14 @@ Property = None
|
||||||
BaseObject = None
|
BaseObject = None
|
||||||
Variant = None
|
Variant = None
|
||||||
VariantList = None
|
VariantList = None
|
||||||
|
JSValue = None
|
||||||
|
|
||||||
if meshroom.backend == meshroom.Backend.PYSIDE:
|
if meshroom.backend == meshroom.Backend.PYSIDE:
|
||||||
# PySide types
|
# PySide types
|
||||||
from .qt import DictModel, ListModel, Slot, Signal, Property, BaseObject, Variant, VariantList
|
from .qt import DictModel, ListModel, Slot, Signal, Property, BaseObject, Variant, VariantList, JSValue
|
||||||
elif meshroom.backend == meshroom.Backend.STANDALONE:
|
elif meshroom.backend == meshroom.Backend.STANDALONE:
|
||||||
# Core types
|
# Core types
|
||||||
from .core import DictModel, ListModel, Slot, Signal, Property, BaseObject, Variant, VariantList
|
from .core import DictModel, ListModel, Slot, Signal, Property, BaseObject, Variant, VariantList, JSValue
|
||||||
|
|
||||||
|
|
||||||
class _BaseModel:
|
class _BaseModel:
|
||||||
|
|
|
@ -146,3 +146,4 @@ Property = CoreProperty
|
||||||
BaseObject = CoreObject
|
BaseObject = CoreObject
|
||||||
Variant = object
|
Variant = object
|
||||||
VariantList = object
|
VariantList = object
|
||||||
|
JSValue = None
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from PySide2 import QtCore
|
from PySide2 import QtCore, QtQml
|
||||||
|
|
||||||
|
|
||||||
class QObjectListModel(QtCore.QAbstractListModel):
|
class QObjectListModel(QtCore.QAbstractListModel):
|
||||||
|
@ -374,3 +374,4 @@ Property = QtCore.Property
|
||||||
BaseObject = QtCore.QObject
|
BaseObject = QtCore.QObject
|
||||||
Variant = "QVariant"
|
Variant = "QVariant"
|
||||||
VariantList = "QVariantList"
|
VariantList = "QVariantList"
|
||||||
|
JSValue = QtQml.QJSValue
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
from meshroom.common import BaseObject, Property, Variant, VariantList
|
from meshroom.common import BaseObject, Property, Variant, VariantList, JSValue
|
||||||
from meshroom.core import pyCompatibility
|
from meshroom.core import pyCompatibility
|
||||||
from enum import Enum # available by default in python3. For python2: "pip install enum34"
|
from enum import Enum # available by default in python3. For python2: "pip install enum34"
|
||||||
import math
|
import math
|
||||||
import os
|
import os
|
||||||
import psutil
|
import psutil
|
||||||
import PySide2
|
|
||||||
import ast
|
import ast
|
||||||
|
|
||||||
class Attribute(BaseObject):
|
class Attribute(BaseObject):
|
||||||
|
@ -69,7 +68,7 @@ class ListAttribute(Attribute):
|
||||||
joinChar = Property(str, lambda self: self._joinChar, constant=True)
|
joinChar = Property(str, lambda self: self._joinChar, constant=True)
|
||||||
|
|
||||||
def validateValue(self, value):
|
def validateValue(self, value):
|
||||||
if isinstance(value, PySide2.QtQml.QJSValue):
|
if JSValue is not None and isinstance(value, JSValue):
|
||||||
# Note: we could use isArray(), property("length").toInt() to retrieve all values
|
# Note: we could use isArray(), property("length").toInt() to retrieve all values
|
||||||
raise ValueError("ListAttribute.validateValue: cannot recognize QJSValue. Please, use JSON.stringify(value) in QML.")
|
raise ValueError("ListAttribute.validateValue: cannot recognize QJSValue. Please, use JSON.stringify(value) in QML.")
|
||||||
if isinstance(value, pyCompatibility.basestring):
|
if isinstance(value, pyCompatibility.basestring):
|
||||||
|
@ -105,7 +104,7 @@ class GroupAttribute(Attribute):
|
||||||
|
|
||||||
def validateValue(self, value):
|
def validateValue(self, value):
|
||||||
""" Ensure value is compatible with the group description and convert value if needed. """
|
""" Ensure value is compatible with the group description and convert value if needed. """
|
||||||
if isinstance(value, PySide2.QtQml.QJSValue):
|
if JSValue is not None and isinstance(value, JSValue):
|
||||||
# Note: we could use isArray(), property("length").toInt() to retrieve all values
|
# Note: we could use isArray(), property("length").toInt() to retrieve all values
|
||||||
raise ValueError("GroupAttribute.validateValue: cannot recognize QJSValue. Please, use JSON.stringify(value) in QML.")
|
raise ValueError("GroupAttribute.validateValue: cannot recognize QJSValue. Please, use JSON.stringify(value) in QML.")
|
||||||
if isinstance(value, pyCompatibility.basestring):
|
if isinstance(value, pyCompatibility.basestring):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue