[calamares] Reformat the rest of the application
This commit is contained in:
parent
9235499f7f
commit
a6d7fcdadf
@ -19,22 +19,22 @@
|
||||
#include "CalamaresApplication.h"
|
||||
|
||||
#include "CalamaresConfig.h"
|
||||
#include "CalamaresWindow.h"
|
||||
#include "CalamaresVersion.h"
|
||||
#include "progresstree/ProgressTreeView.h"
|
||||
#include "CalamaresWindow.h"
|
||||
#include "progresstree/ProgressTreeModel.h"
|
||||
#include "progresstree/ProgressTreeView.h"
|
||||
|
||||
#include "Branding.h"
|
||||
#include "JobQueue.h"
|
||||
#include "Settings.h"
|
||||
#include "ViewManager.h"
|
||||
#include "modulesystem/ModuleManager.h"
|
||||
#include "utils/CalamaresUtilsGui.h"
|
||||
#include "utils/CalamaresUtilsSystem.h"
|
||||
#include "utils/Dirs.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/Retranslator.h"
|
||||
#include "JobQueue.h"
|
||||
#include "Branding.h"
|
||||
#include "Settings.h"
|
||||
#include "viewpages/ViewStep.h"
|
||||
#include "ViewManager.h"
|
||||
|
||||
#include <QDesktopWidget>
|
||||
#include <QDir>
|
||||
@ -77,12 +77,11 @@ CalamaresApplication::init()
|
||||
initSettings();
|
||||
initBranding();
|
||||
|
||||
setWindowIcon( QIcon( Calamares::Branding::instance()->
|
||||
imagePath( Calamares::Branding::ProductIcon ) ) );
|
||||
setWindowIcon( QIcon( Calamares::Branding::instance()->imagePath( Calamares::Branding::ProductIcon ) ) );
|
||||
|
||||
cDebug() << "STARTUP: initQmlPath, initSettings, initBranding done";
|
||||
|
||||
initModuleManager(); //also shows main window
|
||||
initModuleManager(); //also shows main window
|
||||
|
||||
cDebug() << "STARTUP: initModuleManager: module init started";
|
||||
}
|
||||
@ -130,14 +129,20 @@ qmlDirCandidates( bool assumeBuilddir )
|
||||
|
||||
QStringList qmlDirs;
|
||||
if ( CalamaresUtils::isAppDataDirOverridden() )
|
||||
{
|
||||
qmlDirs << CalamaresUtils::appDataDir().absoluteFilePath( QML );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( assumeBuilddir )
|
||||
{
|
||||
qmlDirs << QDir::current().absoluteFilePath( "src/qml" ); // In build-dir
|
||||
}
|
||||
if ( CalamaresUtils::haveExtraDirs() )
|
||||
for ( auto s : CalamaresUtils::extraDataDirs() )
|
||||
{
|
||||
qmlDirs << ( s + QML );
|
||||
}
|
||||
qmlDirs << CalamaresUtils::appDataDir().absoluteFilePath( QML );
|
||||
}
|
||||
|
||||
@ -152,14 +157,20 @@ settingsFileCandidates( bool assumeBuilddir )
|
||||
|
||||
QStringList settingsPaths;
|
||||
if ( CalamaresUtils::isAppDataDirOverridden() )
|
||||
{
|
||||
settingsPaths << CalamaresUtils::appDataDir().absoluteFilePath( settings );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( assumeBuilddir )
|
||||
{
|
||||
settingsPaths << QDir::current().absoluteFilePath( settings );
|
||||
}
|
||||
if ( CalamaresUtils::haveExtraDirs() )
|
||||
for ( auto s : CalamaresUtils::extraConfigDirs() )
|
||||
{
|
||||
settingsPaths << ( s + settings );
|
||||
}
|
||||
settingsPaths << CMAKE_INSTALL_FULL_SYSCONFDIR "/calamares/settings.conf"; // String concat
|
||||
settingsPaths << CalamaresUtils::appDataDir().absoluteFilePath( settings );
|
||||
}
|
||||
@ -173,16 +184,22 @@ brandingFileCandidates( bool assumeBuilddir, const QString& brandingFilename )
|
||||
{
|
||||
QStringList brandingPaths;
|
||||
if ( CalamaresUtils::isAppDataDirOverridden() )
|
||||
{
|
||||
brandingPaths << CalamaresUtils::appDataDir().absoluteFilePath( brandingFilename );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( assumeBuilddir )
|
||||
{
|
||||
brandingPaths << ( QDir::currentPath() + QStringLiteral( "/src/" ) + brandingFilename );
|
||||
}
|
||||
if ( CalamaresUtils::haveExtraDirs() )
|
||||
for ( auto s : CalamaresUtils::extraDataDirs() )
|
||||
{
|
||||
brandingPaths << ( s + brandingFilename );
|
||||
}
|
||||
brandingPaths << QDir( CMAKE_INSTALL_FULL_SYSCONFDIR "/calamares/" ).absoluteFilePath( brandingFilename );
|
||||
brandingPaths << CalamaresUtils::appDataDir().absoluteFilePath( brandingFilename);
|
||||
brandingPaths << CalamaresUtils::appDataDir().absoluteFilePath( brandingFilename );
|
||||
}
|
||||
|
||||
return brandingPaths;
|
||||
@ -210,11 +227,15 @@ CalamaresApplication::initQmlPath()
|
||||
if ( !found || !importPath.exists() || !importPath.isReadable() )
|
||||
{
|
||||
cError() << "Cowardly refusing to continue startup without a QML directory."
|
||||
<< Logger::DebugList( qmlDirCandidatesByPriority );
|
||||
<< Logger::DebugList( qmlDirCandidatesByPriority );
|
||||
if ( CalamaresUtils::isAppDataDirOverridden() )
|
||||
{
|
||||
cError() << "FATAL: explicitly configured application data directory is missing qml/";
|
||||
}
|
||||
else
|
||||
{
|
||||
cError() << "FATAL: none of the expected QML paths exist.";
|
||||
}
|
||||
::exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
@ -245,11 +266,15 @@ CalamaresApplication::initSettings()
|
||||
if ( !found || !settingsFile.exists() || !settingsFile.isReadable() )
|
||||
{
|
||||
cError() << "Cowardly refusing to continue startup without settings."
|
||||
<< Logger::DebugList( settingsFileCandidatesByPriority );
|
||||
<< Logger::DebugList( settingsFileCandidatesByPriority );
|
||||
if ( CalamaresUtils::isAppDataDirOverridden() )
|
||||
{
|
||||
cError() << "FATAL: explicitly configured application data directory is missing settings.conf";
|
||||
}
|
||||
else
|
||||
{
|
||||
cError() << "FATAL: none of the expected configuration file paths exist.";
|
||||
}
|
||||
::exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
@ -273,7 +298,7 @@ CalamaresApplication::initBranding()
|
||||
}
|
||||
|
||||
QString brandingDescriptorSubpath = QString( "branding/%1/branding.desc" ).arg( brandingComponentName );
|
||||
QStringList brandingFileCandidatesByPriority = brandingFileCandidates( isDebug(), brandingDescriptorSubpath);
|
||||
QStringList brandingFileCandidatesByPriority = brandingFileCandidates( isDebug(), brandingDescriptorSubpath );
|
||||
|
||||
QFileInfo brandingFile;
|
||||
bool found = false;
|
||||
@ -292,11 +317,15 @@ CalamaresApplication::initBranding()
|
||||
if ( !found || !brandingFile.exists() || !brandingFile.isReadable() )
|
||||
{
|
||||
cError() << "Cowardly refusing to continue startup without branding."
|
||||
<< Logger::DebugList( brandingFileCandidatesByPriority );
|
||||
<< Logger::DebugList( brandingFileCandidatesByPriority );
|
||||
if ( CalamaresUtils::isAppDataDirOverridden() )
|
||||
{
|
||||
cError() << "FATAL: explicitly configured application data directory is missing" << brandingComponentName;
|
||||
}
|
||||
else
|
||||
{
|
||||
cError() << "FATAL: none of the expected branding descriptor file paths exist.";
|
||||
}
|
||||
::exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
@ -307,10 +336,8 @@ CalamaresApplication::initBranding()
|
||||
void
|
||||
CalamaresApplication::initModuleManager()
|
||||
{
|
||||
m_moduleManager = new Calamares::ModuleManager(
|
||||
Calamares::Settings::instance()->modulesSearchPaths(), this );
|
||||
connect( m_moduleManager, &Calamares::ModuleManager::initDone,
|
||||
this, &CalamaresApplication::initView );
|
||||
m_moduleManager = new Calamares::ModuleManager( Calamares::Settings::instance()->modulesSearchPaths(), this );
|
||||
connect( m_moduleManager, &Calamares::ModuleManager::initDone, this, &CalamaresApplication::initView );
|
||||
m_moduleManager->init();
|
||||
}
|
||||
|
||||
@ -322,18 +349,14 @@ CalamaresApplication::initView()
|
||||
initJobQueue();
|
||||
cDebug() << "STARTUP: initJobQueue done";
|
||||
|
||||
m_mainwindow = new CalamaresWindow(); //also creates ViewManager
|
||||
m_mainwindow = new CalamaresWindow(); //also creates ViewManager
|
||||
|
||||
connect( m_moduleManager, &Calamares::ModuleManager::modulesLoaded,
|
||||
this, &CalamaresApplication::initViewSteps );
|
||||
connect( m_moduleManager, &Calamares::ModuleManager::modulesFailed,
|
||||
this, &CalamaresApplication::initFailed );
|
||||
connect( m_moduleManager, &Calamares::ModuleManager::modulesLoaded, this, &CalamaresApplication::initViewSteps );
|
||||
connect( m_moduleManager, &Calamares::ModuleManager::modulesFailed, this, &CalamaresApplication::initFailed );
|
||||
|
||||
m_moduleManager->loadModules();
|
||||
|
||||
m_mainwindow->move(
|
||||
this->desktop()->availableGeometry().center() -
|
||||
m_mainwindow->rect().center() );
|
||||
m_mainwindow->move( this->desktop()->availableGeometry().center() - m_mainwindow->rect().center() );
|
||||
|
||||
cDebug() << "STARTUP: CalamaresWindow created; loadModules started";
|
||||
}
|
||||
@ -350,7 +373,9 @@ CalamaresApplication::initViewSteps()
|
||||
m_mainwindow->showMaximized();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_mainwindow->show();
|
||||
}
|
||||
|
||||
ProgressTreeModel* m = new ProgressTreeModel( nullptr );
|
||||
ProgressTreeView::instance()->setModel( m );
|
||||
@ -360,11 +385,13 @@ CalamaresApplication::initViewSteps()
|
||||
cDebug() << Logger::SubEntry << steps.count() << "view steps loaded.";
|
||||
// Tell the first view that it's been shown.
|
||||
if ( steps.count() > 0 )
|
||||
steps[0]->onActivate();
|
||||
{
|
||||
steps[ 0 ]->onActivate();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CalamaresApplication::initFailed(const QStringList& l)
|
||||
CalamaresApplication::initFailed( const QStringList& l )
|
||||
{
|
||||
cError() << "STARTUP: failed modules are" << l;
|
||||
m_mainwindow->show();
|
||||
|
@ -82,4 +82,4 @@ private:
|
||||
bool m_debugMode;
|
||||
};
|
||||
|
||||
#endif // CALAMARESAPPLICATION_H
|
||||
#endif // CALAMARESAPPLICATION_H
|
||||
|
@ -21,33 +21,39 @@
|
||||
|
||||
#include "CalamaresWindow.h"
|
||||
|
||||
#include "Branding.h"
|
||||
#include "Settings.h"
|
||||
#include "ViewManager.h"
|
||||
#include "progresstree/ProgressTreeView.h"
|
||||
#include "utils/CalamaresUtilsGui.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/DebugWindow.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/Retranslator.h"
|
||||
#include "Settings.h"
|
||||
#include "Branding.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QBoxLayout>
|
||||
#include <QCloseEvent>
|
||||
#include <QDesktopWidget>
|
||||
#include <QLabel>
|
||||
#include <QTreeView>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QLabel>
|
||||
#include <QTreeView>
|
||||
|
||||
static inline int
|
||||
windowDimensionToPixels( const Calamares::Branding::WindowDimension& u )
|
||||
{
|
||||
if ( !u.isValid() )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if ( u.unit() == Calamares::Branding::WindowDimensionUnit::Pixies )
|
||||
{
|
||||
return u.value();
|
||||
}
|
||||
if ( u.unit() == Calamares::Branding::WindowDimensionUnit::Fonties )
|
||||
{
|
||||
return u.value() * CalamaresUtils::defaultFontHeight();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -58,14 +64,13 @@ CalamaresWindow::CalamaresWindow( QWidget* parent )
|
||||
{
|
||||
// If we can never cancel, don't show the window-close button
|
||||
if ( Calamares::Settings::instance()->disableCancel() )
|
||||
{
|
||||
setWindowFlag( Qt::WindowCloseButtonHint, false );
|
||||
}
|
||||
|
||||
CALAMARES_RETRANSLATE(
|
||||
setWindowTitle( Calamares::Settings::instance()->isSetupMode()
|
||||
? tr( "%1 Setup Program" ).arg( *Calamares::Branding::ProductName )
|
||||
: tr( "%1 Installer" ).arg( *Calamares::Branding::ProductName )
|
||||
);
|
||||
)
|
||||
CALAMARES_RETRANSLATE( setWindowTitle( Calamares::Settings::instance()->isSetupMode()
|
||||
? tr( "%1 Setup Program" ).arg( *Calamares::Branding::ProductName )
|
||||
: tr( "%1 Installer" ).arg( *Calamares::Branding::ProductName ) ); )
|
||||
|
||||
const Calamares::Branding* const branding = Calamares::Branding::instance();
|
||||
|
||||
@ -75,7 +80,7 @@ CalamaresWindow::CalamaresWindow( QWidget* parent )
|
||||
using CalamaresUtils::windowPreferredWidth;
|
||||
|
||||
// Needs to match what's checked in DebugWindow
|
||||
this->setObjectName("mainApp");
|
||||
this->setObjectName( "mainApp" );
|
||||
|
||||
QSize availableSize = qApp->desktop()->availableGeometry( this ).size();
|
||||
QSize minimumSize( qBound( windowMinimumWidth, availableSize.width(), windowPreferredWidth ),
|
||||
@ -87,7 +92,7 @@ CalamaresWindow::CalamaresWindow( QWidget* parent )
|
||||
auto brandingSizes = branding->windowSize();
|
||||
|
||||
int w = qBound( minimumSize.width(), windowDimensionToPixels( brandingSizes.first ), availableSize.width() );
|
||||
int h = qBound( minimumSize.height(), windowDimensionToPixels( brandingSizes.second ), availableSize.height() );
|
||||
int h = qBound( minimumSize.height(), windowDimensionToPixels( brandingSizes.second ), availableSize.height() );
|
||||
|
||||
cDebug() << Logger::SubEntry << "Proposed window size:" << w << h;
|
||||
resize( w, h );
|
||||
@ -96,25 +101,26 @@ CalamaresWindow::CalamaresWindow( QWidget* parent )
|
||||
setLayout( mainLayout );
|
||||
|
||||
QWidget* sideBox = new QWidget( this );
|
||||
sideBox->setObjectName("sidebarApp");
|
||||
sideBox->setObjectName( "sidebarApp" );
|
||||
mainLayout->addWidget( sideBox );
|
||||
|
||||
QBoxLayout* sideLayout = new QVBoxLayout;
|
||||
sideBox->setLayout( sideLayout );
|
||||
// Set this attribute into qss file
|
||||
sideBox->setFixedWidth( qBound( 100, CalamaresUtils::defaultFontHeight() * 12, w < windowPreferredWidth ? 100 : 190 ) );
|
||||
sideBox->setFixedWidth(
|
||||
qBound( 100, CalamaresUtils::defaultFontHeight() * 12, w < windowPreferredWidth ? 100 : 190 ) );
|
||||
sideBox->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
|
||||
|
||||
QHBoxLayout* logoLayout = new QHBoxLayout;
|
||||
sideLayout->addLayout( logoLayout );
|
||||
logoLayout->addStretch();
|
||||
QLabel* logoLabel = new QLabel( sideBox );
|
||||
logoLabel->setObjectName("logoApp");
|
||||
logoLabel->setObjectName( "logoApp" );
|
||||
//Define all values into qss file
|
||||
{
|
||||
QPalette plt = sideBox->palette();
|
||||
sideBox->setAutoFillBackground( true );
|
||||
plt.setColor( sideBox->backgroundRole(),branding->styleString( Calamares::Branding::SidebarBackground ) );
|
||||
plt.setColor( sideBox->backgroundRole(), branding->styleString( Calamares::Branding::SidebarBackground ) );
|
||||
plt.setColor( sideBox->foregroundRole(), branding->styleString( Calamares::Branding::SidebarText ) );
|
||||
sideBox->setPalette( plt );
|
||||
logoLabel->setPalette( plt );
|
||||
@ -133,22 +139,16 @@ CalamaresWindow::CalamaresWindow( QWidget* parent )
|
||||
{
|
||||
QPushButton* debugWindowBtn = new QPushButton;
|
||||
debugWindowBtn->setObjectName( "debugButton" );
|
||||
CALAMARES_RETRANSLATE(
|
||||
debugWindowBtn->setText( tr( "Show debug information" ) );
|
||||
)
|
||||
CALAMARES_RETRANSLATE( debugWindowBtn->setText( tr( "Show debug information" ) ); )
|
||||
sideLayout->addWidget( debugWindowBtn );
|
||||
debugWindowBtn->setFlat( true );
|
||||
debugWindowBtn->setCheckable( true );
|
||||
connect( debugWindowBtn, &QPushButton::clicked,
|
||||
this, [ = ]( bool checked )
|
||||
{
|
||||
connect( debugWindowBtn, &QPushButton::clicked, this, [=]( bool checked ) {
|
||||
if ( checked )
|
||||
{
|
||||
m_debugWindow = new Calamares::DebugWindow();
|
||||
m_debugWindow->show();
|
||||
connect( m_debugWindow.data(), &Calamares::DebugWindow::closed,
|
||||
this, [ = ]()
|
||||
{
|
||||
connect( m_debugWindow.data(), &Calamares::DebugWindow::closed, this, [=]() {
|
||||
m_debugWindow->deleteLater();
|
||||
debugWindowBtn->setChecked( false );
|
||||
} );
|
||||
@ -156,7 +156,9 @@ CalamaresWindow::CalamaresWindow( QWidget* parent )
|
||||
else
|
||||
{
|
||||
if ( m_debugWindow )
|
||||
{
|
||||
m_debugWindow->deleteLater();
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
@ -166,7 +168,9 @@ CalamaresWindow::CalamaresWindow( QWidget* parent )
|
||||
|
||||
m_viewManager = Calamares::ViewManager::instance( this );
|
||||
if ( branding->windowExpands() )
|
||||
{
|
||||
connect( m_viewManager, &Calamares::ViewManager::enlarge, this, &CalamaresWindow::enlarge );
|
||||
}
|
||||
// NOTE: Although the ViewManager has a signal cancelEnabled() that
|
||||
// signals when the state of the cancel button changes (in
|
||||
// particular, to disable cancel during the exec phase),
|
||||
@ -201,5 +205,7 @@ CalamaresWindow::closeEvent( QCloseEvent* event )
|
||||
qApp->quit();
|
||||
}
|
||||
else
|
||||
{
|
||||
event->ignore();
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace Calamares
|
||||
{
|
||||
class DebugWindow;
|
||||
class ViewManager;
|
||||
}
|
||||
} // namespace Calamares
|
||||
|
||||
/**
|
||||
* @brief The CalamaresWindow class represents the main window of the Calamares UI.
|
||||
@ -55,4 +55,4 @@ private:
|
||||
Calamares::ViewManager* m_viewManager;
|
||||
};
|
||||
|
||||
#endif // CALAMARESWINDOW_H
|
||||
#endif // CALAMARESWINDOW_H
|
||||
|
@ -24,11 +24,10 @@
|
||||
#include "kdsingleapplicationguard/kdsingleapplicationguard.h"
|
||||
#include "utils/Dirs.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "CalamaresConfig.h"
|
||||
|
||||
#ifdef WITH_KF5Crash
|
||||
#include <KF5/KCrash/KCrash>
|
||||
#include <KF5/KCoreAddons/KAboutData>
|
||||
#include <KF5/KCrash/KCrash>
|
||||
#endif
|
||||
|
||||
#include <QCommandLineParser>
|
||||
@ -38,14 +37,13 @@
|
||||
static void
|
||||
handle_args( CalamaresApplication& a )
|
||||
{
|
||||
QCommandLineOption debugOption( QStringList{ "d", "debug"},
|
||||
QCommandLineOption debugOption( QStringList { "d", "debug" },
|
||||
"Also look in current directory for configuration. Implies -D8." );
|
||||
QCommandLineOption debugLevelOption( QStringLiteral("D"),
|
||||
"Verbose output for debugging purposes (0-8).", "level" );
|
||||
QCommandLineOption configOption( QStringList{ "c", "config"},
|
||||
"Configuration directory to use, for testing purposes.", "config" );
|
||||
QCommandLineOption xdgOption( QStringList{"X", "xdg-config"},
|
||||
"Use XDG_{CONFIG,DATA}_DIRS as well." );
|
||||
QCommandLineOption debugLevelOption(
|
||||
QStringLiteral( "D" ), "Verbose output for debugging purposes (0-8).", "level" );
|
||||
QCommandLineOption configOption(
|
||||
QStringList { "c", "config" }, "Configuration directory to use, for testing purposes.", "config" );
|
||||
QCommandLineOption xdgOption( QStringList { "X", "xdg-config" }, "Use XDG_{CONFIG,DATA}_DIRS as well." );
|
||||
|
||||
QCommandLineParser parser;
|
||||
parser.setApplicationDescription( "Distribution-independent installer framework" );
|
||||
@ -61,22 +59,32 @@ handle_args( CalamaresApplication& a )
|
||||
|
||||
a.setDebug( parser.isSet( debugOption ) );
|
||||
if ( parser.isSet( debugOption ) )
|
||||
{
|
||||
Logger::setupLogLevel( Logger::LOGVERBOSE );
|
||||
}
|
||||
else if ( parser.isSet( debugLevelOption ) )
|
||||
{
|
||||
bool ok = true;
|
||||
int l = parser.value( debugLevelOption ).toInt( &ok );
|
||||
unsigned int dlevel = 0;
|
||||
if ( !ok || ( l < 0 ) )
|
||||
{
|
||||
dlevel = Logger::LOGVERBOSE;
|
||||
}
|
||||
else
|
||||
dlevel = static_cast<unsigned int>( l ); // l >= 0
|
||||
{
|
||||
dlevel = static_cast< unsigned int >( l ); // l >= 0
|
||||
}
|
||||
Logger::setupLogLevel( dlevel );
|
||||
}
|
||||
if ( parser.isSet( configOption ) )
|
||||
{
|
||||
CalamaresUtils::setAppDataDir( QDir( parser.value( configOption ) ) );
|
||||
}
|
||||
if ( parser.isSet( xdgOption ) )
|
||||
{
|
||||
CalamaresUtils::setXdgDirs();
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
@ -118,9 +126,13 @@ main( int argc, char* argv[] )
|
||||
auto instancelist = guard.instances();
|
||||
qDebug() << "Calamares is already running, shutting down.";
|
||||
if ( instancelist.count() > 0 )
|
||||
{
|
||||
qDebug() << "Other running Calamares instances:";
|
||||
}
|
||||
for ( const auto& i : instancelist )
|
||||
{
|
||||
qDebug() << " " << i.isValid() << i.pid() << i.arguments();
|
||||
}
|
||||
}
|
||||
|
||||
return returnCode;
|
||||
|
@ -22,9 +22,9 @@
|
||||
* bindings.
|
||||
*/
|
||||
|
||||
#include "modulesystem/Module.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/Yaml.h"
|
||||
#include "modulesystem/Module.h"
|
||||
|
||||
#include "GlobalStorage.h"
|
||||
#include "Job.h"
|
||||
@ -40,28 +40,47 @@
|
||||
|
||||
struct ModuleConfig
|
||||
{
|
||||
QString moduleName() const { return m_module; }
|
||||
QString configFile() const { return m_jobConfig; }
|
||||
QString language() const { return m_language; }
|
||||
QString globalConfigFile() const { return m_globalConfig; }
|
||||
QString
|
||||
moduleName() const
|
||||
{
|
||||
return m_module;
|
||||
}
|
||||
QString
|
||||
configFile() const
|
||||
{
|
||||
return m_jobConfig;
|
||||
}
|
||||
QString
|
||||
language() const
|
||||
{
|
||||
return m_language;
|
||||
}
|
||||
QString
|
||||
globalConfigFile() const
|
||||
{
|
||||
return m_globalConfig;
|
||||
}
|
||||
|
||||
QString m_module;
|
||||
QString m_jobConfig;
|
||||
QString m_globalConfig;
|
||||
QString m_language;
|
||||
} ;
|
||||
};
|
||||
|
||||
static ModuleConfig
|
||||
handle_args( QCoreApplication& a )
|
||||
{
|
||||
QCommandLineOption debugLevelOption( QStringLiteral("D"),
|
||||
"Verbose output for debugging purposes (0-8).", "level" );
|
||||
QCommandLineOption globalOption( QStringList() << QStringLiteral( "g" ) << QStringLiteral( "global "),
|
||||
QStringLiteral( "Global settings document" ), "global.yaml" );
|
||||
QCommandLineOption jobOption( QStringList() << QStringLiteral( "j" ) << QStringLiteral( "job"),
|
||||
QStringLiteral( "Job settings document" ), "job.yaml" );
|
||||
QCommandLineOption debugLevelOption(
|
||||
QStringLiteral( "D" ), "Verbose output for debugging purposes (0-8).", "level" );
|
||||
QCommandLineOption globalOption( QStringList() << QStringLiteral( "g" ) << QStringLiteral( "global " ),
|
||||
QStringLiteral( "Global settings document" ),
|
||||
"global.yaml" );
|
||||
QCommandLineOption jobOption( QStringList() << QStringLiteral( "j" ) << QStringLiteral( "job" ),
|
||||
QStringLiteral( "Job settings document" ),
|
||||
"job.yaml" );
|
||||
QCommandLineOption langOption( QStringList() << QStringLiteral( "l" ) << QStringLiteral( "language" ),
|
||||
QStringLiteral( "Language (global)" ), "languagecode" );
|
||||
QStringLiteral( "Language (global)" ),
|
||||
"languagecode" );
|
||||
|
||||
QCommandLineParser parser;
|
||||
parser.setApplicationDescription( "Calamares module tester" );
|
||||
@ -73,7 +92,7 @@ handle_args( QCoreApplication& a )
|
||||
parser.addOption( jobOption );
|
||||
parser.addOption( langOption );
|
||||
parser.addPositionalArgument( "module", "Path or name of module to run." );
|
||||
parser.addPositionalArgument( "job.yaml", "Path of job settings document to use.", "[job.yaml]");
|
||||
parser.addPositionalArgument( "job.yaml", "Path of job settings document to use.", "[job.yaml]" );
|
||||
|
||||
parser.process( a );
|
||||
|
||||
@ -83,9 +102,13 @@ handle_args( QCoreApplication& a )
|
||||
unsigned int l = parser.value( debugLevelOption ).toUInt( &ok );
|
||||
unsigned int dlevel = 0;
|
||||
if ( !ok )
|
||||
{
|
||||
dlevel = Logger::LOGVERBOSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
dlevel = l;
|
||||
}
|
||||
Logger::setupLogLevel( dlevel );
|
||||
}
|
||||
|
||||
@ -104,9 +127,11 @@ handle_args( QCoreApplication& a )
|
||||
{
|
||||
QString jobSettings( parser.value( jobOption ) );
|
||||
if ( jobSettings.isEmpty() && ( args.size() == 2 ) )
|
||||
jobSettings = args.at(1);
|
||||
{
|
||||
jobSettings = args.at( 1 );
|
||||
}
|
||||
|
||||
return ModuleConfig{ args.first(), jobSettings, parser.value( globalOption ), parser.value( langOption ) };
|
||||
return ModuleConfig { args.first(), jobSettings, parser.value( globalOption ), parser.value( langOption ) };
|
||||
}
|
||||
}
|
||||
|
||||
@ -120,14 +145,18 @@ load_module( const ModuleConfig& moduleConfig )
|
||||
bool ok = false;
|
||||
QVariantMap descriptor;
|
||||
|
||||
for ( const QString& prefix : QStringList{ "./", "src/modules/", "modules/" } )
|
||||
for ( const QString& prefix : QStringList { "./", "src/modules/", "modules/" } )
|
||||
{
|
||||
// Could be a complete path, eg. src/modules/dummycpp/module.desc
|
||||
fi = QFileInfo( prefix + moduleName );
|
||||
if ( fi.exists() && fi.isFile() )
|
||||
{
|
||||
descriptor = CalamaresUtils::loadYaml( fi, &ok );
|
||||
}
|
||||
if ( ok )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// Could be a path without module.desc
|
||||
fi = QFileInfo( prefix + moduleName );
|
||||
@ -135,8 +164,13 @@ load_module( const ModuleConfig& moduleConfig )
|
||||
{
|
||||
fi = QFileInfo( prefix + moduleName + "/module.desc" );
|
||||
if ( fi.exists() && fi.isFile() )
|
||||
{
|
||||
descriptor = CalamaresUtils::loadYaml( fi, &ok );
|
||||
if ( ok ) break;
|
||||
}
|
||||
if ( ok )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,15 +188,12 @@ load_module( const ModuleConfig& moduleConfig )
|
||||
}
|
||||
|
||||
QString moduleDirectory = fi.absolutePath();
|
||||
QString configFile(
|
||||
moduleConfig.configFile().isEmpty()
|
||||
? moduleDirectory + '/' + name + ".conf"
|
||||
: moduleConfig.configFile() );
|
||||
QString configFile( moduleConfig.configFile().isEmpty() ? moduleDirectory + '/' + name + ".conf"
|
||||
: moduleConfig.configFile() );
|
||||
|
||||
cDebug() << "Module" << moduleName << "job-configuration:" << configFile;
|
||||
|
||||
Calamares::Module* module = Calamares::Module::fromDescriptor(
|
||||
descriptor, name, configFile, moduleDirectory );
|
||||
Calamares::Module* module = Calamares::Module::fromDescriptor( descriptor, name, configFile, moduleDirectory );
|
||||
|
||||
return module;
|
||||
}
|
||||
@ -174,14 +205,18 @@ main( int argc, char* argv[] )
|
||||
|
||||
ModuleConfig module = handle_args( a );
|
||||
if ( module.moduleName().isEmpty() )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::unique_ptr< Calamares::Settings > settings_p( new Calamares::Settings( QString(), true ) );
|
||||
std::unique_ptr< Calamares::JobQueue > jobqueue_p( new Calamares::JobQueue( nullptr ) );
|
||||
|
||||
auto gs = jobqueue_p->globalStorage();
|
||||
if ( !module.globalConfigFile().isEmpty() )
|
||||
{
|
||||
gs->loadYaml( module.globalConfigFile() );
|
||||
}
|
||||
if ( !module.language().isEmpty() )
|
||||
{
|
||||
QVariantMap vm;
|
||||
@ -199,7 +234,9 @@ main( int argc, char* argv[] )
|
||||
}
|
||||
|
||||
if ( !m->isLoaded() )
|
||||
{
|
||||
m->loadSelf();
|
||||
}
|
||||
|
||||
if ( !m->isLoaded() )
|
||||
{
|
||||
@ -207,12 +244,10 @@ main( int argc, char* argv[] )
|
||||
return 1;
|
||||
}
|
||||
|
||||
using TR = Logger::DebugRow<const char*, const QString>;
|
||||
using TR = Logger::DebugRow< const char*, const QString >;
|
||||
|
||||
cDebug() << "Module metadata"
|
||||
<< TR( "name", m->name() )
|
||||
<< TR( "type", m->typeString() )
|
||||
<< TR( "interface", m->interfaceString() );
|
||||
cDebug() << "Module metadata" << TR( "name", m->name() ) << TR( "type", m->typeString() )
|
||||
<< TR( "interface", m->interfaceString() );
|
||||
|
||||
cDebug() << "Job outputs:";
|
||||
Calamares::JobList jobList = m->jobs();
|
||||
@ -224,11 +259,11 @@ main( int argc, char* argv[] )
|
||||
Calamares::JobResult r = p->exec();
|
||||
if ( !r )
|
||||
{
|
||||
cError() << "Job #" << count << "failed"
|
||||
<< TR( "summary", r.message() )
|
||||
<< TR( "details", r.details() );
|
||||
cError() << "Job #" << count << "failed" << TR( "summary", r.message() ) << TR( "details", r.details() );
|
||||
if ( r.errorCode() > 0 )
|
||||
{
|
||||
++failure_count;
|
||||
}
|
||||
}
|
||||
++count;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user