2017-12-03 18:47:41 +01:00
|
|
|
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
|
|
|
*
|
|
|
|
* Copyright 2017, Adriaan de Groot <groot@kde.org>
|
|
|
|
*
|
|
|
|
* Calamares is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Calamares is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2017-12-04 12:44:37 +01:00
|
|
|
#include "PlasmaLnfViewStep.h"
|
2017-12-03 18:47:41 +01:00
|
|
|
|
|
|
|
#include "PlasmaLnfJob.h"
|
|
|
|
#include "PlasmaLnfPage.h"
|
|
|
|
|
2017-12-04 12:44:37 +01:00
|
|
|
#include "utils/Logger.h"
|
|
|
|
|
2017-12-04 12:40:13 +01:00
|
|
|
#include <QProcess>
|
2017-12-03 18:47:41 +01:00
|
|
|
#include <QVariantMap>
|
|
|
|
|
|
|
|
CALAMARES_PLUGIN_FACTORY_DEFINITION( PlasmaLnfViewStepFactory, registerPlugin<PlasmaLnfViewStep>(); )
|
|
|
|
|
|
|
|
PlasmaLnfViewStep::PlasmaLnfViewStep( QObject* parent )
|
|
|
|
: Calamares::ViewStep( parent )
|
|
|
|
, m_widget( new PlasmaLnfPage )
|
|
|
|
{
|
|
|
|
connect( m_widget, &PlasmaLnfPage::plasmaThemeSelected, this, &PlasmaLnfViewStep::themeSelected );
|
|
|
|
emit nextStatusChanged( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PlasmaLnfViewStep::~PlasmaLnfViewStep()
|
|
|
|
{
|
|
|
|
if ( m_widget && m_widget->parent() == nullptr )
|
|
|
|
m_widget->deleteLater();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString
|
|
|
|
PlasmaLnfViewStep::prettyName() const
|
|
|
|
{
|
|
|
|
return tr( "Look-and-Feel" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QWidget*
|
|
|
|
PlasmaLnfViewStep::widget()
|
|
|
|
{
|
|
|
|
return m_widget;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
PlasmaLnfViewStep::next()
|
|
|
|
{
|
|
|
|
emit done();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
PlasmaLnfViewStep::back()
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
PlasmaLnfViewStep::isNextEnabled() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
PlasmaLnfViewStep::isBackEnabled() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
PlasmaLnfViewStep::isAtBeginning() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
PlasmaLnfViewStep::isAtEnd() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PlasmaLnfViewStep::onLeave()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-03 18:58:54 +01:00
|
|
|
QList<Calamares::job_ptr>
|
2017-12-03 18:47:41 +01:00
|
|
|
PlasmaLnfViewStep::jobs() const
|
|
|
|
{
|
2017-12-03 18:58:54 +01:00
|
|
|
QList<Calamares::job_ptr> l;
|
2017-12-03 18:47:41 +01:00
|
|
|
|
|
|
|
cDebug() << "Creating Plasma LNF jobs ..";
|
2017-12-04 17:54:33 +01:00
|
|
|
if ( !m_themeId.isEmpty() )
|
|
|
|
{
|
|
|
|
if ( !m_lnfPath.isEmpty() )
|
|
|
|
l.append( Calamares::job_ptr( new PlasmaLnfJob( m_lnfPath, m_themeId ) ) );
|
|
|
|
else
|
|
|
|
cDebug() << "WARNING: no lnftool given for plasmalnf module.";
|
|
|
|
}
|
2017-12-03 18:47:41 +01:00
|
|
|
return l;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
PlasmaLnfViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|
|
|
{
|
2017-12-03 18:58:54 +01:00
|
|
|
QString lnfPath;
|
|
|
|
if ( configurationMap.contains( "lnftool" ) && configurationMap.value( "lnftool" ).type() == QVariant::String )
|
|
|
|
lnfPath = configurationMap.value( "lnftool" ).toString();
|
|
|
|
m_lnfPath = lnfPath;
|
2017-12-03 21:41:52 +01:00
|
|
|
m_widget->setLnfPath( m_lnfPath );
|
2017-12-03 18:47:41 +01:00
|
|
|
|
2017-12-04 12:44:37 +01:00
|
|
|
if ( m_lnfPath.isEmpty() )
|
2017-12-03 18:47:41 +01:00
|
|
|
cDebug() << "WARNING: no lnftool given for plasmalnf module.";
|
2017-12-04 15:37:34 +01:00
|
|
|
|
|
|
|
QString liveUser;
|
|
|
|
if ( configurationMap.contains( "liveuser" ) && configurationMap.value( "liveuser" ).type() == QVariant::String )
|
|
|
|
liveUser = configurationMap.value( "liveuser" ).toString();
|
|
|
|
m_liveUser = liveUser;
|
2017-12-03 18:47:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PlasmaLnfViewStep::themeSelected( const QString& id )
|
|
|
|
{
|
|
|
|
m_themeId = id;
|
2017-12-04 17:51:16 +01:00
|
|
|
if ( m_lnfPath.isEmpty() )
|
|
|
|
{
|
|
|
|
cDebug() << "WARNING: no lnftool given for plasmalnf module.";
|
|
|
|
return;
|
|
|
|
}
|
2017-12-04 12:40:13 +01:00
|
|
|
|
|
|
|
QProcess lnftool;
|
2017-12-04 15:37:34 +01:00
|
|
|
if ( !m_liveUser.isEmpty() )
|
|
|
|
lnftool.start( "sudo", {"-E", "-H", "-u", m_liveUser, m_lnfPath, "--resetLayout", "--apply", id} );
|
|
|
|
else
|
|
|
|
lnftool.start( m_lnfPath, {"--resetLayout", "--apply", id} );
|
2017-12-04 12:40:13 +01:00
|
|
|
|
|
|
|
if ( !lnftool.waitForStarted( 1000 ) )
|
|
|
|
{
|
|
|
|
cDebug() << "WARNING: could not start look-and-feel" << m_lnfPath;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ( !lnftool.waitForFinished() )
|
|
|
|
{
|
|
|
|
cDebug() << "WARNING:" << m_lnfPath << "timed out.";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-12-04 12:44:37 +01:00
|
|
|
if ( ( lnftool.exitCode() == 0 ) && ( lnftool.exitStatus() == QProcess::NormalExit ) )
|
2017-12-04 12:40:13 +01:00
|
|
|
cDebug() << "Plasma look-and-feel applied" << id;
|
|
|
|
else
|
|
|
|
cDebug() << "WARNING: could not apply look-and-feel" << id;
|
2017-12-03 18:47:41 +01:00
|
|
|
}
|