Merge branch 'master' of https://github.com/calamares/calamares into development
This commit is contained in:
commit
746d7f6af7
@ -48,11 +48,11 @@ windowDimensionToPixels( const Calamares::Branding::WindowDimension& u )
|
||||
}
|
||||
if ( u.unit() == Calamares::Branding::WindowDimensionUnit::Pixies )
|
||||
{
|
||||
return u.value();
|
||||
return static_cast< int >( u.value() );
|
||||
}
|
||||
if ( u.unit() == Calamares::Branding::WindowDimensionUnit::Fonties )
|
||||
{
|
||||
return u.value() * CalamaresUtils::defaultFontHeight();
|
||||
return static_cast< int >( u.value() * CalamaresUtils::defaultFontHeight() );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -76,9 +76,10 @@ ProgressTreeView::setModel( QAbstractItemModel* model )
|
||||
QTreeView::setModel( model );
|
||||
expandAll();
|
||||
|
||||
connect( Calamares::ViewManager::instance(),
|
||||
&Calamares::ViewManager::currentStepChanged,
|
||||
this,
|
||||
[this]() { viewport()->update(); },
|
||||
Qt::UniqueConnection );
|
||||
connect(
|
||||
Calamares::ViewManager::instance(),
|
||||
&Calamares::ViewManager::currentStepChanged,
|
||||
this,
|
||||
[this]() { viewport()->update(); },
|
||||
Qt::UniqueConnection );
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ static CommandLine
|
||||
get_variant_object( const QVariantMap& m )
|
||||
{
|
||||
QString command = CalamaresUtils::getString( m, "command" );
|
||||
int timeout = CalamaresUtils::getInteger( m, "timeout", -1 );
|
||||
qint64 timeout = CalamaresUtils::getInteger( m, "timeout", -1 );
|
||||
|
||||
if ( !command.isEmpty() )
|
||||
{
|
||||
|
@ -24,7 +24,7 @@
|
||||
#ifndef UTILS_PLUGINFACTORY_H
|
||||
#define UTILS_PLUGINFACTORY_H
|
||||
|
||||
#include <KF5/KCoreAddons/KPluginFactory>
|
||||
#include <KPluginFactory>
|
||||
|
||||
#define CalamaresPluginFactory_iid "io.calamares.PluginFactory"
|
||||
|
||||
@ -102,6 +102,6 @@ public:
|
||||
K_PLUGIN_FACTORY_DEFINITION_WITH_BASEFACTORY( name, CalamaresPluginFactory, pluginRegistrations )
|
||||
|
||||
|
||||
// Q_DECLARE_INTERFACE( Calamares::PluginFactory, CalamaresPluginFactory_iid )
|
||||
Q_DECLARE_INTERFACE( CalamaresPluginFactory, CalamaresPluginFactory_iid )
|
||||
|
||||
#endif
|
||||
|
@ -87,7 +87,7 @@ const QStringList Branding::s_styleEntryStrings =
|
||||
// clang-format on
|
||||
// *INDENT-ON*
|
||||
|
||||
const NamedEnumTable<Branding::WindowDimensionUnit>&
|
||||
const NamedEnumTable< Branding::WindowDimensionUnit >&
|
||||
Branding::WindowDimension::suffixes()
|
||||
{
|
||||
using Unit = Branding::WindowDimensionUnit;
|
||||
@ -110,16 +110,23 @@ Branding::WindowDimension::suffixes()
|
||||
* the @p transform function, which may change strings.
|
||||
*/
|
||||
static void
|
||||
loadStrings( QMap<QString, QString>& map, const YAML::Node& doc, const std::string& key, const std::function< QString(const QString&) >& transform )
|
||||
loadStrings( QMap< QString, QString >& map,
|
||||
const YAML::Node& doc,
|
||||
const std::string& key,
|
||||
const std::function< QString( const QString& ) >& transform )
|
||||
{
|
||||
if ( !doc[ key ].IsMap() )
|
||||
throw YAML::Exception( YAML::Mark(), std::string("Branding configuration is not a map: ") + key );
|
||||
{
|
||||
throw YAML::Exception( YAML::Mark(), std::string( "Branding configuration is not a map: " ) + key );
|
||||
}
|
||||
|
||||
const auto& config = CalamaresUtils::yamlMapToVariant( doc[ key ] ).toMap();
|
||||
|
||||
map.clear();
|
||||
for ( auto it = config.constBegin(); it != config.constEnd(); ++it )
|
||||
{
|
||||
map.insert( it.key(), transform( it.value().toString() ) );
|
||||
}
|
||||
}
|
||||
|
||||
/** @brief Load the @p map with strings from @p config
|
||||
@ -129,8 +136,7 @@ loadStrings( QMap<QString, QString>& map, const YAML::Node& doc, const std::stri
|
||||
* documentation for details.
|
||||
*/
|
||||
|
||||
Branding::Branding( const QString& brandingFilePath,
|
||||
QObject* parent )
|
||||
Branding::Branding( const QString& brandingFilePath, QObject* parent )
|
||||
: QObject( parent )
|
||||
, m_descriptorPath( brandingFilePath )
|
||||
, m_slideshowAPI( 1 )
|
||||
@ -141,7 +147,9 @@ Branding::Branding( const QString& brandingFilePath,
|
||||
|
||||
QDir componentDir( componentDirectory() );
|
||||
if ( !componentDir.exists() )
|
||||
{
|
||||
bail( "Bad component directory path." );
|
||||
}
|
||||
|
||||
QFile file( brandingFilePath );
|
||||
if ( file.exists() && file.open( QFile::ReadOnly | QFile::Text ) )
|
||||
@ -153,8 +161,7 @@ Branding::Branding( const QString& brandingFilePath,
|
||||
YAML::Node doc = YAML::Load( ba.constData() );
|
||||
Q_ASSERT( doc.IsMap() );
|
||||
|
||||
m_componentName = QString::fromStdString( doc[ "componentName" ]
|
||||
.as< std::string >() );
|
||||
m_componentName = QString::fromStdString( doc[ "componentName" ].as< std::string >() );
|
||||
if ( m_componentName != componentDir.dirName() )
|
||||
bail( "The branding component name should match the name of the "
|
||||
"component directory." );
|
||||
@ -165,8 +172,7 @@ Branding::Branding( const QString& brandingFilePath,
|
||||
// Copy the os-release information into a QHash for use by KMacroExpander.
|
||||
KOSRelease relInfo;
|
||||
|
||||
QHash< QString, QString > relMap{
|
||||
std::initializer_list< std::pair< QString, QString > > {
|
||||
QHash< QString, QString > relMap { std::initializer_list< std::pair< QString, QString > > {
|
||||
{ QStringLiteral( "NAME" ), relInfo.name() },
|
||||
{ QStringLiteral( "VERSION" ), relInfo.version() },
|
||||
{ QStringLiteral( "ID" ), relInfo.id() },
|
||||
@ -182,9 +188,10 @@ Branding::Branding( const QString& brandingFilePath,
|
||||
{ QStringLiteral( "BUILD_ID" ), relInfo.buildId() },
|
||||
{ QStringLiteral( "VARIANT" ), relInfo.variant() },
|
||||
{ QStringLiteral( "VARIANT_ID" ), relInfo.variantId() },
|
||||
{ QStringLiteral( "LOGO" ), relInfo.logo() }
|
||||
} };
|
||||
auto expand = [&]( const QString& s ) -> QString { return KMacroExpander::expandMacros( s, relMap, QLatin1Char( '@' ) ); };
|
||||
{ QStringLiteral( "LOGO" ), relInfo.logo() } } };
|
||||
auto expand = [&]( const QString& s ) -> QString {
|
||||
return KMacroExpander::expandMacros( s, relMap, QLatin1Char( '@' ) );
|
||||
};
|
||||
#else
|
||||
auto expand = []( const QString& s ) -> QString { return s; };
|
||||
#endif
|
||||
@ -192,26 +199,23 @@ Branding::Branding( const QString& brandingFilePath,
|
||||
|
||||
// Massage the strings, images and style sections.
|
||||
loadStrings( m_strings, doc, "strings", expand );
|
||||
loadStrings( m_images, doc, "images",
|
||||
[&]( const QString& s ) -> QString
|
||||
loadStrings( m_images, doc, "images", [&]( const QString& s ) -> QString {
|
||||
// See also image()
|
||||
const QString imageName( expand( s ) );
|
||||
QFileInfo imageFi( componentDir.absoluteFilePath( imageName ) );
|
||||
if ( !imageFi.exists() )
|
||||
{
|
||||
// See also image()
|
||||
const QString imageName( expand( s ) );
|
||||
QFileInfo imageFi( componentDir.absoluteFilePath( imageName ) );
|
||||
if ( !imageFi.exists() )
|
||||
const auto icon = QIcon::fromTheme( imageName );
|
||||
// Not found, bail out with the filename used
|
||||
if ( icon.isNull() )
|
||||
{
|
||||
const auto icon = QIcon::fromTheme( imageName );
|
||||
// Not found, bail out with the filename used
|
||||
if ( icon.isNull() )
|
||||
bail( QString( "Image file %1 does not exist." ).arg( imageFi.absoluteFilePath() ) );
|
||||
return imageName; // Not turned into a path
|
||||
bail( QString( "Image file %1 does not exist." ).arg( imageFi.absoluteFilePath() ) );
|
||||
}
|
||||
return imageFi.absoluteFilePath();
|
||||
return imageName; // Not turned into a path
|
||||
}
|
||||
);
|
||||
loadStrings( m_style, doc, "style",
|
||||
[]( const QString& s ) -> QString { return s; }
|
||||
);
|
||||
return imageFi.absoluteFilePath();
|
||||
} );
|
||||
loadStrings( m_style, doc, "style", []( const QString& s ) -> QString { return s; } );
|
||||
|
||||
if ( doc[ "slideshow" ].IsSequence() )
|
||||
{
|
||||
@ -222,8 +226,7 @@ Branding::Branding( const QString& brandingFilePath,
|
||||
QString pathString = slideShowPictures[ i ];
|
||||
QFileInfo imageFi( componentDir.absoluteFilePath( pathString ) );
|
||||
if ( !imageFi.exists() )
|
||||
bail( QString( "Slideshow file %1 does not exist." )
|
||||
.arg( imageFi.absoluteFilePath() ) );
|
||||
bail( QString( "Slideshow file %1 does not exist." ).arg( imageFi.absoluteFilePath() ) );
|
||||
|
||||
slideShowPictures[ i ] = imageFi.absoluteFilePath();
|
||||
}
|
||||
@ -232,19 +235,19 @@ Branding::Branding( const QString& brandingFilePath,
|
||||
}
|
||||
else if ( doc[ "slideshow" ].IsScalar() )
|
||||
{
|
||||
QString slideshowPath = QString::fromStdString( doc[ "slideshow" ]
|
||||
.as< std::string >() );
|
||||
QString slideshowPath = QString::fromStdString( doc[ "slideshow" ].as< std::string >() );
|
||||
QFileInfo slideshowFi( componentDir.absoluteFilePath( slideshowPath ) );
|
||||
if ( !slideshowFi.exists() ||
|
||||
!slideshowFi.fileName().toLower().endsWith( ".qml" ) )
|
||||
if ( !slideshowFi.exists() || !slideshowFi.fileName().toLower().endsWith( ".qml" ) )
|
||||
bail( QString( "Slideshow file %1 does not exist or is not a valid QML file." )
|
||||
.arg( slideshowFi.absoluteFilePath() ) );
|
||||
.arg( slideshowFi.absoluteFilePath() ) );
|
||||
m_slideshowPath = slideshowFi.absoluteFilePath();
|
||||
}
|
||||
else
|
||||
{
|
||||
bail( "Syntax error in slideshow sequence." );
|
||||
}
|
||||
|
||||
int api = doc[ "slideshowAPI" ].IsScalar() ? doc[ "slideshowAPI" ].as<int>() : -1;
|
||||
int api = doc[ "slideshowAPI" ].IsScalar() ? doc[ "slideshowAPI" ].as< int >() : -1;
|
||||
if ( ( api < 1 ) || ( api > 2 ) )
|
||||
{
|
||||
cWarning() << "Invalid or missing *slideshowAPI* in branding file.";
|
||||
@ -260,11 +263,11 @@ Branding::Branding( const QString& brandingFilePath,
|
||||
|
||||
QDir translationsDir( componentDir.filePath( "lang" ) );
|
||||
if ( !translationsDir.exists() )
|
||||
{
|
||||
cWarning() << "the branding component" << componentDir.absolutePath() << "does not ship translations.";
|
||||
}
|
||||
m_translationsPathPrefix = translationsDir.absolutePath();
|
||||
m_translationsPathPrefix.append( QString( "%1calamares-%2" )
|
||||
.arg( QDir::separator() )
|
||||
.arg( m_componentName ) );
|
||||
m_translationsPathPrefix.append( QString( "%1calamares-%2" ).arg( QDir::separator() ).arg( m_componentName ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -286,7 +289,7 @@ Branding::Branding( const QString& brandingFilePath,
|
||||
QString
|
||||
Branding::componentDirectory() const
|
||||
{
|
||||
QFileInfo fi ( m_descriptorPath );
|
||||
QFileInfo fi( m_descriptorPath );
|
||||
return fi.absoluteDir().absolutePath();
|
||||
}
|
||||
|
||||
@ -325,7 +328,7 @@ Branding::image( Branding::ImageEntry imageEntry, const QSize& size ) const
|
||||
}
|
||||
else
|
||||
{
|
||||
auto icon = QIcon::fromTheme(path);
|
||||
auto icon = QIcon::fromTheme( path );
|
||||
|
||||
Q_ASSERT( !icon.isNull() );
|
||||
return icon.pixmap( size );
|
||||
@ -333,7 +336,7 @@ Branding::image( Branding::ImageEntry imageEntry, const QSize& size ) const
|
||||
}
|
||||
|
||||
QPixmap
|
||||
Branding::image(const QString& imageName, const QSize& size) const
|
||||
Branding::image( const QString& imageName, const QSize& size ) const
|
||||
{
|
||||
QDir componentDir( componentDirectory() );
|
||||
QFileInfo imageFi( componentDir.absoluteFilePath( imageName ) );
|
||||
@ -342,7 +345,9 @@ Branding::image(const QString& imageName, const QSize& size) const
|
||||
const auto icon = QIcon::fromTheme( imageName );
|
||||
// Not found, bail out with the filename used
|
||||
if ( icon.isNull() )
|
||||
{
|
||||
return QPixmap();
|
||||
}
|
||||
return icon.pixmap( size );
|
||||
}
|
||||
return ImageRegistry::instance()->pixmap( imageFi.absoluteFilePath(), size );
|
||||
@ -360,7 +365,9 @@ Branding::stylesheet() const
|
||||
return stylesheetFile.readAll();
|
||||
}
|
||||
else
|
||||
{
|
||||
cWarning() << "The branding component" << fi.absoluteDir().absolutePath() << "does not ship stylesheet.qss.";
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
@ -369,7 +376,9 @@ Branding::setGlobals( GlobalStorage* globalStorage ) const
|
||||
{
|
||||
QVariantMap brandingMap;
|
||||
for ( const QString& key : s_stringEntryStrings )
|
||||
{
|
||||
brandingMap.insert( key, m_strings.value( key ) );
|
||||
}
|
||||
globalStorage->insert( "branding", brandingMap );
|
||||
}
|
||||
|
||||
@ -384,15 +393,17 @@ Branding::WindowDimension::isValid() const
|
||||
static inline QString
|
||||
getString( const YAML::Node& doc, const char* key )
|
||||
{
|
||||
if ( doc[key] )
|
||||
return QString::fromStdString( doc[key].as< std::string >() );
|
||||
if ( doc[ key ] )
|
||||
{
|
||||
return QString::fromStdString( doc[ key ].as< std::string >() );
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
void
|
||||
Branding::initSimpleSettings( const YAML::Node& doc )
|
||||
{
|
||||
static const NamedEnumTable< WindowExpansion > expansionNames{
|
||||
static const NamedEnumTable< WindowExpansion > expansionNames {
|
||||
{ QStringLiteral( "normal" ), WindowExpansion::Normal },
|
||||
{ QStringLiteral( "fullscreen" ), WindowExpansion::Fullscreen },
|
||||
{ QStringLiteral( "noexpand" ), WindowExpansion::Fixed }
|
||||
@ -403,7 +414,10 @@ Branding::initSimpleSettings( const YAML::Node& doc )
|
||||
m_welcomeExpandingLogo = doc[ "welcomeExpandingLogo" ].as< bool >( true );
|
||||
m_windowExpansion = expansionNames.find( getString( doc, "windowExpanding" ), ok );
|
||||
if ( !ok )
|
||||
cWarning() << "Branding module-setting *windowExpanding* interpreted as" << expansionNames.find( m_windowExpansion, ok );
|
||||
{
|
||||
cWarning() << "Branding module-setting *windowExpanding* interpreted as"
|
||||
<< expansionNames.find( m_windowExpansion, ok );
|
||||
}
|
||||
|
||||
QString windowSize = getString( doc, "windowSize" );
|
||||
if ( !windowSize.isEmpty() )
|
||||
@ -411,24 +425,26 @@ Branding::initSimpleSettings( const YAML::Node& doc )
|
||||
auto l = windowSize.split( ',' );
|
||||
if ( l.count() == 2 )
|
||||
{
|
||||
m_windowWidth = WindowDimension( l[0] );
|
||||
m_windowHeight = WindowDimension( l[1] );
|
||||
m_windowWidth = WindowDimension( l[ 0 ] );
|
||||
m_windowHeight = WindowDimension( l[ 1 ] );
|
||||
}
|
||||
}
|
||||
if ( !m_windowWidth.isValid() )
|
||||
{
|
||||
m_windowWidth = WindowDimension( CalamaresUtils::windowPreferredWidth, WindowDimensionUnit::Pixies );
|
||||
}
|
||||
if ( !m_windowHeight.isValid() )
|
||||
{
|
||||
m_windowHeight = WindowDimension( CalamaresUtils::windowPreferredHeight, WindowDimensionUnit::Pixies );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[[noreturn]] void
|
||||
Branding::bail( const QString& message )
|
||||
{
|
||||
cError() << "FATAL in"
|
||||
<< m_descriptorPath
|
||||
<< "\n" + message;
|
||||
cError() << "FATAL in" << m_descriptorPath << "\n" + message;
|
||||
::exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Calamares
|
||||
|
@ -73,10 +73,14 @@ ViewStep::setModuleInstanceKey( const QString& instanceKey )
|
||||
|
||||
|
||||
void
|
||||
ViewStep::setConfigurationMap( const QVariantMap& configurationMap ) { Q_UNUSED( configurationMap ) }
|
||||
ViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
{
|
||||
Q_UNUSED( configurationMap )
|
||||
}
|
||||
|
||||
|
||||
RequirementsList ViewStep::checkRequirements()
|
||||
RequirementsList
|
||||
ViewStep::checkRequirements()
|
||||
{
|
||||
return RequirementsList();
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ void
|
||||
ContextualProcessJob::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
{
|
||||
bool dontChroot = CalamaresUtils::getBool( configurationMap, "dontChroot", false );
|
||||
int timeout = CalamaresUtils::getInteger( configurationMap, "timeout", 10 );
|
||||
qint64 timeout = CalamaresUtils::getInteger( configurationMap, "timeout", 10 );
|
||||
if ( timeout < 1 )
|
||||
{
|
||||
timeout = 10;
|
||||
|
@ -3,13 +3,13 @@
|
||||
#
|
||||
# === This file is part of Calamares - <https://github.com/calamares> ===
|
||||
#
|
||||
# Copyright 2019 Dominic Hayes <ferenosdev@outlook.com>
|
||||
# Copyright 2014-2018, Philip Müller <philm@manjaro.org>
|
||||
# Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
|
||||
# Copyright 2014, Kevin Kofler <kevin.kofler@chello.at>
|
||||
# Copyright 2017, Alf Gaida <agaida@siduction.org>
|
||||
# Copyright 2017, Bernhard Landauer <oberon@manjaro.org>
|
||||
# Copyright 2017, Adriaan de Groot <groot@kde.org>
|
||||
# Copyright 2017, 2019, Adriaan de Groot <groot@kde.org>
|
||||
# Copyright 2019, Dominic Hayes <ferenosdev@outlook.com>
|
||||
#
|
||||
# Calamares is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -117,14 +117,11 @@ class DisplayManager(metaclass=abc.ABCMeta):
|
||||
in the target system.
|
||||
"""
|
||||
if self.executable is None:
|
||||
return True
|
||||
return False
|
||||
|
||||
bin_path = "{!s}/usr/bin/{!s}".format(self.root_mount_point, self.executable)
|
||||
sbin_path = "{!s}/usr/sbin/{!s}".format(self.root_mount_point, self.executable)
|
||||
return (
|
||||
os.path.exists(bin_path)
|
||||
or os.path.exists(sbin_path)
|
||||
)
|
||||
return os.path.exists(bin_path) or os.path.exists(sbin_path)
|
||||
|
||||
# The four abstract methods below are called in the order listed here.
|
||||
# They must all be implemented by subclasses, but not all of them
|
||||
@ -251,10 +248,33 @@ class DMmdm(DisplayManager):
|
||||
class DMgdm(DisplayManager):
|
||||
name = "gdm"
|
||||
executable = "gdm"
|
||||
config = None # Set by have_dm()
|
||||
|
||||
def have_dm(self):
|
||||
"""
|
||||
GDM exists with different executable names, so search
|
||||
for one of them and use it.
|
||||
"""
|
||||
for executable, config in (
|
||||
( "gdm", "etc/gdm/custom.conf" ),
|
||||
( "gdm3", "etc/gdm3/daemon.conf" )
|
||||
):
|
||||
bin_path = "{!s}/usr/bin/{!s}".format(self.root_mount_point, executable)
|
||||
sbin_path = "{!s}/usr/sbin/{!s}".format(self.root_mount_point, executable)
|
||||
if os.path.exists(bin_path) or os.path.exists(sbin_path):
|
||||
# Keep the found-executable name around for later
|
||||
self.executable = executable
|
||||
self.config = config
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def set_autologin(self, username, do_autologin, default_desktop_environment):
|
||||
if self.config is None:
|
||||
raise ValueError( "No config file for GDM has been set." )
|
||||
|
||||
# Systems with GDM as Desktop Manager
|
||||
gdm_conf_path = os.path.join(self.root_mount_point, "etc/gdm/custom.conf")
|
||||
gdm_conf_path = os.path.join(self.root_mount_point, self.config)
|
||||
|
||||
if os.path.exists(gdm_conf_path):
|
||||
with open(gdm_conf_path, 'r') as gdm_conf:
|
||||
|
@ -69,7 +69,7 @@ void
|
||||
ShellProcessJob::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
{
|
||||
bool dontChroot = CalamaresUtils::getBool( configurationMap, "dontChroot", false );
|
||||
int timeout = CalamaresUtils::getInteger( configurationMap, "timeout", 10 );
|
||||
qint64 timeout = CalamaresUtils::getInteger( configurationMap, "timeout", 10 );
|
||||
if ( timeout < 1 )
|
||||
{
|
||||
timeout = 10;
|
||||
|
Loading…
Reference in New Issue
Block a user