Manage PCM loading with QtConcurrent.
This commit is contained in:
parent
0666fb4977
commit
c9fac9bc5c
@ -52,6 +52,8 @@
|
|||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QStackedWidget>
|
#include <QStackedWidget>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QtConcurrent/QtConcurrent>
|
||||||
|
#include <QFutureWatcher>
|
||||||
|
|
||||||
PartitionViewStep::PartitionViewStep( QObject* parent )
|
PartitionViewStep::PartitionViewStep( QObject* parent )
|
||||||
: Calamares::ViewStep( parent )
|
: Calamares::ViewStep( parent )
|
||||||
@ -71,13 +73,19 @@ PartitionViewStep::PartitionViewStep( QObject* parent )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PartitionViewStep::continueLoading()
|
PartitionViewStep::initPartitionCoreModule()
|
||||||
{
|
{
|
||||||
Q_ASSERT( !m_core );
|
Q_ASSERT( !m_core );
|
||||||
|
m_core = new PartitionCoreModule( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PartitionViewStep::continueLoading()
|
||||||
|
{
|
||||||
Q_ASSERT( !m_choicePage );
|
Q_ASSERT( !m_choicePage );
|
||||||
Q_ASSERT( !m_manualPartitionPage );
|
Q_ASSERT( !m_manualPartitionPage );
|
||||||
|
|
||||||
m_core = new PartitionCoreModule( this );
|
|
||||||
m_manualPartitionPage = new PartitionPage( m_core );
|
m_manualPartitionPage = new PartitionPage( m_core );
|
||||||
m_choicePage = new ChoicePage();
|
m_choicePage = new ChoicePage();
|
||||||
|
|
||||||
@ -468,7 +476,20 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|||||||
gs->insert( "drawNestedPartitions", false );
|
gs->insert( "drawNestedPartitions", false );
|
||||||
}
|
}
|
||||||
|
|
||||||
QTimer::singleShot( 0, this, &PartitionViewStep::continueLoading );
|
// Now that we have the config, we load the PartitionCoreModule in the background
|
||||||
|
// because it could take a while. Then when it's done, we can set up the widgets
|
||||||
|
// and remove the spinner.
|
||||||
|
QFutureWatcher< void >* watcher = new QFutureWatcher< void >();
|
||||||
|
connect( watcher, &QFutureWatcher< void >::finished,
|
||||||
|
this, [ this, watcher ]
|
||||||
|
{
|
||||||
|
continueLoading();
|
||||||
|
watcher->deleteLater();
|
||||||
|
} );
|
||||||
|
|
||||||
|
QFuture< void > future =
|
||||||
|
QtConcurrent::run( this, &PartitionViewStep::initPartitionCoreModule );
|
||||||
|
watcher->setFuture( future );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,8 +44,6 @@ public:
|
|||||||
explicit PartitionViewStep( QObject* parent = 0 );
|
explicit PartitionViewStep( QObject* parent = 0 );
|
||||||
virtual ~PartitionViewStep();
|
virtual ~PartitionViewStep();
|
||||||
|
|
||||||
void continueLoading();
|
|
||||||
|
|
||||||
QString prettyName() const override;
|
QString prettyName() const override;
|
||||||
QWidget* createSummaryWidget() const override;
|
QWidget* createSummaryWidget() const override;
|
||||||
|
|
||||||
@ -68,6 +66,9 @@ public:
|
|||||||
QList< Calamares::job_ptr > jobs() const override;
|
QList< Calamares::job_ptr > jobs() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void initPartitionCoreModule();
|
||||||
|
void continueLoading();
|
||||||
|
|
||||||
PartitionCoreModule* m_core;
|
PartitionCoreModule* m_core;
|
||||||
QStackedWidget* m_widget;
|
QStackedWidget* m_widget;
|
||||||
ChoicePage* m_choicePage;
|
ChoicePage* m_choicePage;
|
||||||
|
Loading…
Reference in New Issue
Block a user