mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-26 08:58:22 -04:00
[plasmalnf] C++ style and reduce includes
This commit is contained in:
parent
eb92755b0a
commit
b10b19e9ee
5 changed files with 27 additions and 54 deletions
|
@ -18,28 +18,14 @@
|
||||||
|
|
||||||
#include "PlasmaLnfJob.h"
|
#include "PlasmaLnfJob.h"
|
||||||
|
|
||||||
#include <QDateTime>
|
|
||||||
#include <QDir>
|
|
||||||
#include <QProcess>
|
|
||||||
#include <QStandardPaths>
|
|
||||||
#include <QThread>
|
|
||||||
|
|
||||||
#include <KService>
|
|
||||||
#include <KServiceTypeTrader>
|
|
||||||
#include <KPluginLoader> // Future
|
|
||||||
|
|
||||||
#include <Plasma/PluginLoader> // TODO: port to KPluginLoader
|
|
||||||
|
|
||||||
#include "CalamaresVersion.h"
|
|
||||||
#include "JobQueue.h"
|
|
||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
|
#include "JobQueue.h"
|
||||||
#include "utils/CalamaresUtilsSystem.h"
|
#include "utils/CalamaresUtilsSystem.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
PlasmaLnfJob::PlasmaLnfJob( const QString& lnfPath, const QString& id )
|
PlasmaLnfJob::PlasmaLnfJob( const QString& lnfPath, const QString& id )
|
||||||
: m_lnfPath( lnfPath )
|
: m_lnfPath( lnfPath )
|
||||||
, m_id(id)
|
, m_id( id )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,15 +61,17 @@ PlasmaLnfJob::exec()
|
||||||
auto system = CalamaresUtils::System::instance();
|
auto system = CalamaresUtils::System::instance();
|
||||||
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
||||||
|
|
||||||
QStringList command( {
|
QStringList command(
|
||||||
"sudo", "-E", "-H", "-u", gs->value("username").toString(),
|
{
|
||||||
m_lnfPath, "-platform", "minimal", "--resetLayout", "--apply", m_id } );
|
"sudo", "-E", "-H", "-u", gs->value( "username" ).toString(),
|
||||||
|
m_lnfPath, "-platform", "minimal", "--resetLayout", "--apply", m_id
|
||||||
|
} );
|
||||||
|
|
||||||
int r = system->targetEnvCall( command );
|
int r = system->targetEnvCall( command );
|
||||||
if (r)
|
if ( r )
|
||||||
return Calamares::JobResult::error(
|
return Calamares::JobResult::error(
|
||||||
tr( "Could not select KDE Plasma Look-and-Feel package" ),
|
tr( "Could not select KDE Plasma Look-and-Feel package" ),
|
||||||
tr( "Could not select KDE Plasma Look-and-Feel package" ) );
|
tr( "Could not select KDE Plasma Look-and-Feel package" ) );
|
||||||
|
|
||||||
return Calamares::JobResult::ok();
|
return Calamares::JobResult::ok();
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,28 +20,20 @@
|
||||||
|
|
||||||
#include "ui_page_plasmalnf.h"
|
#include "ui_page_plasmalnf.h"
|
||||||
|
|
||||||
#include "Branding.h"
|
|
||||||
#include "JobQueue.h"
|
|
||||||
#include "GlobalStorage.h"
|
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/CalamaresUtilsGui.h"
|
|
||||||
#include "utils/Retranslator.h"
|
#include "utils/Retranslator.h"
|
||||||
#include "ViewManager.h"
|
|
||||||
|
|
||||||
#include <KPackage/Package>
|
#include <KPackage/Package>
|
||||||
#include <KPackage/PackageLoader>
|
#include <KPackage/PackageLoader>
|
||||||
|
|
||||||
#include <QButtonGroup>
|
|
||||||
#include <QDesktopServices>
|
|
||||||
#include <QLabel>
|
|
||||||
|
|
||||||
static PlasmaLnfList plasma_themes()
|
static PlasmaLnfList plasma_themes()
|
||||||
{
|
{
|
||||||
PlasmaLnfList packages;
|
PlasmaLnfList packages;
|
||||||
|
|
||||||
QList<KPluginMetaData> pkgs = KPackage::PackageLoader::self()->listPackages("Plasma/LookAndFeel");
|
QList<KPluginMetaData> pkgs = KPackage::PackageLoader::self()->listPackages( "Plasma/LookAndFeel" );
|
||||||
|
|
||||||
for (const KPluginMetaData &data : pkgs) {
|
for ( const KPluginMetaData& data : pkgs )
|
||||||
|
{
|
||||||
packages << PlasmaLnfDescriptor{ data.pluginId(), data.name() };
|
packages << PlasmaLnfDescriptor{ data.pluginId(), data.name() };
|
||||||
cDebug() << "LNF Package" << data.pluginId();
|
cDebug() << "LNF Package" << data.pluginId();
|
||||||
cDebug() << " .." << data.name();
|
cDebug() << " .." << data.name();
|
||||||
|
@ -53,30 +45,29 @@ static PlasmaLnfList plasma_themes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PlasmaLnfPage::PlasmaLnfPage(QWidget *parent)
|
PlasmaLnfPage::PlasmaLnfPage( QWidget* parent )
|
||||||
: QWidget( parent )
|
: QWidget( parent )
|
||||||
, ui( new Ui::PlasmaLnfPage )
|
, ui( new Ui::PlasmaLnfPage )
|
||||||
{
|
{
|
||||||
using StringEntry = Calamares::Branding::StringEntry;
|
|
||||||
|
|
||||||
ui->setupUi( this );
|
ui->setupUi( this );
|
||||||
CALAMARES_RETRANSLATE(
|
CALAMARES_RETRANSLATE(
|
||||||
|
{
|
||||||
ui->retranslateUi( this );
|
ui->retranslateUi( this );
|
||||||
ui->generalExplanation->setText( tr( "Please choose a look-and-feel for the KDE Plasma Desktop, below." ) );
|
ui->generalExplanation->setText( tr( "Please choose a look-and-feel for the KDE Plasma Desktop, below." ) );
|
||||||
m_availableLnf = plasma_themes();
|
m_availableLnf = plasma_themes();
|
||||||
ui->lnfCombo->clear();
|
ui->lnfCombo->clear();
|
||||||
for ( const auto& p : m_availableLnf )
|
for ( const auto& p : m_availableLnf )
|
||||||
ui->lnfCombo->addItem( p.name );
|
ui->lnfCombo->addItem( p.name );
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
QObject::connect<void( QComboBox::* )( int )>( ui->lnfCombo, &QComboBox::activated, this, &PlasmaLnfPage::activated );
|
||||||
QObject::connect<void(QComboBox::*)(int)>(ui->lnfCombo, &QComboBox::activated, this, &PlasmaLnfPage::activated);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PlasmaLnfPage::activated( int index )
|
PlasmaLnfPage::activated( int index )
|
||||||
{
|
{
|
||||||
if ( (index < 0) || (index > m_availableLnf.length()) )
|
if ( ( index < 0 ) || ( index > m_availableLnf.length() ) )
|
||||||
{
|
{
|
||||||
cDebug() << "Plasma LNF index" << index << "out of range.";
|
cDebug() << "Plasma LNF index" << index << "out of range.";
|
||||||
return;
|
return;
|
||||||
|
@ -88,7 +79,7 @@ PlasmaLnfPage::activated( int index )
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PlasmaLnfPage::setLnfPath(const QString& path)
|
PlasmaLnfPage::setLnfPath( const QString& path )
|
||||||
{
|
{
|
||||||
m_lnfPath = path;
|
m_lnfPath = path;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,9 @@
|
||||||
#ifndef PLASMALNFPAGE_H
|
#ifndef PLASMALNFPAGE_H
|
||||||
#define PLASMALNFPAGE_H
|
#define PLASMALNFPAGE_H
|
||||||
|
|
||||||
|
#include <QList>
|
||||||
|
#include <QString>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QUrl>
|
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,18 +15,13 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
#include "PlasmaLnfViewStep.h"
|
||||||
#include "JobQueue.h"
|
|
||||||
#include "GlobalStorage.h"
|
|
||||||
#include "utils/Logger.h"
|
|
||||||
#include "utils/CalamaresUtils.h"
|
|
||||||
#include "utils/CalamaresUtilsSystem.h"
|
|
||||||
|
|
||||||
#include "PlasmaLnfJob.h"
|
#include "PlasmaLnfJob.h"
|
||||||
#include "PlasmaLnfPage.h"
|
#include "PlasmaLnfPage.h"
|
||||||
#include "PlasmaLnfViewStep.h"
|
|
||||||
|
|
||||||
#include <QDesktopServices>
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
|
|
||||||
|
@ -114,9 +109,7 @@ PlasmaLnfViewStep::jobs() const
|
||||||
|
|
||||||
cDebug() << "Creating Plasma LNF jobs ..";
|
cDebug() << "Creating Plasma LNF jobs ..";
|
||||||
if ( !m_themeId.isEmpty() && !m_lnfPath.isEmpty() )
|
if ( !m_themeId.isEmpty() && !m_lnfPath.isEmpty() )
|
||||||
{
|
|
||||||
l.append( Calamares::job_ptr( new PlasmaLnfJob( m_lnfPath, m_themeId ) ) );
|
l.append( Calamares::job_ptr( new PlasmaLnfJob( m_lnfPath, m_themeId ) ) );
|
||||||
}
|
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +123,7 @@ PlasmaLnfViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||||
m_lnfPath = lnfPath;
|
m_lnfPath = lnfPath;
|
||||||
m_widget->setLnfPath( m_lnfPath );
|
m_widget->setLnfPath( m_lnfPath );
|
||||||
|
|
||||||
if (m_lnfPath.isEmpty())
|
if ( m_lnfPath.isEmpty() )
|
||||||
cDebug() << "WARNING: no lnftool given for plasmalnf module.";
|
cDebug() << "WARNING: no lnftool given for plasmalnf module.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +146,7 @@ PlasmaLnfViewStep::themeSelected( const QString& id )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (lnftool.exitCode() == 0) && (lnftool.exitStatus() == QProcess::NormalExit ) )
|
if ( ( lnftool.exitCode() == 0 ) && ( lnftool.exitStatus() == QProcess::NormalExit ) )
|
||||||
cDebug() << "Plasma look-and-feel applied" << id;
|
cDebug() << "Plasma look-and-feel applied" << id;
|
||||||
else
|
else
|
||||||
cDebug() << "WARNING: could not apply look-and-feel" << id;
|
cDebug() << "WARNING: could not apply look-and-feel" << id;
|
||||||
|
|
|
@ -57,7 +57,7 @@ public:
|
||||||
void setConfigurationMap( const QVariantMap& configurationMap ) override;
|
void setConfigurationMap( const QVariantMap& configurationMap ) override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void themeSelected( const QString &id );
|
void themeSelected( const QString& id );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PlasmaLnfPage* m_widget;
|
PlasmaLnfPage* m_widget;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue