[libcalamaresui] Manual QML loading trickery

- The slideshow item needs a parent to be visible,
 - QML gets size 0,0 unless explicitly sized to the surrounding widget.
This commit is contained in:
Adriaan de Groot 2019-06-02 14:27:12 +02:00
parent 103decab68
commit f52d62034b
2 changed files with 16 additions and 5 deletions

View File

@ -38,6 +38,7 @@
#include <QProgressBar>
#include <QQmlComponent>
#include <QQmlEngine>
#include <QQuickItem>
#include <QQuickWidget>
#include <QVBoxLayout>
@ -150,9 +151,18 @@ ExecutionViewStep::onActivate()
loadQml();
if ( m_qmlComponent )
{
m_qmlObject = m_qmlComponent->create();
cDebug() << "Created QML object" << (void *)m_qmlObject << m_qmlObject->objectName();
cDebug() << "Show root" << m_qmlShow->rootObject() << "context" << m_qmlShow->rootContext();
auto* rootItem = m_qmlShow->quickWindow()->contentItem();
rootItem->setSize( m_qmlShow->size() );
QObject* o = m_qmlComponent->create();
m_qmlObject = qobject_cast< QQuickItem* >( o );
if ( !m_qmlObject )
delete o;
else
{
m_qmlObject->setParentItem( rootItem );
m_qmlObject->setSize( m_qmlShow->size() );
}
}
JobQueue* queue = JobQueue::instance();

View File

@ -27,8 +27,9 @@
class QLabel;
class QObject;
class QProgressBar;
class QQuickWidget;
class QQmlComponent;
class QQuickItem;
class QQuickWidget;
namespace Calamares
{
@ -65,7 +66,7 @@ private:
QLabel* m_label;
QQuickWidget* m_qmlShow;
QQmlComponent* m_qmlComponent;
QObject* m_qmlObject; //< The actual show
QQuickItem* m_qmlObject; //< The actual show
QStringList m_jobInstanceKeys;