mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-28 01:45:36 -04:00
Generalized code path for Phase switching. Also load install modules.
This commit is contained in:
parent
6348e72974
commit
8d28a2ea5d
5 changed files with 86 additions and 53 deletions
|
@ -28,6 +28,8 @@
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "JobQueue.h"
|
#include "JobQueue.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
#include "viewpages/ViewStep.h"
|
||||||
|
#include "ViewManager.h"
|
||||||
|
|
||||||
|
|
||||||
CalamaresApplication::CalamaresApplication( int& argc, char *argv[] )
|
CalamaresApplication::CalamaresApplication( int& argc, char *argv[] )
|
||||||
|
@ -118,6 +120,13 @@ CalamaresApplication::mainWindow()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
CalamaresApplication::startPhase( Calamares::Phase phase )
|
||||||
|
{
|
||||||
|
m_moduleManager->loadModules( phase );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CalamaresApplication::initSettings()
|
CalamaresApplication::initSettings()
|
||||||
{
|
{
|
||||||
|
@ -140,6 +149,37 @@ CalamaresApplication::initPlugins()
|
||||||
connect( m_moduleManager, &Calamares::ModuleManager::initDone,
|
connect( m_moduleManager, &Calamares::ModuleManager::initDone,
|
||||||
this, &CalamaresApplication::onPluginsReady );
|
this, &CalamaresApplication::onPluginsReady );
|
||||||
m_moduleManager->init();
|
m_moduleManager->init();
|
||||||
|
|
||||||
|
connect( m_moduleManager, &Calamares::ModuleManager::modulesLoaded,
|
||||||
|
this, [this]( Calamares::Phase phase )
|
||||||
|
{
|
||||||
|
if ( phase == Calamares::Prepare )
|
||||||
|
{
|
||||||
|
m_mainwindow->show();
|
||||||
|
|
||||||
|
ProgressTreeModel* m = new ProgressTreeModel( this );
|
||||||
|
ProgressTreeView::instance()->setModel( m );
|
||||||
|
}
|
||||||
|
else if ( phase == Calamares::Install )
|
||||||
|
{
|
||||||
|
Calamares::ViewManager* vm = Calamares::ViewManager::instance();
|
||||||
|
Calamares::JobQueue* queue = Calamares::JobQueue::instance();
|
||||||
|
|
||||||
|
//FIXME: we should enqueue viewmodule jobs in the order from settings.conf,
|
||||||
|
// not in the order they show up in the UI
|
||||||
|
// Ideally, if a module is a viewmodule and isLoaded we should ask
|
||||||
|
// for jobs, else if it's a viewmodule and not isLoaded we bail with
|
||||||
|
// error, else if jobmodule and not isLoaded, just loadSelf.
|
||||||
|
for( Calamares::ViewStep* step : vm->prepareSteps() )
|
||||||
|
{
|
||||||
|
queue->enqueue( step->jobs() );
|
||||||
|
}
|
||||||
|
connect( queue, &Calamares::JobQueue::failed,
|
||||||
|
vm, &Calamares::ViewManager::onInstallationFailed );
|
||||||
|
|
||||||
|
queue->start();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -149,19 +189,10 @@ CalamaresApplication::onPluginsReady()
|
||||||
initJobQueue();
|
initJobQueue();
|
||||||
|
|
||||||
m_mainwindow = new CalamaresWindow(); //also creates ViewManager
|
m_mainwindow = new CalamaresWindow(); //also creates ViewManager
|
||||||
|
connect( Calamares::ViewManager::instance(), &Calamares::ViewManager::phaseChangeRequested,
|
||||||
|
this, &CalamaresApplication::startPhase );
|
||||||
|
|
||||||
m_moduleManager->loadModules( Calamares::Prepare );
|
startPhase( Calamares::Prepare );
|
||||||
connect( m_moduleManager, &Calamares::ModuleManager::modulesLoaded,
|
|
||||||
[this]( Calamares::Phase phase )
|
|
||||||
{
|
|
||||||
if ( phase == Calamares::Prepare )
|
|
||||||
{
|
|
||||||
m_mainwindow->show();
|
|
||||||
|
|
||||||
ProgressTreeModel* m = new ProgressTreeModel( this );
|
|
||||||
ProgressTreeView::instance()->setModel( m );
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
#ifndef CALAMARESAPPLICATION_H
|
#ifndef CALAMARESAPPLICATION_H
|
||||||
#define CALAMARESAPPLICATION_H
|
#define CALAMARESAPPLICATION_H
|
||||||
|
|
||||||
|
#include "Typedefs.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
#define APP CalamaresApplication::instance()
|
#define APP CalamaresApplication::instance()
|
||||||
|
@ -45,6 +47,8 @@ public:
|
||||||
|
|
||||||
CalamaresWindow* mainWindow();
|
CalamaresWindow* mainWindow();
|
||||||
|
|
||||||
|
void startPhase( Calamares::Phase phase );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onPluginsReady();
|
void onPluginsReady();
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "viewpages/ViewStep.h"
|
#include "viewpages/ViewStep.h"
|
||||||
#include "InstallationViewStep.h"
|
#include "InstallationViewStep.h"
|
||||||
#include "JobQueue.h"
|
#include "JobQueue.h"
|
||||||
|
#include "modulesystem/ModuleManager.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
|
@ -112,6 +113,31 @@ ViewManager::insertViewStep( int before, ViewStep* step)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ViewManager::onInstallationFailed( const QString& message, const QString& details )
|
||||||
|
{
|
||||||
|
QString text = tr(
|
||||||
|
"<p><b>Installation Failed</b></p>"
|
||||||
|
"<p>%1</p>"
|
||||||
|
).arg( message );
|
||||||
|
|
||||||
|
if ( !details.isEmpty() )
|
||||||
|
{
|
||||||
|
text += tr(
|
||||||
|
"<p>%1</p>"
|
||||||
|
).arg( details );
|
||||||
|
}
|
||||||
|
|
||||||
|
QMessageBox::critical(
|
||||||
|
QApplication::activeWindow(),
|
||||||
|
tr( "Error" ),
|
||||||
|
text,
|
||||||
|
QMessageBox::Close
|
||||||
|
);
|
||||||
|
QApplication::quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QList< ViewStep* >
|
QList< ViewStep* >
|
||||||
ViewManager::prepareSteps() const
|
ViewManager::prepareSteps() const
|
||||||
{
|
{
|
||||||
|
@ -155,7 +181,7 @@ ViewManager::next()
|
||||||
emit currentStepChanged();
|
emit currentStepChanged();
|
||||||
if ( installing )
|
if ( installing )
|
||||||
{
|
{
|
||||||
startInstallation();
|
emit phaseChangeRequested( Calamares::Install );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -191,40 +217,4 @@ ViewManager::back()
|
||||||
m_back->setEnabled( false );
|
m_back->setEnabled( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
ViewManager::startInstallation()
|
|
||||||
{
|
|
||||||
JobQueue* queue = JobQueue::instance();
|
|
||||||
for( ViewStep* step : m_prepareSteps )
|
|
||||||
{
|
|
||||||
queue->enqueue( step->jobs() );
|
|
||||||
}
|
|
||||||
connect( queue, &JobQueue::failed, this, &ViewManager::onInstallationFailed );
|
|
||||||
queue->start();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ViewManager::onInstallationFailed( const QString& message, const QString& details )
|
|
||||||
{
|
|
||||||
QString text = tr(
|
|
||||||
"<p><b>Installation Failed</b></p>"
|
|
||||||
"<p>%1</p>"
|
|
||||||
).arg( message );
|
|
||||||
|
|
||||||
if ( !details.isEmpty() )
|
|
||||||
{
|
|
||||||
text += tr(
|
|
||||||
"<p>%1</p>"
|
|
||||||
).arg( details );
|
|
||||||
}
|
|
||||||
|
|
||||||
QMessageBox::critical(
|
|
||||||
QApplication::activeWindow(),
|
|
||||||
tr( "Error" ),
|
|
||||||
text,
|
|
||||||
QMessageBox::Close
|
|
||||||
);
|
|
||||||
QApplication::quit();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#define VIEWMANAGER_H
|
#define VIEWMANAGER_H
|
||||||
|
|
||||||
#include "UiDllMacro.h"
|
#include "UiDllMacro.h"
|
||||||
|
#include "Typedefs.h"
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
@ -54,10 +55,15 @@ public slots:
|
||||||
void next();
|
void next();
|
||||||
void back();
|
void back();
|
||||||
|
|
||||||
|
void onInstallationFailed( const QString& message, const QString& details );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void currentStepChanged();
|
void currentStepChanged();
|
||||||
|
void phaseChangeRequested( Calamares::Phase );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void insertViewStep( int before, ViewStep* step );
|
||||||
|
|
||||||
static ViewManager* s_instance;
|
static ViewManager* s_instance;
|
||||||
|
|
||||||
QList< ViewStep* > m_steps;
|
QList< ViewStep* > m_steps;
|
||||||
|
@ -70,10 +76,6 @@ private:
|
||||||
QPushButton* m_back;
|
QPushButton* m_back;
|
||||||
QPushButton* m_next;
|
QPushButton* m_next;
|
||||||
QPushButton* m_quit;
|
QPushButton* m_quit;
|
||||||
|
|
||||||
void insertViewStep( int before, ViewStep* step );
|
|
||||||
void startInstallation();
|
|
||||||
void onInstallationFailed( const QString& message, const QString& details );
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,6 +86,12 @@ ModuleManager::loadModules( Phase phase )
|
||||||
<< "\nCalamares will now quit.";
|
<< "\nCalamares will now quit.";
|
||||||
qApp->quit();
|
qApp->quit();
|
||||||
}
|
}
|
||||||
|
if ( m_availableModules.value( moduleName )->isLoaded() )
|
||||||
|
{
|
||||||
|
cDebug() << "Module" << moduleName << "already loaded.";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
recursiveLoad( moduleName );
|
recursiveLoad( moduleName );
|
||||||
}
|
}
|
||||||
emit modulesLoaded( phase );
|
emit modulesLoaded( phase );
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue