[libcalamaresui] Shuffle code for QML slideshow
- Create widgets earlier - Group layouting code - Add retranslator only once, not on every activate - Load QML only once, preferably at activation
This commit is contained in:
parent
cbe14bbf03
commit
5973dbf74c
@ -46,31 +46,36 @@ namespace Calamares
|
||||
ExecutionViewStep::ExecutionViewStep( QObject* parent )
|
||||
: ViewStep( parent )
|
||||
, m_widget( new QWidget )
|
||||
, m_progressBar( new QProgressBar )
|
||||
, m_label( new QLabel )
|
||||
, m_qmlShow( new QQuickWidget )
|
||||
, m_qmlShowLoaded( false )
|
||||
{
|
||||
m_progressBar = new QProgressBar;
|
||||
m_progressBar->setMaximum( 10000 );
|
||||
m_label = new QLabel;
|
||||
QVBoxLayout* layout = new QVBoxLayout( m_widget );
|
||||
QVBoxLayout* innerLayout = new QVBoxLayout;
|
||||
|
||||
m_qmlShow = new QQuickWidget;
|
||||
layout->addWidget( m_qmlShow );
|
||||
CalamaresUtils::unmarginLayout( layout );
|
||||
m_progressBar->setMaximum( 10000 );
|
||||
|
||||
layout->addLayout( innerLayout );
|
||||
m_qmlShow->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
|
||||
m_qmlShow->setResizeMode( QQuickWidget::SizeRootObjectToView );
|
||||
|
||||
m_qmlShow->engine()->addImportPath( CalamaresUtils::qmlModulesDir().absolutePath() );
|
||||
|
||||
layout->addWidget( m_qmlShow );
|
||||
CalamaresUtils::unmarginLayout( layout );
|
||||
layout->addLayout( innerLayout );
|
||||
|
||||
innerLayout->addSpacing( CalamaresUtils::defaultFontHeight() / 2 );
|
||||
innerLayout->addWidget( m_progressBar );
|
||||
innerLayout->addWidget( m_label );
|
||||
|
||||
cDebug() << "QML import paths:" << Logger::DebugList( m_qmlShow->engine()->importPathList() );
|
||||
|
||||
connect( JobQueue::instance(), &JobQueue::progress,
|
||||
this, &ExecutionViewStep::updateFromJobQueue );
|
||||
connect( JobQueue::instance(), &JobQueue::progress, this, &ExecutionViewStep::updateFromJobQueue );
|
||||
|
||||
CALAMARES_RETRANSLATE_WIDGET( m_widget,
|
||||
if ( m_qmlShowLoaded )
|
||||
m_qmlShow->setSource( QUrl::fromLocalFile( Calamares::Branding::instance()->slideshowPath() ) );
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -133,11 +138,11 @@ ExecutionViewStep::isAtEnd() const
|
||||
void
|
||||
ExecutionViewStep::onActivate()
|
||||
{
|
||||
CALAMARES_RETRANSLATE_WIDGET( m_widget,
|
||||
if ( !Calamares::Branding::instance()->slideshowPath().isEmpty() )
|
||||
m_qmlShow->setSource( QUrl::fromLocalFile( Calamares::Branding::instance()
|
||||
->slideshowPath() ) );
|
||||
)
|
||||
if ( !m_qmlShowLoaded && !Calamares::Branding::instance()->slideshowPath().isEmpty() )
|
||||
{
|
||||
m_qmlShow->setSource( QUrl::fromLocalFile( Calamares::Branding::instance()->slideshowPath() ) );
|
||||
m_qmlShowLoaded = true;
|
||||
}
|
||||
|
||||
JobQueue* queue = JobQueue::instance();
|
||||
foreach ( const QString& instanceKey, m_jobInstanceKeys )
|
||||
|
@ -61,6 +61,7 @@ private:
|
||||
QProgressBar* m_progressBar;
|
||||
QLabel* m_label;
|
||||
QQuickWidget* m_qmlShow;
|
||||
bool m_qmlShowLoaded;
|
||||
|
||||
QStringList m_jobInstanceKeys;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user