From 615fcffe440129edfb3e47315baf3d0aba5743d5 Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Tue, 31 Oct 2023 08:08:08 +0100 Subject: [PATCH] transitioning for QskSubWindow added --- src/controls/QskMenu.cpp | 16 ++++++++++------ src/controls/QskSubWindow.cpp | 6 ++++++ src/controls/QskSubWindow.h | 2 ++ src/controls/QskSubWindowSkinlet.cpp | 12 ++++++++++++ src/dialogs/QskDialog.cpp | 27 ++++++++++++++------------- 5 files changed, 44 insertions(+), 19 deletions(-) diff --git a/src/controls/QskMenu.cpp b/src/controls/QskMenu.cpp index 3ef4c805..e7a5cd9f 100644 --- a/src/controls/QskMenu.cpp +++ b/src/controls/QskMenu.cpp @@ -72,13 +72,13 @@ QskMenu::QskMenu( QQuickItem* parent ) initSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed ); // we hide the focus indicator while sliding - connect( this, &QskMenu::transitioningChanged, + connect( this, &QskPopup::transitioningChanged, this, &QskControl::focusIndicatorRectChanged ); connect( this, &QskPopup::transitioningChanged, this, &QQuickItem::setClip ); - connect( this, &QskMenu::opened, this, + connect( this, &QskPopup::opened, this, [this]() { m_data->triggeredIndex = -1; } ); setAcceptHoverEvents( true ); @@ -283,11 +283,13 @@ QString QskMenu::triggeredText() const void QskMenu::updateResources() { - const auto size = sizeConstraint(); - const auto dy = ( 1.0 - transitioningFactor() ) * size.height(); + if ( isTransitioning() ) + { + 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, - size.width(), size.height() ); + Inherited::updateResources(); } void QskMenu::updateNode( QSGNode* node ) @@ -485,6 +487,8 @@ void QskMenu::mouseReleaseEvent( QMouseEvent* event ) void QskMenu::aboutToShow() { + setSize( sizeConstraint() ); + if ( m_data->currentIndex < 0 ) { if ( !m_data->actions.isEmpty() ) diff --git a/src/controls/QskSubWindow.cpp b/src/controls/QskSubWindow.cpp index c278a889..728a1f24 100644 --- a/src/controls/QskSubWindow.cpp +++ b/src/controls/QskSubWindow.cpp @@ -253,4 +253,10 @@ void QskSubWindow::itemChange( QQuickItem::ItemChange change, } } +void QskSubWindow::updateResources() +{ + setOpacity( transitioningFactor() ); + Inherited::updateResources(); +} + #include "moc_QskSubWindow.cpp" diff --git a/src/controls/QskSubWindow.h b/src/controls/QskSubWindow.h index 47d08e5f..76bb5d52 100644 --- a/src/controls/QskSubWindow.h +++ b/src/controls/QskSubWindow.h @@ -95,6 +95,8 @@ class QSK_EXPORT QskSubWindow : public QskPopup bool event( QEvent* ) override; void updateLayout() override; + void updateResources() override; + QSizeF layoutSizeHint( Qt::SizeHint, const QSizeF& ) const override; void itemChange( QQuickItem::ItemChange, diff --git a/src/controls/QskSubWindowSkinlet.cpp b/src/controls/QskSubWindowSkinlet.cpp index beea972b..771b0668 100644 --- a/src/controls/QskSubWindowSkinlet.cpp +++ b/src/controls/QskSubWindowSkinlet.cpp @@ -94,6 +94,18 @@ QSGNode* QskSubWindowSkinlet::updateSubNode( 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 ); diff --git a/src/dialogs/QskDialog.cpp b/src/dialogs/QskDialog.cpp index cb1b5da7..d75b5b4e 100644 --- a/src/dialogs/QskDialog.cpp +++ b/src/dialogs/QskDialog.cpp @@ -77,6 +77,7 @@ static void qskSetupSubWindow( const QString& title, QskDialog::Actions actions, QskDialog::Action defaultAction, QskDialogSubWindow* subWindow ) { + subWindow->setPopupFlag( QskPopup::DeleteOnClose ); subWindow->setModal( true ); subWindow->setWindowTitle( title ); subWindow->setDialogActions( actions ); @@ -128,14 +129,14 @@ static QskDialog::Action qskMessageSubWindow( const QString& text, int symbolType, QskDialog::Actions actions, QskDialog::Action defaultAction ) { - QskMessageSubWindow subWindow( window->contentItem() ); - subWindow.setSymbolType( symbolType ); - subWindow.setText( text ); + auto subWindow = new QskMessageSubWindow( window->contentItem() ); + subWindow->setSymbolType( symbolType ); + subWindow->setText( text ); - qskSetupSubWindow( title, actions, defaultAction, &subWindow ); - ( void ) subWindow.exec(); + qskSetupSubWindow( title, actions, defaultAction, subWindow ); + ( void ) subWindow->exec(); - auto clickedAction = subWindow.clickedAction(); + auto clickedAction = subWindow->clickedAction(); if ( clickedAction == QskDialog::NoAction ) { // dialog might have been closed by the window menu @@ -172,16 +173,16 @@ static QString qskSelectSubWindow( QskDialog::Actions actions, QskDialog::Action defaultAction, const QStringList& entries, int selectedRow ) { - QskSelectionSubWindow subWindow( window->contentItem() ); - subWindow.setInfoText( text ); - subWindow.setEntries( entries ); - subWindow.setSelectedRow( selectedRow ); + auto subWindow = new QskSelectionSubWindow( window->contentItem() ); + subWindow->setInfoText( text ); + subWindow->setEntries( entries ); + subWindow->setSelectedRow( selectedRow ); QString selectedEntry; - qskSetupSubWindow( title, actions, defaultAction, &subWindow ); - if ( subWindow.exec() == QskDialog::Accepted ) - selectedEntry = subWindow.selectedEntry(); + qskSetupSubWindow( title, actions, defaultAction, subWindow ); + if ( subWindow->exec() == QskDialog::Accepted ) + selectedEntry = subWindow->selectedEntry(); return selectedEntry; }