mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-06-04 11:51:58 +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
|
||||
Variant = None
|
||||
VariantList = None
|
||||
JSValue = None
|
||||
|
||||
if meshroom.backend == meshroom.Backend.PYSIDE:
|
||||
# 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:
|
||||
# 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:
|
||||
|
|
|
@ -146,3 +146,4 @@ Property = CoreProperty
|
|||
BaseObject = CoreObject
|
||||
Variant = object
|
||||
VariantList = object
|
||||
JSValue = None
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from PySide2 import QtCore
|
||||
from PySide2 import QtCore, QtQml
|
||||
|
||||
|
||||
class QObjectListModel(QtCore.QAbstractListModel):
|
||||
|
@ -374,3 +374,4 @@ Property = QtCore.Property
|
|||
BaseObject = QtCore.QObject
|
||||
Variant = "QVariant"
|
||||
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 enum import Enum # available by default in python3. For python2: "pip install enum34"
|
||||
import math
|
||||
import os
|
||||
import psutil
|
||||
import PySide2
|
||||
import ast
|
||||
|
||||
class Attribute(BaseObject):
|
||||
|
@ -69,7 +68,7 @@ class ListAttribute(Attribute):
|
|||
joinChar = Property(str, lambda self: self._joinChar, constant=True)
|
||||
|
||||
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
|
||||
raise ValueError("ListAttribute.validateValue: cannot recognize QJSValue. Please, use JSON.stringify(value) in QML.")
|
||||
if isinstance(value, pyCompatibility.basestring):
|
||||
|
@ -105,7 +104,7 @@ class GroupAttribute(Attribute):
|
|||
|
||||
def validateValue(self, value):
|
||||
""" 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
|
||||
raise ValueError("GroupAttribute.validateValue: cannot recognize QJSValue. Please, use JSON.stringify(value) in QML.")
|
||||
if isinstance(value, pyCompatibility.basestring):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue