code simplified
This commit is contained in:
parent
e86ce49fb4
commit
9ab005a0f5
@ -110,6 +110,14 @@ namespace
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static inline QskGradientStop qskToGradientStop( const QJSValue& value )
|
||||||
|
{
|
||||||
|
return QskGradientStop(
|
||||||
|
value.property( QLatin1String( "position" ) ).toNumber(),
|
||||||
|
value.property( QLatin1String( "color" ) ).toVariant().value< QColor >()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void QskQml::registerTypes()
|
void QskQml::registerTypes()
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
@ -198,17 +206,7 @@ void QskQml::registerTypes()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Support (lists of) GradientStop
|
// Support (lists of) GradientStop
|
||||||
QMetaType::registerConverter< QJSValue, QskGradientStop >(
|
QMetaType::registerConverter< QJSValue, QskGradientStop >( qskToGradientStop );
|
||||||
|
|
||||||
[](const QJSValue& value) -> QskGradientStop
|
|
||||||
{
|
|
||||||
return
|
|
||||||
{
|
|
||||||
value.property( QLatin1String( "position" ) ).toNumber(),
|
|
||||||
value.property( QLatin1String( "color" ) ).toVariant().value< QColor >()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
QMetaType::registerConverter< QJSValue, QVector< QskGradientStop > >(
|
QMetaType::registerConverter< QJSValue, QVector< QskGradientStop > >(
|
||||||
|
|
||||||
@ -218,22 +216,9 @@ void QskQml::registerTypes()
|
|||||||
if ( value.isArray() )
|
if ( value.isArray() )
|
||||||
{
|
{
|
||||||
QJSValueIterator it( value );
|
QJSValueIterator it( value );
|
||||||
|
|
||||||
while ( it.next() && it.hasNext() )
|
while ( it.next() && it.hasNext() )
|
||||||
{
|
stops.append( qskToGradientStop( it.value() ) );
|
||||||
auto source = it.value();
|
|
||||||
auto target = QskGradientStop();
|
|
||||||
|
|
||||||
const int sourceTypeId = qMetaTypeId< decltype( source ) >();
|
|
||||||
const int targetTypeId = qMetaTypeId< decltype( target ) >();
|
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )
|
|
||||||
QMetaType::convert( QMetaType( sourceTypeId ), &source,
|
|
||||||
QMetaType( targetTypeId ), &target );
|
|
||||||
#else
|
|
||||||
QMetaType::convert( &source, sourceTypeId, &target, targetTypeId );
|
|
||||||
#endif
|
|
||||||
stops.append( target );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return stops;
|
return stops;
|
||||||
}
|
}
|
||||||
@ -252,6 +237,7 @@ void QskQml::registerTypes()
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#if 1
|
||||||
QMetaType::registerConverter< int, QskSizePolicy >(
|
QMetaType::registerConverter< int, QskSizePolicy >(
|
||||||
[]( int value )
|
[]( int value )
|
||||||
{
|
{
|
||||||
@ -259,4 +245,5 @@ void QskQml::registerTypes()
|
|||||||
return QskSizePolicy( policy, policy );
|
return QskSizePolicy( policy, policy );
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user