qskinny/src/controls/QskBox.cpp

76 lines
1.5 KiB
C++
Raw Normal View History

2017-07-21 18:21:34 +02:00
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/
#include "QskBox.h"
#include "QskMargins.h"
2017-07-21 18:21:34 +02:00
QSK_SUBCONTROL( QskBox, Panel )
2018-08-03 08:15:28 +02:00
QskBox::QskBox( QQuickItem* parent )
2019-05-10 07:44:13 +02:00
: QskBox( true, parent )
{
}
QskBox::QskBox( bool hasPanel, QQuickItem* parent )
2018-08-03 08:15:28 +02:00
: Inherited( parent )
2019-05-10 07:44:13 +02:00
, m_hasPanel( hasPanel )
2017-07-21 18:21:34 +02:00
{
}
QskBox::~QskBox()
{
}
2019-05-10 07:44:13 +02:00
void QskBox::setPanel( bool on )
{
if ( on != m_hasPanel )
{
m_hasPanel = on;
resetImplicitSize();
polish();
update();
}
}
bool QskBox::hasPanel() const
{
return m_hasPanel;
}
2019-09-20 07:04:17 +02:00
void QskBox::setPadding( qreal padding )
{
2020-12-27 11:15:34 +01:00
setPadding( QskMargins( padding ) );
2019-09-20 07:04:17 +02:00
}
void QskBox::setPadding( const QMarginsF& padding )
{
2020-12-27 11:15:34 +01:00
const auto pd = QskMargins().expandedTo( padding );
2019-09-20 07:04:17 +02:00
if ( setPaddingHint( Panel, pd ) )
2019-09-20 07:04:17 +02:00
Q_EMIT paddingChanged( pd );
}
void QskBox::resetPadding()
{
2020-12-15 11:01:00 +01:00
if ( resetPaddingHint( Panel ) )
2020-12-27 11:15:34 +01:00
Q_EMIT paddingChanged( paddingHint( Panel ) );
2019-09-20 07:04:17 +02:00
}
QMarginsF QskBox::padding() const
{
2020-12-15 11:01:00 +01:00
return paddingHint( Panel );
2019-09-20 07:04:17 +02:00
}
QRectF QskBox::layoutRectForSize( const QSizeF& size ) const
2018-08-03 08:15:28 +02:00
{
2020-12-29 12:57:03 +01:00
if ( m_hasPanel )
return subControlContentsRect( size, Panel );
2019-05-10 07:44:13 +02:00
2020-12-29 12:57:03 +01:00
return Inherited::layoutRectForSize( size );
2017-07-21 18:21:34 +02:00
}
#include "moc_QskBox.cpp"