QskAspect::Section introduced
This commit is contained in:
parent
44e264d472
commit
62fcbc6c32
@ -295,6 +295,9 @@ void qskDebugAspect( QDebug debug, const QMetaObject* metaObject, QskAspect aspe
|
||||
else
|
||||
debug << subControlName;
|
||||
|
||||
if ( aspect.section() != QskAspect::Body )
|
||||
debug << ", " << qskEnumString( "Section", aspect.section() );
|
||||
|
||||
debug << ", " << qskEnumString( "Type", aspect.type() );
|
||||
if ( aspect.isAnimator() )
|
||||
debug << "(A)";
|
||||
@ -338,7 +341,7 @@ const char* QskAspect::toPrintable() const
|
||||
QDebug debug( &tmp );
|
||||
debug << *this;
|
||||
|
||||
// we should find a better impementation
|
||||
// we should find a better implementation
|
||||
static QByteArray bytes[ 10 ];
|
||||
static int counter = 0;
|
||||
|
||||
|
@ -27,6 +27,18 @@ class QSK_EXPORT QskAspect
|
||||
|
||||
static constexpr uint typeCount = 3;
|
||||
|
||||
enum Section : quint8
|
||||
{
|
||||
Body = 0,
|
||||
|
||||
Header,
|
||||
Footer
|
||||
};
|
||||
Q_ENUM( Section )
|
||||
|
||||
static constexpr uint FirstUserSection = Section::Footer + 1;
|
||||
static constexpr uint LastSection = ( 1 << 4 ) - 1;
|
||||
|
||||
enum Primitive : quint8
|
||||
{
|
||||
NoPrimitive = 0,
|
||||
@ -88,11 +100,14 @@ class QSK_EXPORT QskAspect
|
||||
|
||||
AllStates = 0xFFFF
|
||||
};
|
||||
|
||||
Q_ENUM( State )
|
||||
Q_DECLARE_FLAGS( States, State )
|
||||
|
||||
constexpr QskAspect() noexcept;
|
||||
|
||||
constexpr QskAspect( Subcontrol ) noexcept;
|
||||
constexpr QskAspect( Section ) noexcept;
|
||||
constexpr QskAspect( Type ) noexcept;
|
||||
constexpr QskAspect( Placement ) noexcept;
|
||||
|
||||
@ -107,6 +122,7 @@ class QSK_EXPORT QskAspect
|
||||
bool operator<( const QskAspect& ) const noexcept;
|
||||
|
||||
constexpr QskAspect operator|( Subcontrol ) const noexcept;
|
||||
constexpr QskAspect operator|( Section ) const noexcept;
|
||||
constexpr QskAspect operator|( Type ) const noexcept;
|
||||
constexpr QskAspect operator|( Primitive ) const noexcept;
|
||||
constexpr QskAspect operator|( Placement ) const noexcept;
|
||||
@ -134,6 +150,9 @@ class QSK_EXPORT QskAspect
|
||||
constexpr Subcontrol subControl() const noexcept;
|
||||
void setSubControl( Subcontrol ) noexcept;
|
||||
|
||||
constexpr Section section() const noexcept;
|
||||
void setSection( Section ) noexcept;
|
||||
|
||||
constexpr Type type() const noexcept;
|
||||
void setType( Type ) noexcept;
|
||||
|
||||
@ -175,23 +194,25 @@ class QSK_EXPORT QskAspect
|
||||
static void reservePrimitives( quint8 count );
|
||||
|
||||
private:
|
||||
constexpr QskAspect( Subcontrol, Type, Placement ) noexcept;
|
||||
constexpr QskAspect( Subcontrol, Section, Type, Placement ) noexcept;
|
||||
|
||||
constexpr QskAspect( uint subControl, uint type, bool isAnimator,
|
||||
constexpr QskAspect( uint subControl, uint section, uint type, bool isAnimator,
|
||||
uint primitive, uint placement, uint states ) noexcept;
|
||||
|
||||
struct Bits
|
||||
{
|
||||
uint subControl : 12;
|
||||
uint section : 4;
|
||||
|
||||
uint type : 3;
|
||||
uint type : 3;
|
||||
uint isAnimator : 1;
|
||||
|
||||
uint primitive : 5;
|
||||
uint placement : 3;
|
||||
uint reserved1 : 8;
|
||||
uint reserved1 : 4;
|
||||
|
||||
uint states : 16;
|
||||
|
||||
uint states : 16;
|
||||
uint reserved2 : 16;
|
||||
};
|
||||
|
||||
@ -218,34 +239,39 @@ constexpr inline QskAspect::State operator>>( QskAspect::State a, const int b )
|
||||
}
|
||||
|
||||
inline constexpr QskAspect::QskAspect() noexcept
|
||||
: QskAspect( Control, Flag, NoPlacement )
|
||||
: QskAspect( Control, Body, Flag, NoPlacement )
|
||||
{
|
||||
}
|
||||
|
||||
inline constexpr QskAspect::QskAspect( Subcontrol subControl ) noexcept
|
||||
: QskAspect( subControl, Flag, NoPlacement )
|
||||
: QskAspect( subControl, Body, Flag, NoPlacement )
|
||||
{
|
||||
}
|
||||
|
||||
inline constexpr QskAspect::QskAspect( Section section ) noexcept
|
||||
: QskAspect( Control, section, Flag, NoPlacement )
|
||||
{
|
||||
}
|
||||
|
||||
inline constexpr QskAspect::QskAspect( Type type ) noexcept
|
||||
: QskAspect( Control, type, NoPlacement )
|
||||
: QskAspect( Control, Body, type, NoPlacement )
|
||||
{
|
||||
}
|
||||
|
||||
inline constexpr QskAspect::QskAspect( Placement placement ) noexcept
|
||||
: QskAspect( Control, Flag, placement )
|
||||
: QskAspect( Control, Body, Flag, placement )
|
||||
{
|
||||
}
|
||||
|
||||
inline constexpr QskAspect::QskAspect(
|
||||
Subcontrol subControl, Type type, Placement placement ) noexcept
|
||||
: QskAspect( subControl, type, false, 0, placement, NoState )
|
||||
Subcontrol subControl, Section section, Type type, Placement placement ) noexcept
|
||||
: QskAspect( subControl, section, type, false, 0, placement, NoState )
|
||||
{
|
||||
}
|
||||
|
||||
inline constexpr QskAspect::QskAspect( uint subControl, uint type, bool isAnimator,
|
||||
inline constexpr QskAspect::QskAspect( uint subControl, uint section, uint type, bool isAnimator,
|
||||
uint primitive, uint placement, uint states ) noexcept
|
||||
: m_bits { subControl, type, isAnimator, primitive, placement, 0, states, 0 }
|
||||
: m_bits { subControl, section, type, isAnimator, primitive, placement, 0, states, 0 }
|
||||
{
|
||||
}
|
||||
|
||||
@ -266,32 +292,38 @@ inline bool QskAspect::operator<( const QskAspect& other ) const noexcept
|
||||
|
||||
inline constexpr QskAspect QskAspect::operator|( Subcontrol subControl ) const noexcept
|
||||
{
|
||||
return QskAspect( subControl, m_bits.type, m_bits.isAnimator,
|
||||
m_bits.primitive, m_bits.placement, m_bits.states );
|
||||
return QskAspect( subControl, m_bits.section, m_bits.type,
|
||||
m_bits.isAnimator, m_bits.primitive, m_bits.placement, m_bits.states );
|
||||
}
|
||||
|
||||
inline constexpr QskAspect QskAspect::operator|( Section section ) const noexcept
|
||||
{
|
||||
return QskAspect( m_bits.subControl, section, m_bits.type,
|
||||
m_bits.isAnimator, m_bits.primitive, m_bits.placement, m_bits.states );
|
||||
}
|
||||
|
||||
inline constexpr QskAspect QskAspect::operator|( Type type ) const noexcept
|
||||
{
|
||||
return QskAspect( m_bits.subControl, type, m_bits.isAnimator,
|
||||
m_bits.primitive, m_bits.placement, m_bits.states );
|
||||
return QskAspect( m_bits.subControl, m_bits.section, type,
|
||||
m_bits.isAnimator, m_bits.primitive, m_bits.placement, m_bits.states );
|
||||
}
|
||||
|
||||
inline constexpr QskAspect QskAspect::operator|( Primitive primitive ) const noexcept
|
||||
{
|
||||
return QskAspect( m_bits.subControl, m_bits.type, m_bits.isAnimator,
|
||||
primitive, m_bits.placement, m_bits.states );
|
||||
return QskAspect( m_bits.subControl, m_bits.section, m_bits.type,
|
||||
m_bits.isAnimator, primitive, m_bits.placement, m_bits.states );
|
||||
}
|
||||
|
||||
inline constexpr QskAspect QskAspect::operator|( Placement placement ) const noexcept
|
||||
{
|
||||
return QskAspect( m_bits.subControl, m_bits.type, m_bits.isAnimator,
|
||||
m_bits.primitive, placement, m_bits.states );
|
||||
return QskAspect( m_bits.subControl, m_bits.section, m_bits.type,
|
||||
m_bits.isAnimator, m_bits.primitive, placement, m_bits.states );
|
||||
}
|
||||
|
||||
inline constexpr QskAspect QskAspect::operator|( State state ) const noexcept
|
||||
{
|
||||
return QskAspect( m_bits.subControl, m_bits.type, m_bits.isAnimator,
|
||||
m_bits.primitive, m_bits.placement, m_bits.states | state );
|
||||
return QskAspect( m_bits.subControl, m_bits.section, m_bits.type,
|
||||
m_bits.isAnimator, m_bits.primitive, m_bits.placement, m_bits.states | state );
|
||||
}
|
||||
|
||||
inline QskAspect& QskAspect::operator|=( State state ) noexcept
|
||||
@ -302,7 +334,7 @@ inline QskAspect& QskAspect::operator|=( State state ) noexcept
|
||||
|
||||
inline constexpr QskAspect QskAspect::operator&( State state ) const noexcept
|
||||
{
|
||||
return QskAspect( m_bits.subControl, m_bits.type, m_bits.isAnimator,
|
||||
return QskAspect( m_bits.subControl, m_bits.section, m_bits.type, m_bits.isAnimator,
|
||||
m_bits.primitive, m_bits.placement, m_bits.states & state );
|
||||
}
|
||||
|
||||
@ -314,7 +346,7 @@ inline QskAspect& QskAspect::operator&=( State state ) noexcept
|
||||
|
||||
inline constexpr QskAspect QskAspect::operator|( States states ) const noexcept
|
||||
{
|
||||
return QskAspect( m_bits.subControl, m_bits.type, m_bits.isAnimator,
|
||||
return QskAspect( m_bits.subControl, m_bits.section, m_bits.type, m_bits.isAnimator,
|
||||
m_bits.primitive, m_bits.placement, m_bits.states | states );
|
||||
}
|
||||
|
||||
@ -326,8 +358,8 @@ inline QskAspect& QskAspect::operator|=( States states ) noexcept
|
||||
|
||||
inline constexpr QskAspect QskAspect::operator&( States states ) const noexcept
|
||||
{
|
||||
return QskAspect( m_bits.subControl, m_bits.type, m_bits.isAnimator,
|
||||
m_bits.primitive, m_bits.placement, m_bits.states & states );
|
||||
return QskAspect( m_bits.subControl, m_bits.section, m_bits.type,
|
||||
m_bits.isAnimator, m_bits.primitive, m_bits.placement, m_bits.states & states );
|
||||
}
|
||||
|
||||
inline QskAspect& QskAspect::operator&=( States states ) noexcept
|
||||
@ -338,14 +370,14 @@ inline QskAspect& QskAspect::operator&=( States states ) noexcept
|
||||
|
||||
inline constexpr QskAspect QskAspect::stateless() const noexcept
|
||||
{
|
||||
return QskAspect( m_bits.subControl, m_bits.type, m_bits.isAnimator,
|
||||
m_bits.primitive, m_bits.placement, 0 );
|
||||
return QskAspect( m_bits.subControl, m_bits.section, m_bits.type,
|
||||
m_bits.isAnimator, m_bits.primitive, m_bits.placement, 0 );
|
||||
}
|
||||
|
||||
inline constexpr QskAspect QskAspect::trunk() const noexcept
|
||||
{
|
||||
return QskAspect( m_bits.subControl, m_bits.type, m_bits.isAnimator,
|
||||
m_bits.primitive, 0, 0 );
|
||||
return QskAspect( m_bits.subControl, m_bits.section, m_bits.type,
|
||||
m_bits.isAnimator, m_bits.primitive, 0, 0 );
|
||||
}
|
||||
|
||||
inline constexpr quint64 QskAspect::value() const noexcept
|
||||
@ -373,6 +405,16 @@ inline void QskAspect::setSubControl( Subcontrol subControl ) noexcept
|
||||
m_bits.subControl = subControl;
|
||||
}
|
||||
|
||||
inline constexpr QskAspect::Section QskAspect::section() const noexcept
|
||||
{
|
||||
return static_cast< Section >( m_bits.section );
|
||||
}
|
||||
|
||||
inline void QskAspect::setSection( Section section ) noexcept
|
||||
{
|
||||
m_bits.section = section;
|
||||
}
|
||||
|
||||
inline constexpr QskAspect::Type QskAspect::type() const noexcept
|
||||
{
|
||||
return static_cast< Type >( m_bits.type );
|
||||
@ -490,6 +532,12 @@ inline constexpr QskAspect operator|(
|
||||
return aspect | subControl;
|
||||
}
|
||||
|
||||
inline constexpr QskAspect operator|(
|
||||
QskAspect::Section section, const QskAspect& aspect ) noexcept
|
||||
{
|
||||
return aspect | section;
|
||||
}
|
||||
|
||||
inline constexpr QskAspect operator|(
|
||||
QskAspect::Type type, const QskAspect& aspect ) noexcept
|
||||
{
|
||||
@ -502,6 +550,18 @@ inline constexpr QskAspect operator|(
|
||||
return aspect | placement;
|
||||
}
|
||||
|
||||
inline constexpr QskAspect operator|(
|
||||
QskAspect::Subcontrol subControl, QskAspect::Section section ) noexcept
|
||||
{
|
||||
return QskAspect( subControl ) | section;
|
||||
}
|
||||
|
||||
inline constexpr QskAspect operator|(
|
||||
QskAspect::Section section, QskAspect::Subcontrol subControl ) noexcept
|
||||
{
|
||||
return subControl | section;
|
||||
}
|
||||
|
||||
inline constexpr QskAspect operator|(
|
||||
QskAspect::Subcontrol subControl, QskAspect::Type type ) noexcept
|
||||
{
|
||||
|
@ -38,6 +38,7 @@ QskControl::QskControl( QQuickItem* parent )
|
||||
{
|
||||
// inheriting attributes from parent
|
||||
QskControlPrivate::resolveLocale( this );
|
||||
QskControlPrivate::resolveSection( this );
|
||||
}
|
||||
}
|
||||
|
||||
@ -240,9 +241,12 @@ void QskControl::setLocale( const QLocale& locale )
|
||||
|
||||
if ( d->locale != locale )
|
||||
{
|
||||
extern void qskInheritLocale( QObject*, const QLocale& );
|
||||
|
||||
d->locale = locale;
|
||||
qskSendEventTo( this, QEvent::LocaleChange );
|
||||
qskSetup->inheritLocale( this, locale );
|
||||
|
||||
qskInheritLocale( this, locale );
|
||||
}
|
||||
}
|
||||
|
||||
@ -257,6 +261,47 @@ void QskControl::resetLocale()
|
||||
}
|
||||
}
|
||||
|
||||
void QskControl::setSection( QskAspect::Section section )
|
||||
{
|
||||
if ( section > QskAspect::LastSection )
|
||||
{
|
||||
qWarning() << "Trying to set an invalid section, ignored";
|
||||
return;
|
||||
}
|
||||
|
||||
Q_D( QskControl );
|
||||
|
||||
d->explicitSection = true;
|
||||
|
||||
if ( d->section != section )
|
||||
{
|
||||
extern void qskInheritSection( QskControl*, const QskAspect::Section );
|
||||
|
||||
d->section = section;
|
||||
|
||||
update();
|
||||
resetImplicitSize();
|
||||
|
||||
qskInheritSection( this, section );
|
||||
}
|
||||
}
|
||||
|
||||
void QskControl::resetSection()
|
||||
{
|
||||
Q_D( QskControl );
|
||||
|
||||
if ( d->explicitSection )
|
||||
{
|
||||
d->explicitSection = false;
|
||||
QskControlPrivate::resolveSection( this );
|
||||
}
|
||||
}
|
||||
|
||||
QskAspect::Section QskControl::section() const
|
||||
{
|
||||
return static_cast< QskAspect::Section >( d_func()->section );
|
||||
}
|
||||
|
||||
void QskControl::initSizePolicy(
|
||||
QskSizePolicy::Policy horizontalPolicy,
|
||||
QskSizePolicy::Policy verticalPolicy )
|
||||
@ -809,6 +854,9 @@ void QskControl::itemChange( QQuickItem::ItemChange change,
|
||||
{
|
||||
if ( !d_func()->explicitLocale )
|
||||
QskControlPrivate::resolveLocale( this );
|
||||
|
||||
if ( !d_func()->explicitSection )
|
||||
QskControlPrivate::resolveSection( this );
|
||||
}
|
||||
|
||||
#if 1
|
||||
|
@ -26,6 +26,9 @@ class QSK_EXPORT QskControl : public QskQuickItem, public QskSkinnable
|
||||
Q_PROPERTY( QLocale locale READ locale
|
||||
WRITE setLocale RESET resetLocale NOTIFY localeChanged )
|
||||
|
||||
Q_PROPERTY( QskAspect::Section section READ section
|
||||
WRITE setSection RESET resetSection NOTIFY sectionChanged )
|
||||
|
||||
Q_PROPERTY( bool autoFillBackground READ autoFillBackground
|
||||
WRITE setAutoFillBackground )
|
||||
|
||||
@ -104,6 +107,10 @@ class QSK_EXPORT QskControl : public QskQuickItem, public QskSkinnable
|
||||
void setFocusPolicy( Qt::FocusPolicy );
|
||||
Qt::FocusPolicy focusPolicy() const;
|
||||
|
||||
void setSection( QskAspect::Section );
|
||||
void resetSection();
|
||||
QskAspect::Section section() const override final;
|
||||
|
||||
void setSizePolicy( QskSizePolicy );
|
||||
void setSizePolicy( QskSizePolicy::Policy, QskSizePolicy::Policy );
|
||||
void setSizePolicy( Qt::Orientation, QskSizePolicy::Policy );
|
||||
@ -175,6 +182,7 @@ class QSK_EXPORT QskControl : public QskQuickItem, public QskSkinnable
|
||||
|
||||
Q_SIGNALS:
|
||||
void backgroundChanged();
|
||||
void sectionChanged( QskAspect::Section );
|
||||
void marginsChanged( const QMarginsF& );
|
||||
void focusIndicatorRectChanged();
|
||||
void localeChanged( const QLocale& );
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include "QskControlPrivate.h"
|
||||
#include "QskSetup.h"
|
||||
#include "QskLayoutMetrics.h"
|
||||
#include "QskObjectTree.h"
|
||||
#include "QskWindow.h"
|
||||
|
||||
static inline void qskSendEventTo( QObject* object, QEvent::Type type )
|
||||
{
|
||||
@ -22,6 +24,108 @@ static inline QPointF qskScenePosition( const QMouseEvent* event )
|
||||
#endif
|
||||
}
|
||||
|
||||
extern bool qskInheritLocale( QskWindow*, const QLocale& );
|
||||
|
||||
namespace
|
||||
{
|
||||
class VisitorLocale final : public QskObjectTree::ResolveVisitor< QLocale >
|
||||
{
|
||||
public:
|
||||
VisitorLocale()
|
||||
: ResolveVisitor< QLocale >( "locale" )
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
bool setImplicitValue( QskControl* control,
|
||||
const QLocale& locale ) override
|
||||
{
|
||||
return QskControlPrivate::inheritLocale( control, locale );
|
||||
}
|
||||
|
||||
bool setImplicitValue( QskWindow* window,
|
||||
const QLocale& locale ) override
|
||||
{
|
||||
return qskInheritLocale( window, locale );
|
||||
}
|
||||
|
||||
QLocale value( const QskControl* control ) const override
|
||||
{
|
||||
return control->locale();
|
||||
}
|
||||
|
||||
QLocale value( const QskWindow* window ) const override
|
||||
{
|
||||
return window->locale();
|
||||
}
|
||||
};
|
||||
|
||||
class VisitorSection final : public QskObjectTree::ResolveVisitor< QskAspect::Section >
|
||||
{
|
||||
public:
|
||||
VisitorSection()
|
||||
: ResolveVisitor< QskAspect::Section >( "section" )
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
bool setImplicitValue( QskControl* control,
|
||||
const QskAspect::Section& section ) override
|
||||
{
|
||||
return QskControlPrivate::inheritSection( control, section );
|
||||
}
|
||||
|
||||
bool setImplicitValue( QskWindow*, const QskAspect::Section& ) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
QskAspect::Section value( const QskControl* control ) const override
|
||||
{
|
||||
return control->section();
|
||||
}
|
||||
|
||||
QskAspect::Section value( const QskWindow* ) const override
|
||||
{
|
||||
return QskAspect::Body;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
QLocale qskInheritedLocale( const QObject* object )
|
||||
{
|
||||
VisitorLocale visitor;
|
||||
visitor.setResolveValue( QLocale() );
|
||||
|
||||
QskObjectTree::traverseUp( const_cast< QObject* >( object ), visitor );
|
||||
return visitor.resolveValue();
|
||||
}
|
||||
|
||||
void qskInheritLocale( QObject* object, const QLocale& locale )
|
||||
{
|
||||
VisitorLocale visitor;
|
||||
visitor.setResolveValue( locale );
|
||||
|
||||
QskObjectTree::traverseDown( object, visitor );
|
||||
}
|
||||
|
||||
static QskAspect::Section qskInheritedSection( const QskControl* control )
|
||||
{
|
||||
VisitorSection visitor;
|
||||
visitor.setResolveValue( QskAspect::Body );
|
||||
|
||||
QskObjectTree::traverseUp( const_cast< QskControl* >( control ), visitor );
|
||||
return visitor.resolveValue();
|
||||
}
|
||||
|
||||
void qskInheritSection( QskControl* control, QskAspect::Section section )
|
||||
{
|
||||
VisitorSection visitor;
|
||||
visitor.setResolveValue( section );
|
||||
|
||||
QskObjectTree::traverseDown( control, visitor );
|
||||
}
|
||||
|
||||
/*
|
||||
Qt 5.12:
|
||||
sizeof( QQuickItemPrivate::ExtraData ) -> 184
|
||||
@ -52,6 +156,7 @@ QskControlPrivate::QskControlPrivate()
|
||||
, hiddenPlacementPolicy( 0 )
|
||||
, layoutAlignmentHint( 0 )
|
||||
, explicitLocale( false )
|
||||
, explicitSection( false )
|
||||
, autoFillBackground( false )
|
||||
, autoLayoutChildren( false )
|
||||
, focusPolicy( Qt::NoFocus )
|
||||
@ -255,7 +360,7 @@ bool QskControlPrivate::inheritLocale( QskControl* control, const QLocale& local
|
||||
|
||||
void QskControlPrivate::resolveLocale( QskControl* control )
|
||||
{
|
||||
const auto locale = qskSetup->inheritedLocale( control );
|
||||
const auto locale = qskInheritedLocale( control );
|
||||
|
||||
auto d = static_cast< QskControlPrivate* >( QQuickItemPrivate::get( control ) );
|
||||
if ( d->locale != locale )
|
||||
@ -263,7 +368,39 @@ void QskControlPrivate::resolveLocale( QskControl* control )
|
||||
d->locale = locale;
|
||||
|
||||
qskSendEventTo( control, QEvent::LocaleChange );
|
||||
qskSetup->inheritLocale( control, locale );
|
||||
qskInheritLocale( control, locale );
|
||||
}
|
||||
}
|
||||
|
||||
bool QskControlPrivate::inheritSection(
|
||||
QskControl* control, const QskAspect::Section section )
|
||||
{
|
||||
auto d = static_cast< QskControlPrivate* >( QQuickItemPrivate::get( control ) );
|
||||
|
||||
if ( d->explicitSection || d->section == section )
|
||||
return true;
|
||||
|
||||
d->section = section;
|
||||
|
||||
control->update();
|
||||
control->resetImplicitSize();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void QskControlPrivate::resolveSection( QskControl* control )
|
||||
{
|
||||
const auto section = qskInheritedSection( control );
|
||||
|
||||
auto d = static_cast< QskControlPrivate* >( QQuickItemPrivate::get( control ) );
|
||||
if ( d->section != section )
|
||||
{
|
||||
d->section = section;
|
||||
|
||||
control->update();
|
||||
control->resetImplicitSize();
|
||||
|
||||
qskInheritSection( control, section );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,9 @@ class QskControlPrivate : public QskQuickItemPrivate
|
||||
static bool inheritLocale( QskControl*, const QLocale& );
|
||||
static void resolveLocale( QskControl* );
|
||||
|
||||
static bool inheritSection( QskControl*, QskAspect::Section );
|
||||
static void resolveSection( QskControl* );
|
||||
|
||||
protected:
|
||||
QskControlPrivate();
|
||||
~QskControlPrivate() override;
|
||||
@ -51,8 +54,10 @@ class QskControlPrivate : public QskQuickItemPrivate
|
||||
unsigned int hiddenPlacementPolicy : 2;
|
||||
|
||||
unsigned int layoutAlignmentHint : 8;
|
||||
unsigned int section : 4;
|
||||
|
||||
bool explicitLocale : 1;
|
||||
bool explicitSection : 1;
|
||||
|
||||
bool autoFillBackground : 1;
|
||||
bool autoLayoutChildren : 1;
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include "QskControl.h"
|
||||
#include "QskControlPrivate.h"
|
||||
#include "QskGraphicProviderMap.h"
|
||||
#include "QskObjectTree.h"
|
||||
#include "QskSkin.h"
|
||||
#include "QskSkinManager.h"
|
||||
#include "QskWindow.h"
|
||||
@ -74,43 +73,6 @@ static void qskApplicationFilter()
|
||||
Q_CONSTRUCTOR_FUNCTION( qskApplicationHook )
|
||||
Q_COREAPP_STARTUP_FUNCTION( qskApplicationFilter )
|
||||
|
||||
extern bool qskInheritLocale( QskWindow*, const QLocale& );
|
||||
|
||||
namespace
|
||||
{
|
||||
class VisitorLocale final : public QskObjectTree::ResolveVisitor< QLocale >
|
||||
{
|
||||
public:
|
||||
VisitorLocale()
|
||||
: ResolveVisitor< QLocale >( "locale" )
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
bool setImplicitValue( QskControl* control,
|
||||
const QLocale& locale ) override
|
||||
{
|
||||
return QskControlPrivate::inheritLocale( control, locale );
|
||||
}
|
||||
|
||||
bool setImplicitValue( QskWindow* window,
|
||||
const QLocale& locale ) override
|
||||
{
|
||||
return qskInheritLocale( window, locale );
|
||||
}
|
||||
|
||||
QLocale value( const QskControl* control ) const override
|
||||
{
|
||||
return control->locale();
|
||||
}
|
||||
|
||||
QLocale value( const QskWindow* window ) const override
|
||||
{
|
||||
return window->locale();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
class QskSetup::PrivateData
|
||||
{
|
||||
public:
|
||||
@ -254,23 +216,6 @@ QskGraphicProvider* QskSetup::graphicProvider( const QString& providerId ) const
|
||||
return m_data->graphicProviders.provider( providerId );
|
||||
}
|
||||
|
||||
QLocale QskSetup::inheritedLocale( const QObject* object )
|
||||
{
|
||||
VisitorLocale visitor;
|
||||
visitor.setResolveValue( QLocale() );
|
||||
|
||||
QskObjectTree::traverseUp( const_cast< QObject* >( object ), visitor );
|
||||
return visitor.resolveValue();
|
||||
}
|
||||
|
||||
void QskSetup::inheritLocale( QObject* object, const QLocale& locale )
|
||||
{
|
||||
VisitorLocale visitor;
|
||||
visitor.setResolveValue( locale );
|
||||
|
||||
QskObjectTree::traverseDown( object, visitor );
|
||||
}
|
||||
|
||||
bool QskSetup::eventFilter( QObject* object, QEvent* event )
|
||||
{
|
||||
if ( auto control = qskControlCast( object ) )
|
||||
|
@ -16,8 +16,6 @@ class QskSkin;
|
||||
class QQuickItem;
|
||||
class QskGraphicProvider;
|
||||
|
||||
class QLocale;
|
||||
|
||||
#if defined( qskSetup )
|
||||
#undef qskSetup
|
||||
#endif
|
||||
@ -51,9 +49,6 @@ class QSK_EXPORT QskSetup : public QObject
|
||||
static void setup();
|
||||
static void cleanup();
|
||||
|
||||
QLocale inheritedLocale( const QObject* );
|
||||
void inheritLocale( QObject*, const QLocale& );
|
||||
|
||||
static QskSetup* qmlAttachedProperties( QObject* );
|
||||
|
||||
Q_SIGNALS:
|
||||
|
@ -14,7 +14,7 @@ inline const QVariant* qskResolvedHint( QskAspect aspect,
|
||||
const std::unordered_map< QskAspect, QVariant >& hints,
|
||||
QskAspect* resolvedAspect )
|
||||
{
|
||||
const auto a = aspect;
|
||||
auto a = aspect;
|
||||
|
||||
Q_FOREVER
|
||||
{
|
||||
@ -56,6 +56,16 @@ inline const QVariant* qskResolvedHint( QskAspect aspect,
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( aspect.section() != QskAspect::Body )
|
||||
{
|
||||
// try to resolve from QskAspect::Body
|
||||
|
||||
a.setSection( QskAspect::Body );
|
||||
aspect = a;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -838,6 +838,9 @@ QVariant QskSkinnable::effectiveSkinHint(
|
||||
{
|
||||
aspect.setSubControl( effectiveSubcontrol( aspect.subControl() ) );
|
||||
|
||||
if ( aspect.section() == QskAspect::Body )
|
||||
aspect.setSection( section() );
|
||||
|
||||
if ( aspect.placement() == QskAspect::NoPlacement )
|
||||
aspect.setPlacement( effectivePlacement() );
|
||||
|
||||
@ -1337,6 +1340,11 @@ QskAspect::Placement QskSkinnable::effectivePlacement() const
|
||||
return QskAspect::NoPlacement;
|
||||
}
|
||||
|
||||
QskAspect::Section QskSkinnable::section() const
|
||||
{
|
||||
return QskAspect::Body;
|
||||
}
|
||||
|
||||
void QskSkinnable::updateNode( QSGNode* parentNode )
|
||||
{
|
||||
effectiveSkinlet()->updateNode( this, parentNode );
|
||||
|
@ -103,6 +103,8 @@ class QSK_EXPORT QskSkinnable
|
||||
QVariant effectiveSkinHint( QskAspect, QskSkinHintStatus* = nullptr ) const;
|
||||
virtual QskAspect::Placement effectivePlacement() const;
|
||||
|
||||
virtual QskAspect::Section section() const;
|
||||
|
||||
QskSkinHintStatus hintStatus( QskAspect ) const;
|
||||
|
||||
QRectF subControlRect( const QRectF&, QskAspect::Subcontrol ) const;
|
||||
|
@ -34,6 +34,9 @@ Q_LOGGING_CATEGORY( logTiming, "qsk.window.timing", QtCriticalMsg )
|
||||
|
||||
#endif
|
||||
|
||||
extern QLocale qskInheritedLocale( const QObject* );
|
||||
extern void qskInheritLocale( QObject*, const QLocale& );
|
||||
|
||||
static void qskResolveLocale( QskWindow* );
|
||||
static bool qskEnforcedSkin = false;
|
||||
|
||||
@ -423,7 +426,7 @@ void QskWindow::setLocale( const QLocale& locale )
|
||||
{
|
||||
d->locale = locale;
|
||||
qskSendEventTo( this, QEvent::LocaleChange );
|
||||
qskSetup->inheritLocale( this, locale );
|
||||
qskInheritLocale( this, locale );
|
||||
}
|
||||
}
|
||||
|
||||
@ -452,14 +455,14 @@ static void qskResolveLocale( QskWindow* window )
|
||||
{
|
||||
auto d = static_cast< QskWindowPrivate* >( QQuickWindowPrivate::get( window ) );
|
||||
|
||||
const QLocale locale = qskSetup->inheritedLocale( window );
|
||||
const auto locale = qskInheritedLocale( window );
|
||||
|
||||
if ( d->locale != locale )
|
||||
{
|
||||
d->locale = locale;
|
||||
qskSendEventTo( window, QEvent::LocaleChange );
|
||||
|
||||
qskSetup->inheritLocale( window, locale );
|
||||
qskInheritLocale( window, locale );
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user