2020-11-11 13:08:42 +01:00
|
|
|
/* === This file is part of Calamares - <https://calamares.io> ===
|
|
|
|
*
|
|
|
|
* SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*
|
|
|
|
* Calamares is Free Software: see the License-Identifier above.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Config.h"
|
|
|
|
|
2020-11-11 14:41:45 +01:00
|
|
|
#include "utils/CalamaresUtilsSystem.h"
|
2020-11-11 13:21:16 +01:00
|
|
|
#include "utils/Logger.h"
|
|
|
|
#include "utils/Variant.h"
|
|
|
|
|
2020-11-11 13:08:42 +01:00
|
|
|
Config::Config( QObject* parent )
|
|
|
|
: QObject( parent )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2020-11-11 13:21:16 +01:00
|
|
|
Config::setConfigurationMap( const QVariantMap& configurationMap )
|
2020-11-11 13:08:42 +01:00
|
|
|
{
|
2020-11-11 13:21:16 +01:00
|
|
|
m_lnfPath = CalamaresUtils::getString( configurationMap, "lnftool" );
|
|
|
|
|
|
|
|
if ( m_lnfPath.isEmpty() )
|
|
|
|
{
|
|
|
|
cWarning() << "no lnftool given for plasmalnf module.";
|
|
|
|
}
|
2020-11-11 14:41:45 +01:00
|
|
|
|
|
|
|
m_liveUser = CalamaresUtils::getString( configurationMap, "liveuser" );
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Config::setTheme( const QString& id )
|
|
|
|
{
|
|
|
|
if ( m_themeId == id )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_themeId = id;
|
|
|
|
if ( lnfToolPath().isEmpty() )
|
|
|
|
{
|
|
|
|
cWarning() << "no lnftool given for plasmalnf module.";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QStringList command;
|
|
|
|
if ( !m_liveUser.isEmpty() )
|
|
|
|
{
|
|
|
|
command << "sudo"
|
|
|
|
<< "-E"
|
|
|
|
<< "-H"
|
|
|
|
<< "-u" << m_liveUser;
|
|
|
|
}
|
|
|
|
command << lnfToolPath() << "--resetLayout"
|
|
|
|
<< "--apply" << id;
|
|
|
|
auto r = CalamaresUtils::System::instance()->runCommand( command, std::chrono::seconds( 10 ) );
|
|
|
|
|
|
|
|
if ( r.getExitCode() )
|
|
|
|
{
|
|
|
|
cWarning() << r.explainProcess( command, std::chrono::seconds( 10 ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cDebug() << "Plasma look-and-feel applied" << id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
emit themeChanged( id );
|
2020-11-11 13:08:42 +01:00
|
|
|
}
|