[libcalamaresui] There is code in Qt for setting up QML widgets

- The not-publicly documented setContent() method does all the
   parenting and resizing needed; some of this isn't available
   from outside of the widget either.

The QML slideshow now sizes and re-sizes correctly.
This commit is contained in:
Adriaan de Groot 2019-06-03 10:38:29 +02:00
parent f52d62034b
commit 2b5cf9e613

View File

@ -151,17 +151,17 @@ ExecutionViewStep::onActivate()
loadQml(); loadQml();
if ( m_qmlComponent ) if ( m_qmlComponent )
{ {
auto* rootItem = m_qmlShow->quickWindow()->contentItem();
rootItem->setSize( m_qmlShow->size() );
QObject* o = m_qmlComponent->create(); QObject* o = m_qmlComponent->create();
m_qmlObject = qobject_cast< QQuickItem* >( o ); m_qmlObject = qobject_cast< QQuickItem* >( o );
if ( !m_qmlObject ) if ( !m_qmlObject )
delete o; delete o;
else else
{ {
m_qmlObject->setParentItem( rootItem ); // setContent() is public API, but not documented publicly.
m_qmlObject->setSize( m_qmlShow->size() ); // It is marked \internal in the Qt sources, but does exactly
// what is needed: sets up visual parent by replacing the root
// item, and handling resizes.
m_qmlShow->setContent( QUrl::fromLocalFile( Calamares::Branding::instance()->slideshowPath() ), m_qmlComponent, m_qmlObject );
} }
} }