subwindows: Allow fading out

Resolves #10
This commit is contained in:
Peter Hartmann 2023-09-30 08:52:34 +02:00
parent 7cf88e7b45
commit 66b40cb198
4 changed files with 37 additions and 13 deletions

View File

@ -1877,6 +1877,8 @@ void Editor::setupSubWindow( const QskFluent2Theme& theme )
using Q = QskSubWindow;
const auto& pal = theme.palette;
setAnimation( Q::Panel | QskAspect::Position, 150 );
setPadding( Q::Panel, { 0, 31, 0, 0 } );
setBoxShape( Q::Panel, 7 );
setBoxBorderMetrics( Q::Panel, 1 );

View File

@ -1236,6 +1236,8 @@ void Editor::setupSubWindow()
using A = QskAspect;
using Q = QskSubWindow;
setAnimation( Q::Panel | QskAspect::Position, 150 );
// Panel
setPadding( Q::Panel, { 24_dp, 0, 24_dp, 24_dp } );

View File

@ -4,6 +4,7 @@
*****************************************************************************/
#include "QskPopup.h"
#include "QskAnimationHint.h"
#include "QskAspect.h"
#include "QskInputGrabber.h"
#include "QskQuick.h"
@ -638,8 +639,23 @@ int QskPopup::execPopup()
*/
connect( popup, &QObject::destroyed, this, &EventLoop::reject );
connect( popup, &QskPopup::fadingChanged, this, &EventLoop::maybeQuit );
connect( popup, &QskPopup::openChanged, this, &EventLoop::maybeQuit );
connect( popup, &QskPopup::fadingChanged, this, [this, popup]()
{
if ( !popup->isOpen() && !popup->isFading() )
{
QEventLoop::exit( 0 );
}
});
connect( popup, &QskPopup::openChanged, this, [this, popup]()
{
if( popup->faderAspect().value() == 0
|| popup->animationHint( popup->faderAspect().subControl() | QskAspect::Position ).duration <= 0 )
{
QEventLoop::exit( 0 );
} // otherwise wait for the fading to finish
});
}
private:
@ -648,17 +664,6 @@ int QskPopup::execPopup()
setParent( nullptr );
QEventLoop::exit( 1 );
}
void maybeQuit()
{
if ( auto popup = qobject_cast< const QskPopup* >( parent() ) )
{
if ( popup->isOpen() || popup->isFading() )
return;
}
QEventLoop::exit( 0 );
}
};
if ( isOpen() || isFading() )

View File

@ -4,6 +4,7 @@
*****************************************************************************/
#include "QskSubWindow.h"
#include "QskAnimationHint.h"
#include "QskAspect.h"
#include "QskPlatform.h"
#include "QskGraphic.h"
@ -49,7 +50,15 @@ QskSubWindow::QskSubWindow( QQuickItem* parent )
setMargins( 0 );
initSizePolicy( QskSizePolicy::MinimumExpanding, QskSizePolicy::MinimumExpanding );
setFaderAspect( Panel | QskAspect::Metric );
setAutoLayoutChildren( true );
connect(this, &QskSubWindow::closed, this, [this]() {
startTransition( Panel | QskAspect::Metric,
animationHint( Panel | QskAspect::Position ),
0.0, 1.0 );
});
}
QskSubWindow::~QskSubWindow()
@ -189,6 +198,12 @@ bool QskSubWindow::event( QEvent* event )
void QskSubWindow::updateLayout()
{
if( isFading() )
{
const auto opacity = 1 - metric( faderAspect() );
setOpacity( opacity );
}
if ( m_data->isWindowIconSourceDirty )
{
if ( !m_data->windowIconSource.isEmpty() )