Load timezone data asynchronously so we don't block the GUI thread on
startup.
This commit is contained in:
parent
4cf6c06dda
commit
f9aa532d77
@ -19,15 +19,39 @@
|
||||
#include "LocaleViewStep.h"
|
||||
|
||||
#include "LocalePage.h"
|
||||
|
||||
#include "timezonewidget/localeglobal.h"
|
||||
|
||||
#include "utils/CalamaresUtilsGui.h"
|
||||
|
||||
#include <QBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QtConcurrent/QtConcurrentRun>
|
||||
|
||||
LocaleViewStep::LocaleViewStep( QObject* parent )
|
||||
: Calamares::ViewStep( parent )
|
||||
, m_widget( new LocalePage() )
|
||||
, m_widget( new QWidget() )
|
||||
, m_actualWidget( new LocalePage() )
|
||||
{
|
||||
LocaleGlobal::init(); //this takes a long time
|
||||
m_widget->init();
|
||||
QBoxLayout* mainLayout = new QHBoxLayout;
|
||||
m_widget->setLayout( mainLayout );
|
||||
CalamaresUtils::unmarginLayout( mainLayout );
|
||||
|
||||
QLabel* waitingLabel = new QLabel( "Loading location data..." );
|
||||
waitingLabel->setAlignment( Qt::AlignCenter );
|
||||
mainLayout->addWidget( waitingLabel );
|
||||
|
||||
connect( &m_initWatcher, &QFutureWatcher< void >::finished,
|
||||
[=]
|
||||
{
|
||||
m_actualWidget->init();
|
||||
m_widget->layout()->removeWidget( waitingLabel );
|
||||
waitingLabel->deleteLater();
|
||||
m_widget->layout()->addWidget( m_actualWidget );
|
||||
});
|
||||
|
||||
QFuture< void > initFuture = QtConcurrent::run( LocaleGlobal::init );
|
||||
m_initWatcher.setFuture( initFuture );
|
||||
|
||||
emit nextStatusChanged( true );
|
||||
}
|
||||
|
||||
@ -85,4 +109,3 @@ LocaleViewStep::isAtEnd() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,8 @@
|
||||
#include "viewpages/ViewStep.h"
|
||||
#include "PluginDllMacro.h"
|
||||
|
||||
#include <QFutureWatcher>
|
||||
|
||||
class LocalePage;
|
||||
|
||||
class PLUGINDLLEXPORT LocaleViewStep : public Calamares::ViewStep
|
||||
@ -50,7 +52,10 @@ public:
|
||||
bool isAtEnd() const override;
|
||||
|
||||
private:
|
||||
LocalePage* m_widget;
|
||||
QWidget* m_widget;
|
||||
QFutureWatcher< void > m_initWatcher;
|
||||
|
||||
LocalePage* m_actualWidget;
|
||||
};
|
||||
|
||||
#endif // LOCALEVIEWSTEP_H
|
||||
|
Loading…
Reference in New Issue
Block a user