[plasmalnf] C++ style and reduce includes

This commit is contained in:
Adriaan de Groot 2017-12-04 06:44:37 -05:00
parent eb92755b0a
commit b10b19e9ee
5 changed files with 27 additions and 54 deletions

View File

@ -18,28 +18,14 @@
#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 "JobQueue.h"
#include "utils/CalamaresUtilsSystem.h"
#include "utils/Logger.h"
PlasmaLnfJob::PlasmaLnfJob( const QString& lnfPath, const QString& id )
: m_lnfPath( lnfPath )
, m_id(id)
, m_id( id )
{
}
@ -75,15 +61,17 @@ PlasmaLnfJob::exec()
auto system = CalamaresUtils::System::instance();
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
QStringList command( {
"sudo", "-E", "-H", "-u", gs->value("username").toString(),
m_lnfPath, "-platform", "minimal", "--resetLayout", "--apply", m_id } );
QStringList command(
{
"sudo", "-E", "-H", "-u", gs->value( "username" ).toString(),
m_lnfPath, "-platform", "minimal", "--resetLayout", "--apply", m_id
} );
int r = system->targetEnvCall( command );
if (r)
if ( r )
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();
}

View File

@ -20,28 +20,20 @@
#include "ui_page_plasmalnf.h"
#include "Branding.h"
#include "JobQueue.h"
#include "GlobalStorage.h"
#include "utils/Logger.h"
#include "utils/CalamaresUtilsGui.h"
#include "utils/Retranslator.h"
#include "ViewManager.h"
#include <KPackage/Package>
#include <KPackage/PackageLoader>
#include <QButtonGroup>
#include <QDesktopServices>
#include <QLabel>
static PlasmaLnfList plasma_themes()
{
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() };
cDebug() << "LNF Package" << data.pluginId();
cDebug() << " .." << data.name();
@ -53,30 +45,29 @@ static PlasmaLnfList plasma_themes()
}
PlasmaLnfPage::PlasmaLnfPage(QWidget *parent)
PlasmaLnfPage::PlasmaLnfPage( QWidget* parent )
: QWidget( parent )
, ui( new Ui::PlasmaLnfPage )
{
using StringEntry = Calamares::Branding::StringEntry;
ui->setupUi( this );
CALAMARES_RETRANSLATE(
{
ui->retranslateUi( this );
ui->generalExplanation->setText( tr( "Please choose a look-and-feel for the KDE Plasma Desktop, below." ) );
m_availableLnf = plasma_themes();
ui->lnfCombo->clear();
for ( const auto& p : m_availableLnf )
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
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.";
return;
@ -88,7 +79,7 @@ PlasmaLnfPage::activated( int index )
}
void
PlasmaLnfPage::setLnfPath(const QString& path)
PlasmaLnfPage::setLnfPath( const QString& path )
{
m_lnfPath = path;
}

View File

@ -19,8 +19,9 @@
#ifndef PLASMALNFPAGE_H
#define PLASMALNFPAGE_H
#include <QList>
#include <QString>
#include <QWidget>
#include <QUrl>
namespace Ui
{

View File

@ -15,18 +15,13 @@
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include "JobQueue.h"
#include "GlobalStorage.h"
#include "utils/Logger.h"
#include "utils/CalamaresUtils.h"
#include "utils/CalamaresUtilsSystem.h"
#include "PlasmaLnfViewStep.h"
#include "PlasmaLnfJob.h"
#include "PlasmaLnfPage.h"
#include "PlasmaLnfViewStep.h"
#include <QDesktopServices>
#include "utils/Logger.h"
#include <QProcess>
#include <QVariantMap>
@ -114,9 +109,7 @@ PlasmaLnfViewStep::jobs() const
cDebug() << "Creating Plasma LNF jobs ..";
if ( !m_themeId.isEmpty() && !m_lnfPath.isEmpty() )
{
l.append( Calamares::job_ptr( new PlasmaLnfJob( m_lnfPath, m_themeId ) ) );
}
return l;
}
@ -130,7 +123,7 @@ PlasmaLnfViewStep::setConfigurationMap( const QVariantMap& configurationMap )
m_lnfPath = lnfPath;
m_widget->setLnfPath( m_lnfPath );
if (m_lnfPath.isEmpty())
if ( m_lnfPath.isEmpty() )
cDebug() << "WARNING: no lnftool given for plasmalnf module.";
}
@ -153,7 +146,7 @@ PlasmaLnfViewStep::themeSelected( const QString& id )
return;
}
if ( (lnftool.exitCode() == 0) && (lnftool.exitStatus() == QProcess::NormalExit ) )
if ( ( lnftool.exitCode() == 0 ) && ( lnftool.exitStatus() == QProcess::NormalExit ) )
cDebug() << "Plasma look-and-feel applied" << id;
else
cDebug() << "WARNING: could not apply look-and-feel" << id;

View File

@ -57,7 +57,7 @@ public:
void setConfigurationMap( const QVariantMap& configurationMap ) override;
public slots:
void themeSelected( const QString &id );
void themeSelected( const QString& id );
private:
PlasmaLnfPage* m_widget;