[desc][qt] use QVariantList for list-type properties

* required for PySide2 > 5.11.1 (and compatible with 5.11.1)
* AttributeItemDelegate: test for list length to determine whether to create a slider component (if range is set to None on Python side, it will be an empty list on the QML/JS side)
This commit is contained in:
Yann Lanthony 2019-01-02 14:38:28 +01:00
parent e7b49f31c7
commit 6ac4a9d712
5 changed files with 10 additions and 7 deletions

View file

@ -7,13 +7,14 @@ Signal = None
Property = None
BaseObject = None
Variant = None
VariantList = None
if meshroom.backend == meshroom.Backend.PYSIDE:
# PySide types
from .qt import DictModel, ListModel, Slot, Signal, Property, BaseObject, Variant
from .qt import DictModel, ListModel, Slot, Signal, Property, BaseObject, Variant, VariantList
elif meshroom.backend == meshroom.Backend.STANDALONE:
# Core types
from .core import DictModel, ListModel, Slot, Signal, Property, BaseObject, Variant
from .core import DictModel, ListModel, Slot, Signal, Property, BaseObject, Variant, VariantList
class _BaseModel:

View file

@ -145,3 +145,4 @@ Signal = CoreSignal
Property = CoreProperty
BaseObject = CoreObject
Variant = object
VariantList = object

View file

@ -373,3 +373,4 @@ Signal = QtCore.Signal
Property = QtCore.Property
BaseObject = QtCore.QObject
Variant = "QVariant"
VariantList = "QVariantList"

View file

@ -1,4 +1,4 @@
from meshroom.common import BaseObject, Property, Variant
from meshroom.common import BaseObject, Property, Variant, VariantList
from meshroom.core import pyCompatibility
from enum import Enum # available by default in python3. For python2: "pip install enum34"
import collections
@ -129,7 +129,7 @@ class IntParam(Param):
except:
raise ValueError('IntParam only supports int value (param:{}, value:{}, type:{})'.format(self.name, value, type(value)))
range = Property(Variant, lambda self: self._range, constant=True)
range = Property(VariantList, lambda self: self._range, constant=True)
class FloatParam(Param):
@ -145,7 +145,7 @@ class FloatParam(Param):
except:
raise ValueError('FloatParam only supports float value (param:{}, value:{}, type:{})'.format(self.name, value, type(value)))
range = Property(Variant, lambda self: self._range, constant=True)
range = Property(VariantList, lambda self: self._range, constant=True)
class ChoiceParam(Param):
@ -174,7 +174,7 @@ class ChoiceParam(Param):
raise ValueError('Non exclusive ChoiceParam value should be iterable (param:{}, value:{}, type:{})'.format(self.name, value, type(value)))
return [self.conformValue(v) for v in value]
values = Property(Variant, lambda self: self._values, constant=True)
values = Property(VariantList, lambda self: self._values, constant=True)
exclusive = Property(bool, lambda self: self._exclusive, constant=True)
joinChar = Property(str, lambda self: self._joinChar, constant=True)

View file

@ -247,7 +247,7 @@ RowLayout {
Loader {
id: slider
Layout.fillWidth: true
active: attribute.desc.range != undefined
active: attribute.desc.range.length === 3
sourceComponent: Slider {
readonly property int stepDecimalCount: stepSize < 1 ? String(stepSize).split(".").pop().length : 0
readonly property real formattedValue: value.toFixed(stepDecimalCount)