2023-05-01 23:00:15 +00:00
|
|
|
#include "QskDrawer.h"
|
2023-04-25 21:28:42 +00:00
|
|
|
#include "QskAspect.h"
|
2023-04-26 21:35:28 +00:00
|
|
|
#include "QskControl.h"
|
2023-05-01 23:00:15 +00:00
|
|
|
|
2023-04-25 21:07:51 +00:00
|
|
|
#include <QskPopup.h>
|
|
|
|
#include <QskBox.h>
|
|
|
|
#include <QskAnimationHint.h>
|
|
|
|
#include <QskQuick.h>
|
2023-05-01 23:00:15 +00:00
|
|
|
|
|
|
|
QSK_SUBCONTROL( QskDrawer, DasPanel )
|
|
|
|
|
|
|
|
class QskDrawer::PrivateData {
|
|
|
|
public:
|
2023-04-26 21:35:28 +00:00
|
|
|
QskControl* content;
|
|
|
|
QskBox* contentBox;
|
2023-05-01 23:00:15 +00:00
|
|
|
Qt::Edge edge = Qt::LeftEdge;
|
|
|
|
};
|
|
|
|
|
|
|
|
QskDrawer::QskDrawer( QQuickItem* parentItem ) :
|
|
|
|
Inherited ( parentItem )
|
|
|
|
, m_data( new PrivateData { } )
|
|
|
|
{
|
|
|
|
setZ( 1 );
|
|
|
|
|
|
|
|
setPopupFlag( PopupFlag::CloseOnPressOutside, true );
|
|
|
|
|
2023-04-26 21:35:28 +00:00
|
|
|
m_data->contentBox = new QskBox(this);
|
|
|
|
m_data->contentBox->setSubcontrolProxy( QskBox::Panel, DasPanel );
|
2023-04-25 21:00:41 +00:00
|
|
|
|
2023-04-25 21:28:08 +00:00
|
|
|
setAnimationHint( DasPanel | QskAspect::Position, QskAnimationHint( 1000 ) );
|
2023-04-25 20:43:51 +00:00
|
|
|
|
2023-05-01 23:00:15 +00:00
|
|
|
setFaderAspect( DasPanel | QskAspect::Metric );
|
|
|
|
|
2023-04-25 21:28:42 +00:00
|
|
|
setSkinHint( Overlay | QskAspect::Style, false );
|
2023-05-01 23:00:15 +00:00
|
|
|
|
2023-04-25 19:40:24 +00:00
|
|
|
connect(this, &QskDrawer::closed, this, [this](){
|
2023-04-25 21:00:41 +00:00
|
|
|
startTransition( DasPanel | QskAspect::Metric,
|
2023-04-25 21:28:08 +00:00
|
|
|
animationHint( DasPanel | QskAspect::Position ),
|
|
|
|
0.0, 1.0 );
|
2023-04-25 19:40:24 +00:00
|
|
|
});
|
2023-05-01 23:00:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QskDrawer::~QskDrawer()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Qt::Edge QskDrawer::edge() const {
|
|
|
|
return m_data->edge;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QskDrawer::setEdge( Qt::Edge edge ) {
|
|
|
|
if( m_data->edge == edge ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_data->edge = edge;
|
|
|
|
edgeChanged( edge );
|
|
|
|
}
|
|
|
|
|
2023-04-26 21:35:28 +00:00
|
|
|
void QskDrawer::setContent( QskControl* content ) {
|
|
|
|
content->setParentItem( m_data->contentBox );
|
|
|
|
m_data->content = content;
|
2023-05-01 23:00:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void QskDrawer::updateLayout() {
|
2023-04-26 21:35:28 +00:00
|
|
|
auto size = m_data->content->preferredSize();
|
|
|
|
|
2023-05-01 23:00:15 +00:00
|
|
|
switch( m_data->edge ) {
|
|
|
|
case Qt::Edge::LeftEdge:
|
|
|
|
case Qt::Edge::RightEdge:
|
|
|
|
// rect.setWidth( m_data->control->preferredSize().width() );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Qt::Edge::TopEdge:
|
|
|
|
case Qt::Edge::BottomEdge:
|
|
|
|
// rect.setHeight( m_data->control->preferredSize().height() );
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
qreal off = metric( faderAspect() ) * size.width();
|
2023-04-26 21:35:28 +00:00
|
|
|
qskSetItemGeometry( m_data->contentBox, -off, 0, size.width(), size.height());
|
|
|
|
|
2023-05-01 23:00:15 +00:00
|
|
|
Inherited::updateLayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QskDrawer::aboutToShow()
|
|
|
|
{
|
2023-04-25 21:28:08 +00:00
|
|
|
startTransition( DasPanel | QskAspect::Metric,
|
|
|
|
animationHint( DasPanel | QskAspect::Position ),
|
|
|
|
1.0, 0.0 );
|
2023-05-01 23:00:15 +00:00
|
|
|
Inherited::aboutToShow();
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "moc_QskDrawer.cpp"
|