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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "PlasmaLnfPage.h"
|
|
|
|
|
|
|
|
#include "ui_page_plasmalnf.h"
|
|
|
|
|
|
|
|
#include "utils/Logger.h"
|
|
|
|
#include "utils/Retranslator.h"
|
|
|
|
|
2017-12-03 21:34:06 +01:00
|
|
|
#include <KPackage/Package>
|
|
|
|
#include <KPackage/PackageLoader>
|
|
|
|
|
2017-12-04 12:40:13 +01:00
|
|
|
static PlasmaLnfList plasma_themes()
|
2017-12-03 21:34:06 +01:00
|
|
|
{
|
2017-12-04 12:40:13 +01:00
|
|
|
PlasmaLnfList packages;
|
2017-12-03 21:34:06 +01:00
|
|
|
|
2017-12-04 12:44:37 +01:00
|
|
|
QList<KPluginMetaData> pkgs = KPackage::PackageLoader::self()->listPackages( "Plasma/LookAndFeel" );
|
2017-12-03 21:34:06 +01:00
|
|
|
|
2017-12-04 12:44:37 +01:00
|
|
|
for ( const KPluginMetaData& data : pkgs )
|
|
|
|
{
|
2017-12-04 12:40:13 +01:00
|
|
|
packages << PlasmaLnfDescriptor{ data.pluginId(), data.name() };
|
|
|
|
cDebug() << "LNF Package" << data.pluginId();
|
|
|
|
cDebug() << " .." << data.name();
|
|
|
|
cDebug() << " .." << data.description();
|
|
|
|
cDebug() << " .." << 'V' << data.isValid() << 'H' << data.isHidden() << 'D' << data.isEnabledByDefault();
|
2017-12-03 21:34:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return packages;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-04 12:44:37 +01:00
|
|
|
PlasmaLnfPage::PlasmaLnfPage( QWidget* parent )
|
2017-12-03 18:47:41 +01:00
|
|
|
: QWidget( parent )
|
|
|
|
, ui( new Ui::PlasmaLnfPage )
|
|
|
|
{
|
|
|
|
ui->setupUi( this );
|
|
|
|
CALAMARES_RETRANSLATE(
|
2017-12-04 12:44:37 +01:00
|
|
|
{
|
2017-12-03 18:47:41 +01:00
|
|
|
ui->retranslateUi( this );
|
|
|
|
ui->generalExplanation->setText( tr( "Please choose a look-and-feel for the KDE Plasma Desktop, below." ) );
|
2017-12-04 12:40:13 +01:00
|
|
|
m_availableLnf = plasma_themes();
|
|
|
|
ui->lnfCombo->clear();
|
|
|
|
for ( const auto& p : m_availableLnf )
|
|
|
|
ui->lnfCombo->addItem( p.name );
|
2017-12-04 12:44:37 +01:00
|
|
|
}
|
2017-12-03 18:47:41 +01:00
|
|
|
)
|
|
|
|
|
2017-12-04 12:44:37 +01:00
|
|
|
QObject::connect<void( QComboBox::* )( int )>( ui->lnfCombo, &QComboBox::activated, this, &PlasmaLnfPage::activated );
|
2017-12-03 18:47:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-12-04 12:40:13 +01:00
|
|
|
PlasmaLnfPage::activated( int index )
|
2017-12-03 18:47:41 +01:00
|
|
|
{
|
2017-12-04 12:44:37 +01:00
|
|
|
if ( ( index < 0 ) || ( index > m_availableLnf.length() ) )
|
2017-12-03 22:09:34 +01:00
|
|
|
{
|
2017-12-04 12:40:13 +01:00
|
|
|
cDebug() << "Plasma LNF index" << index << "out of range.";
|
2017-12-03 22:09:34 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-12-04 12:40:13 +01:00
|
|
|
const PlasmaLnfDescriptor& lnf = m_availableLnf.at( index );
|
|
|
|
cDebug() << "Changed to" << index << lnf.id << lnf.name;
|
|
|
|
emit plasmaThemeSelected( lnf.id );
|
2017-12-03 18:47:41 +01:00
|
|
|
}
|
2017-12-03 21:41:52 +01:00
|
|
|
|
|
|
|
void
|
2017-12-04 12:44:37 +01:00
|
|
|
PlasmaLnfPage::setLnfPath( const QString& path )
|
2017-12-03 21:41:52 +01:00
|
|
|
{
|
|
|
|
m_lnfPath = path;
|
|
|
|
}
|