[plasmalnf] Enable translations
- Move tool-running to the view-step - Enable translations by showing name instead of theme-id - More verbose logging
This commit is contained in:
parent
71966b5330
commit
eb92755b0a
@ -34,16 +34,19 @@
|
|||||||
#include <QButtonGroup>
|
#include <QButtonGroup>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QProcess>
|
|
||||||
|
|
||||||
static QStringList plasma_themes()
|
static PlasmaLnfList plasma_themes()
|
||||||
{
|
{
|
||||||
QStringList 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 << data.pluginId();
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
return packages;
|
return packages;
|
||||||
@ -60,36 +63,28 @@ PlasmaLnfPage::PlasmaLnfPage(QWidget *parent)
|
|||||||
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();
|
||||||
|
ui->lnfCombo->clear();
|
||||||
|
for ( const auto& p : m_availableLnf )
|
||||||
|
ui->lnfCombo->addItem( p.name );
|
||||||
)
|
)
|
||||||
|
|
||||||
ui->lnfCombo->addItems( plasma_themes() );
|
|
||||||
|
|
||||||
QObject::connect<void(QComboBox::*)(const QString&)>(ui->lnfCombo, &QComboBox::activated, this, &PlasmaLnfPage::activated);
|
QObject::connect<void(QComboBox::*)(int)>(ui->lnfCombo, &QComboBox::activated, this, &PlasmaLnfPage::activated);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PlasmaLnfPage::activated(const QString& name)
|
PlasmaLnfPage::activated( int index )
|
||||||
{
|
{
|
||||||
cDebug() << "Changed to" << name;
|
if ( (index < 0) || (index > m_availableLnf.length()) )
|
||||||
|
|
||||||
QProcess lnftool;
|
|
||||||
lnftool.start( m_lnfPath, {"--resetLayout", "--apply", name} );
|
|
||||||
|
|
||||||
if ( !lnftool.waitForStarted( 1000 ) )
|
|
||||||
{
|
{
|
||||||
cDebug() << "WARNING: could not start look-and-feel" << m_lnfPath;
|
cDebug() << "Plasma LNF index" << index << "out of range.";
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ( !lnftool.waitForFinished() )
|
|
||||||
{
|
|
||||||
cDebug() << "WARNING:" << m_lnfPath << "timed out.";
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (lnftool.exitCode() == 0) && (lnftool.exitStatus() == QProcess::NormalExit ) )
|
const PlasmaLnfDescriptor& lnf = m_availableLnf.at( index );
|
||||||
emit plasmaThemeSelected( name );
|
cDebug() << "Changed to" << index << lnf.id << lnf.name;
|
||||||
else
|
emit plasmaThemeSelected( lnf.id );
|
||||||
cDebug() << "WARNING: could not apply look-and-feel" << name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -27,6 +27,14 @@ namespace Ui
|
|||||||
class PlasmaLnfPage;
|
class PlasmaLnfPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct PlasmaLnfDescriptor
|
||||||
|
{
|
||||||
|
QString id;
|
||||||
|
QString name;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
using PlasmaLnfList = QList<PlasmaLnfDescriptor>;
|
||||||
|
|
||||||
class PlasmaLnfPage : public QWidget
|
class PlasmaLnfPage : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -36,14 +44,15 @@ public:
|
|||||||
void setLnfPath( const QString& path );
|
void setLnfPath( const QString& path );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void activated(const QString& name);
|
void activated( int index );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void plasmaThemeSelected( const QString &id );
|
void plasmaThemeSelected( const QString& id );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::PlasmaLnfPage* ui;
|
Ui::PlasmaLnfPage* ui;
|
||||||
QString m_lnfPath;
|
QString m_lnfPath;
|
||||||
|
PlasmaLnfList m_availableLnf;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //PLASMALNFPAGE_H
|
#endif //PLASMALNFPAGE_H
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "PlasmaLnfViewStep.h"
|
#include "PlasmaLnfViewStep.h"
|
||||||
|
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
#include <QProcess>
|
||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
|
|
||||||
CALAMARES_PLUGIN_FACTORY_DEFINITION( PlasmaLnfViewStepFactory, registerPlugin<PlasmaLnfViewStep>(); )
|
CALAMARES_PLUGIN_FACTORY_DEFINITION( PlasmaLnfViewStepFactory, registerPlugin<PlasmaLnfViewStep>(); )
|
||||||
@ -137,4 +138,23 @@ void
|
|||||||
PlasmaLnfViewStep::themeSelected( const QString& id )
|
PlasmaLnfViewStep::themeSelected( const QString& id )
|
||||||
{
|
{
|
||||||
m_themeId = id;
|
m_themeId = id;
|
||||||
|
|
||||||
|
QProcess lnftool;
|
||||||
|
lnftool.start( m_lnfPath, {"--resetLayout", "--apply", id} );
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user