making the panel optional
This commit is contained in:
parent
16d071489e
commit
01d5fedca7
|
@ -8,7 +8,13 @@
|
|||
QSK_SUBCONTROL( QskBox, Panel )
|
||||
|
||||
QskBox::QskBox( QQuickItem* parent )
|
||||
: QskBox( true, parent )
|
||||
{
|
||||
}
|
||||
|
||||
QskBox::QskBox( bool hasPanel, QQuickItem* parent )
|
||||
: Inherited( parent )
|
||||
, m_hasPanel( hasPanel )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -16,13 +22,36 @@ QskBox::~QskBox()
|
|||
{
|
||||
}
|
||||
|
||||
void QskBox::setPanel( bool on )
|
||||
{
|
||||
if ( on != m_hasPanel )
|
||||
{
|
||||
m_hasPanel = on;
|
||||
|
||||
resetImplicitSize();
|
||||
polish();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
bool QskBox::hasPanel() const
|
||||
{
|
||||
return m_hasPanel;
|
||||
}
|
||||
|
||||
QRectF QskBox::layoutRectForSize( const QSizeF& size ) const
|
||||
{
|
||||
if ( !m_hasPanel )
|
||||
return Inherited::layoutRectForSize( size );
|
||||
|
||||
return innerBox( Panel, subControlRect( size, Panel ) );
|
||||
}
|
||||
|
||||
QSizeF QskBox::contentsSizeHint() const
|
||||
{
|
||||
if ( !m_hasPanel )
|
||||
return Inherited::contentsSizeHint();
|
||||
|
||||
QSizeF size( -1, -1 );
|
||||
|
||||
if ( autoLayoutChildren() )
|
||||
|
|
|
@ -14,14 +14,28 @@ class QSK_EXPORT QskBox : public QskControl
|
|||
|
||||
using Inherited = QskControl;
|
||||
|
||||
Q_PROPERTY( bool panel READ hasPanel
|
||||
WRITE setPanel NOTIFY panelChanged FINAL )
|
||||
|
||||
public:
|
||||
QSK_SUBCONTROLS( Panel )
|
||||
|
||||
QskBox( QQuickItem* parent = nullptr );
|
||||
QskBox( bool hasPanel, QQuickItem* parent = nullptr );
|
||||
|
||||
~QskBox() override;
|
||||
|
||||
void setPanel( bool );
|
||||
bool hasPanel() const;
|
||||
|
||||
QRectF layoutRectForSize( const QSizeF& ) const override;
|
||||
QSizeF contentsSizeHint() const override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void panelChanged( bool );
|
||||
|
||||
private:
|
||||
bool m_hasPanel;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,10 +30,15 @@ QRectF QskBoxSkinlet::subControlRect( const QskSkinnable* skinnable,
|
|||
QSGNode* QskBoxSkinlet::updateSubNode(
|
||||
const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const
|
||||
{
|
||||
const auto box = static_cast< const QskBox* >( skinnable );
|
||||
|
||||
switch ( nodeRole )
|
||||
{
|
||||
case PanelRole:
|
||||
{
|
||||
if ( !box->hasPanel() )
|
||||
return nullptr;
|
||||
|
||||
return updateBoxNode( skinnable, node, QskBox::Panel );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue