Fix phase handling in ViewManager, to allow adding a Finished page.
This commit is contained in:
parent
8a3ea7c8b1
commit
2782328036
@ -335,6 +335,8 @@ CalamaresApplication::initPlugins()
|
||||
|
||||
ProgressTreeModel* m = new ProgressTreeModel( this );
|
||||
ProgressTreeView::instance()->setModel( m );
|
||||
|
||||
Calamares::ViewManager::instance()->setUpInstallationStep();
|
||||
}
|
||||
else if ( phase == Calamares::Install )
|
||||
{
|
||||
@ -351,6 +353,10 @@ CalamaresApplication::initPlugins()
|
||||
|
||||
queue->start();
|
||||
}
|
||||
else if ( phase == Calamares::PostInstall )
|
||||
{
|
||||
Calamares::ViewManager::instance()->next();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,9 @@ ViewManager::ViewManager( QObject* parent )
|
||||
: QObject( parent )
|
||||
, m_widget( new QWidget() )
|
||||
, m_currentStep( 0 )
|
||||
, m_installationViewStep( 0 )
|
||||
, m_phase( Prepare )
|
||||
, m_finishedStep( 0 )
|
||||
{
|
||||
s_instance = this;
|
||||
QBoxLayout* mainLayout = new QVBoxLayout;
|
||||
@ -87,7 +90,6 @@ ViewManager::ViewManager( QObject* parent )
|
||||
m_back->setEnabled( false );
|
||||
|
||||
m_installationViewStep = new InstallationViewStep( this );
|
||||
insertViewStep( 0, m_installationViewStep );
|
||||
}
|
||||
|
||||
|
||||
@ -107,12 +109,31 @@ ViewManager::centralWidget()
|
||||
void
|
||||
ViewManager::addViewStep( ViewStep* step )
|
||||
{
|
||||
m_prepareSteps.append( step );
|
||||
insertViewStep( m_steps.size(), step );
|
||||
|
||||
insertViewStep( m_steps.size() - 1, step );
|
||||
if ( m_phase == Prepare )
|
||||
{
|
||||
m_prepareSteps.append( step );
|
||||
// If this is the first inserted view step, update status of "Next" button
|
||||
if ( m_prepareSteps.count() == 1 )
|
||||
m_next->setEnabled( step->isNextEnabled() );
|
||||
}
|
||||
else if ( m_phase == PostInstall )
|
||||
{
|
||||
//FIXME: allow multiple postinstall pages
|
||||
if ( !m_finishedStep )
|
||||
m_finishedStep = step;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ViewManager::setUpInstallationStep()
|
||||
{
|
||||
if ( m_installationViewStep && !m_steps.contains( m_installationViewStep ) )
|
||||
{
|
||||
insertViewStep( m_steps.count(), m_installationViewStep );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -189,6 +210,13 @@ ViewManager::currentStep() const
|
||||
}
|
||||
|
||||
|
||||
ViewStep*
|
||||
ViewManager::finishedStep() const
|
||||
{
|
||||
return m_finishedStep;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
ViewManager::currentStepIndex() const
|
||||
{
|
||||
@ -212,6 +240,16 @@ ViewManager::next()
|
||||
if ( installing )
|
||||
{
|
||||
emit phaseChangeRequested( Calamares::Install );
|
||||
m_phase = Install;
|
||||
m_back->setEnabled( false );
|
||||
m_next->setEnabled( false );
|
||||
connect( Calamares::JobQueue::instance(), &Calamares::JobQueue::finished,
|
||||
this, [this]
|
||||
{
|
||||
emit phaseChangeRequested( Calamares::PostInstall );
|
||||
m_phase = PostInstall;
|
||||
m_next->setEnabled( true );
|
||||
} );
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -220,7 +258,7 @@ ViewManager::next()
|
||||
}
|
||||
|
||||
m_next->setEnabled( !installing && m_steps.at( m_currentStep )->isNextEnabled() );
|
||||
m_back->setEnabled( !installing );
|
||||
m_back->setEnabled( !installing && m_steps.at( m_currentStep )->isBackEnabled() );
|
||||
|
||||
if ( m_currentStep == m_steps.count() -1 &&
|
||||
m_steps.last()->isAtEnd() )
|
||||
@ -247,6 +285,8 @@ ViewManager::back()
|
||||
else return;
|
||||
|
||||
m_next->setEnabled( m_steps.at( m_currentStep )->isNextEnabled() );
|
||||
m_back->setEnabled( m_steps.at( m_currentStep )->isBackEnabled() );
|
||||
|
||||
if ( m_currentStep == 0 && m_steps.first()->isAtBeginning() )
|
||||
m_back->setEnabled( false );
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
|
||||
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
|
||||
*
|
||||
* Calamares is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -46,11 +46,15 @@ public:
|
||||
|
||||
void addViewStep( ViewStep* step );
|
||||
|
||||
void setUpInstallationStep();
|
||||
|
||||
QList< ViewStep* > prepareSteps() const;
|
||||
ViewStep* installationStep() const;
|
||||
ViewStep* currentStep() const;
|
||||
ViewStep* finishedStep() const;
|
||||
int currentStepIndex() const;
|
||||
|
||||
|
||||
public slots:
|
||||
void next();
|
||||
void back();
|
||||
@ -69,6 +73,7 @@ private:
|
||||
QList< ViewStep* > m_steps;
|
||||
QList< ViewStep* > m_prepareSteps;
|
||||
InstallationViewStep* m_installationViewStep;
|
||||
ViewStep* m_finishedStep;
|
||||
int m_currentStep;
|
||||
|
||||
QWidget* m_widget;
|
||||
@ -76,6 +81,8 @@ private:
|
||||
QPushButton* m_back;
|
||||
QPushButton* m_next;
|
||||
QPushButton* m_quit;
|
||||
|
||||
Calamares::Phase m_phase;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user