using QskMargins instead of QMargins in Q_PROPRTY definitions to get Qt6
working
This commit is contained in:
parent
78ac3377f7
commit
9a3e8d0d2d
@ -45,9 +45,7 @@
|
|||||||
#include <QskVirtualKeyboard.h>
|
#include <QskVirtualKeyboard.h>
|
||||||
#include <QskWindow.h>
|
#include <QskWindow.h>
|
||||||
|
|
||||||
|
|
||||||
#include <qjsvalueiterator.h>
|
#include <qjsvalueiterator.h>
|
||||||
#include <qmargins.h>
|
|
||||||
#include <qstringlist.h>
|
#include <qstringlist.h>
|
||||||
|
|
||||||
QSK_QT_PRIVATE_BEGIN
|
QSK_QT_PRIVATE_BEGIN
|
||||||
@ -106,8 +104,6 @@ struct QskRgbValue_Gadget
|
|||||||
Q_GADGET
|
Q_GADGET
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE( QMarginsF )
|
|
||||||
|
|
||||||
// Use this pattern to provide valueOf() to any type, something which is needed
|
// Use this pattern to provide valueOf() to any type, something which is needed
|
||||||
// in JS to convert a variant to a JS value. This would be a template, but moc
|
// in JS to convert a variant to a JS value. This would be a template, but moc
|
||||||
// doesn't support template classes.
|
// doesn't support template classes.
|
||||||
@ -267,6 +263,7 @@ void QskQml::registerTypes()
|
|||||||
QSK_REGISTER_GADGET( QskLayoutHint, "LayoutHint" );
|
QSK_REGISTER_GADGET( QskLayoutHint, "LayoutHint" );
|
||||||
QSK_REGISTER_GADGET( QskSizePolicy, "SizePolicy" );
|
QSK_REGISTER_GADGET( QskSizePolicy, "SizePolicy" );
|
||||||
QSK_REGISTER_GADGET( QskTextOptions, "TextOptions" );
|
QSK_REGISTER_GADGET( QskTextOptions, "TextOptions" );
|
||||||
|
QSK_REGISTER_GADGET( QskMargins, "Margins" );
|
||||||
|
|
||||||
// Support (lists of) GradientStop
|
// Support (lists of) GradientStop
|
||||||
QMetaType::registerConverter< QJSValue, QskGradientStop >(
|
QMetaType::registerConverter< QJSValue, QskGradientStop >(
|
||||||
@ -310,46 +307,8 @@ void QskQml::registerTypes()
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// Support QMarginsF in QML
|
QQmlMetaType::registerCustomStringConverter( qMetaTypeId< QskMargins >(),
|
||||||
class MarginsProvider final : public QQmlValueTypeProvider
|
[]( const QString& s ) { return QVariant::fromValue( QskMargins( s.toDouble() ) ); } );
|
||||||
{
|
|
||||||
public:
|
|
||||||
const QMetaObject* getMetaObjectForMetaType( int id ) override
|
|
||||||
{
|
|
||||||
if ( id == qMetaTypeId< QMarginsF >() )
|
|
||||||
return &QskMargins::staticMetaObject;
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
QQml_addValueTypeProvider( new MarginsProvider() );
|
|
||||||
|
|
||||||
QQmlMetaType::registerCustomStringConverter(
|
|
||||||
qMetaTypeId< QMarginsF >(),
|
|
||||||
[]( const QString& rhs )
|
|
||||||
{
|
|
||||||
auto margin = rhs.toDouble();
|
|
||||||
return QVariant::fromValue( QMarginsF( margin, margin, margin, margin ) );
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
QMetaType::registerConverter< int, QMarginsF >(
|
|
||||||
[]( int value ) { return QMarginsF( value, value, value, value ); } );
|
|
||||||
|
|
||||||
QMetaType::registerConverter< qreal, QMarginsF >(
|
|
||||||
[]( qreal value ) { return QMarginsF( value, value, value, value ); } );
|
|
||||||
|
|
||||||
qRegisterAnimationInterpolator< QMarginsF >(
|
|
||||||
[]( const QMarginsF& from, const QMarginsF& to, qreal progress )
|
|
||||||
{
|
|
||||||
return QVariant::fromValue( QMarginsF(
|
|
||||||
_q_interpolate( from.left(), to.left(), progress ),
|
|
||||||
_q_interpolate( from.top(), to.top(), progress ),
|
|
||||||
_q_interpolate( from.right(), to.right(), progress ),
|
|
||||||
_q_interpolate( from.bottom(), to.bottom(), progress )
|
|
||||||
) );
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// Support QskSizePolicy in QML user properties
|
// Support QskSizePolicy in QML user properties
|
||||||
QMetaType::registerConverter< QJSValue, QskSizePolicy >(
|
QMetaType::registerConverter< QJSValue, QskSizePolicy >(
|
||||||
|
@ -1,6 +1,17 @@
|
|||||||
#include "QskMargins.h"
|
#include "QskMargins.h"
|
||||||
#include <qvariant.h>
|
#include <qvariant.h>
|
||||||
|
|
||||||
|
static void qskRegisterConverter()
|
||||||
|
{
|
||||||
|
QMetaType::registerConverter< int, QskMargins >(
|
||||||
|
[]( int value ) { return QskMargins( value ); } );
|
||||||
|
|
||||||
|
QMetaType::registerConverter< qreal, QskMargins >(
|
||||||
|
[]( qreal value ) { return QskMargins( value ); } );
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_CONSTRUCTOR_FUNCTION( qskRegisterConverter )
|
||||||
|
|
||||||
static inline qreal qskInterpolated( qreal from, qreal to, qreal ratio )
|
static inline qreal qskInterpolated( qreal from, qreal to, qreal ratio )
|
||||||
{
|
{
|
||||||
return from + ( to - from ) * ratio;
|
return from + ( to - from ) * ratio;
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "QskBox.h"
|
#include "QskBox.h"
|
||||||
|
#include "QskMargins.h"
|
||||||
|
|
||||||
QSK_SUBCONTROL( QskBox, Panel )
|
QSK_SUBCONTROL( QskBox, Panel )
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ class QSK_EXPORT QskBox : public QskControl
|
|||||||
Q_PROPERTY( bool panel READ hasPanel
|
Q_PROPERTY( bool panel READ hasPanel
|
||||||
WRITE setPanel NOTIFY panelChanged FINAL )
|
WRITE setPanel NOTIFY panelChanged FINAL )
|
||||||
|
|
||||||
Q_PROPERTY( QMarginsF padding READ padding
|
Q_PROPERTY( QskMargins padding READ padding
|
||||||
WRITE setPadding RESET resetPadding NOTIFY paddingChanged )
|
WRITE setPadding RESET resetPadding NOTIFY paddingChanged )
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "QskSkin.h"
|
#include "QskSkin.h"
|
||||||
#include "QskSkinlet.h"
|
#include "QskSkinlet.h"
|
||||||
#include "QskSkinHintTable.h"
|
#include "QskSkinHintTable.h"
|
||||||
|
#include "QskMargins.h"
|
||||||
|
|
||||||
#include <qlocale.h>
|
#include <qlocale.h>
|
||||||
#include <qvector.h>
|
#include <qvector.h>
|
||||||
|
@ -37,7 +37,7 @@ class QSK_EXPORT QskControl : public QskQuickItem, public QskSkinnable
|
|||||||
Q_PROPERTY( bool wheelEnabled READ isWheelEnabled
|
Q_PROPERTY( bool wheelEnabled READ isWheelEnabled
|
||||||
WRITE setWheelEnabled NOTIFY wheelEnabledChanged FINAL )
|
WRITE setWheelEnabled NOTIFY wheelEnabledChanged FINAL )
|
||||||
|
|
||||||
Q_PROPERTY( QMarginsF margins READ margins
|
Q_PROPERTY( QskMargins margins READ margins
|
||||||
WRITE setMargins RESET resetMargins NOTIFY marginsChanged )
|
WRITE setMargins RESET resetMargins NOTIFY marginsChanged )
|
||||||
|
|
||||||
Q_PROPERTY( QskGradient background READ background
|
Q_PROPERTY( QskGradient background READ background
|
||||||
|
Loading…
x
Reference in New Issue
Block a user