diff --git a/src/modules/locale/LocaleViewStep.cpp b/src/modules/locale/LocaleViewStep.cpp index f5ae872af..700678d60 100644 --- a/src/modules/locale/LocaleViewStep.cpp +++ b/src/modules/locale/LocaleViewStep.cpp @@ -19,15 +19,39 @@ #include "LocaleViewStep.h" #include "LocalePage.h" - #include "timezonewidget/localeglobal.h" +#include "utils/CalamaresUtilsGui.h" + +#include +#include +#include + 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; } - diff --git a/src/modules/locale/LocaleViewStep.h b/src/modules/locale/LocaleViewStep.h index 57c5f44b3..0c9c97e33 100644 --- a/src/modules/locale/LocaleViewStep.h +++ b/src/modules/locale/LocaleViewStep.h @@ -24,6 +24,8 @@ #include "viewpages/ViewStep.h" #include "PluginDllMacro.h" +#include + 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