transitioning for QskSubWindow added

This commit is contained in:
Uwe Rathmann 2023-10-31 08:08:08 +01:00
parent 6a11179cc9
commit 615fcffe44
5 changed files with 44 additions and 19 deletions

View File

@ -72,13 +72,13 @@ QskMenu::QskMenu( QQuickItem* parent )
initSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed ); initSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed );
// we hide the focus indicator while sliding // we hide the focus indicator while sliding
connect( this, &QskMenu::transitioningChanged, connect( this, &QskPopup::transitioningChanged,
this, &QskControl::focusIndicatorRectChanged ); this, &QskControl::focusIndicatorRectChanged );
connect( this, &QskPopup::transitioningChanged, connect( this, &QskPopup::transitioningChanged,
this, &QQuickItem::setClip ); this, &QQuickItem::setClip );
connect( this, &QskMenu::opened, this, connect( this, &QskPopup::opened, this,
[this]() { m_data->triggeredIndex = -1; } ); [this]() { m_data->triggeredIndex = -1; } );
setAcceptHoverEvents( true ); setAcceptHoverEvents( true );
@ -283,11 +283,13 @@ QString QskMenu::triggeredText() const
void QskMenu::updateResources() void QskMenu::updateResources()
{ {
const auto size = sizeConstraint(); if ( isTransitioning() )
const auto dy = ( 1.0 - transitioningFactor() ) * size.height(); {
const auto dy = ( 1.0 - transitioningFactor() ) * height();
setPosition( m_data->origin.x(), m_data->origin.y() - dy );
}
setGeometry( m_data->origin.x(), m_data->origin.y() - dy, Inherited::updateResources();
size.width(), size.height() );
} }
void QskMenu::updateNode( QSGNode* node ) void QskMenu::updateNode( QSGNode* node )
@ -485,6 +487,8 @@ void QskMenu::mouseReleaseEvent( QMouseEvent* event )
void QskMenu::aboutToShow() void QskMenu::aboutToShow()
{ {
setSize( sizeConstraint() );
if ( m_data->currentIndex < 0 ) if ( m_data->currentIndex < 0 )
{ {
if ( !m_data->actions.isEmpty() ) if ( !m_data->actions.isEmpty() )

View File

@ -253,4 +253,10 @@ void QskSubWindow::itemChange( QQuickItem::ItemChange change,
} }
} }
void QskSubWindow::updateResources()
{
setOpacity( transitioningFactor() );
Inherited::updateResources();
}
#include "moc_QskSubWindow.cpp" #include "moc_QskSubWindow.cpp"

View File

@ -95,6 +95,8 @@ class QSK_EXPORT QskSubWindow : public QskPopup
bool event( QEvent* ) override; bool event( QEvent* ) override;
void updateLayout() override; void updateLayout() override;
void updateResources() override;
QSizeF layoutSizeHint( Qt::SizeHint, const QSizeF& ) const override; QSizeF layoutSizeHint( Qt::SizeHint, const QSizeF& ) const override;
void itemChange( QQuickItem::ItemChange, void itemChange( QQuickItem::ItemChange,

View File

@ -94,6 +94,18 @@ QSGNode* QskSubWindowSkinlet::updateSubNode(
return nullptr; return nullptr;
} }
case OverlayRole:
{
/*
Overloading QskPopupSkinlet: as the opacity of the subwindow already
depends on the transitioningFactor we do not want the additional opacity
adjustments for the overlay node.
Maybe we should have a flag that indicates if the popup does
opacity or geometry transitions, when opening/closing TODO ...
*/
updateBoxNode( subWindow, node, Q::Overlay );
break;
}
} }
return Inherited::updateSubNode( skinnable, nodeRole, node ); return Inherited::updateSubNode( skinnable, nodeRole, node );

View File

@ -77,6 +77,7 @@ static void qskSetupSubWindow(
const QString& title, QskDialog::Actions actions, const QString& title, QskDialog::Actions actions,
QskDialog::Action defaultAction, QskDialogSubWindow* subWindow ) QskDialog::Action defaultAction, QskDialogSubWindow* subWindow )
{ {
subWindow->setPopupFlag( QskPopup::DeleteOnClose );
subWindow->setModal( true ); subWindow->setModal( true );
subWindow->setWindowTitle( title ); subWindow->setWindowTitle( title );
subWindow->setDialogActions( actions ); subWindow->setDialogActions( actions );
@ -128,14 +129,14 @@ static QskDialog::Action qskMessageSubWindow(
const QString& text, int symbolType, QskDialog::Actions actions, const QString& text, int symbolType, QskDialog::Actions actions,
QskDialog::Action defaultAction ) QskDialog::Action defaultAction )
{ {
QskMessageSubWindow subWindow( window->contentItem() ); auto subWindow = new QskMessageSubWindow( window->contentItem() );
subWindow.setSymbolType( symbolType ); subWindow->setSymbolType( symbolType );
subWindow.setText( text ); subWindow->setText( text );
qskSetupSubWindow( title, actions, defaultAction, &subWindow ); qskSetupSubWindow( title, actions, defaultAction, subWindow );
( void ) subWindow.exec(); ( void ) subWindow->exec();
auto clickedAction = subWindow.clickedAction(); auto clickedAction = subWindow->clickedAction();
if ( clickedAction == QskDialog::NoAction ) if ( clickedAction == QskDialog::NoAction )
{ {
// dialog might have been closed by the window menu // dialog might have been closed by the window menu
@ -172,16 +173,16 @@ static QString qskSelectSubWindow(
QskDialog::Actions actions, QskDialog::Action defaultAction, QskDialog::Actions actions, QskDialog::Action defaultAction,
const QStringList& entries, int selectedRow ) const QStringList& entries, int selectedRow )
{ {
QskSelectionSubWindow subWindow( window->contentItem() ); auto subWindow = new QskSelectionSubWindow( window->contentItem() );
subWindow.setInfoText( text ); subWindow->setInfoText( text );
subWindow.setEntries( entries ); subWindow->setEntries( entries );
subWindow.setSelectedRow( selectedRow ); subWindow->setSelectedRow( selectedRow );
QString selectedEntry; QString selectedEntry;
qskSetupSubWindow( title, actions, defaultAction, &subWindow ); qskSetupSubWindow( title, actions, defaultAction, subWindow );
if ( subWindow.exec() == QskDialog::Accepted ) if ( subWindow->exec() == QskDialog::Accepted )
selectedEntry = subWindow.selectedEntry(); selectedEntry = subWindow->selectedEntry();
return selectedEntry; return selectedEntry;
} }