[plasmalnf] Hammer in theme-changing
- Tool is currently a hard-coded path.
This commit is contained in:
parent
8c65ee5481
commit
2d3defcca3
@ -1,6 +1,6 @@
|
|||||||
find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE)
|
find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE)
|
||||||
|
|
||||||
find_package( KF5 5.29 REQUIRED CoreAddons Plasma Service )
|
find_package( KF5 5.29 REQUIRED CoreAddons Plasma Service Package )
|
||||||
|
|
||||||
calamares_add_plugin( plasmalnf
|
calamares_add_plugin( plasmalnf
|
||||||
TYPE viewmodule
|
TYPE viewmodule
|
||||||
@ -13,6 +13,7 @@ calamares_add_plugin( plasmalnf
|
|||||||
page_plasmalnf.ui
|
page_plasmalnf.ui
|
||||||
LINK_PRIVATE_LIBRARIES
|
LINK_PRIVATE_LIBRARIES
|
||||||
calamaresui
|
calamaresui
|
||||||
|
KF5::Package
|
||||||
KF5::Plasma
|
KF5::Plasma
|
||||||
KF5::Service
|
KF5::Service
|
||||||
SHARED_LIB
|
SHARED_LIB
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
#include <KPluginLoader> // Future
|
#include <KPluginLoader> // Future
|
||||||
|
|
||||||
#include <Plasma/PluginLoader> // TODO: port to KPluginLoader
|
#include <Plasma/PluginLoader> // TODO: port to KPluginLoader
|
||||||
|
#include <KPackage/Package>
|
||||||
|
#include <KPackage/PackageLoader>
|
||||||
|
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
@ -36,6 +38,20 @@
|
|||||||
namespace Calamares
|
namespace Calamares
|
||||||
{
|
{
|
||||||
|
|
||||||
|
QStringList themes_by_package()
|
||||||
|
{
|
||||||
|
QStringList packages;
|
||||||
|
|
||||||
|
QList<KPluginMetaData> pkgs = KPackage::PackageLoader::self()->listPackages("Plasma/LookAndFeel");
|
||||||
|
|
||||||
|
for (const KPluginMetaData &data : pkgs) {
|
||||||
|
packages << data.pluginId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return packages;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList themes_by_service()
|
QStringList themes_by_service()
|
||||||
{
|
{
|
||||||
KService::List services;
|
KService::List services;
|
||||||
@ -88,7 +104,7 @@ QStringList themes_by_lnftool()
|
|||||||
QStringList packages;
|
QStringList packages;
|
||||||
|
|
||||||
QProcess lnftool;
|
QProcess lnftool;
|
||||||
lnftool.start( "lookandfeeltool", {"--list"} );
|
lnftool.start( Calamares::lnftool(), {"--list"} );
|
||||||
if ( lnftool.waitForStarted(1000) && lnftool.waitForFinished( 1000 ) && (lnftool.exitCode() == 0) && (lnftool.exitStatus() == QProcess::NormalExit ) )
|
if ( lnftool.waitForStarted(1000) && lnftool.waitForFinished( 1000 ) && (lnftool.exitCode() == 0) && (lnftool.exitStatus() == QProcess::NormalExit ) )
|
||||||
{
|
{
|
||||||
packages = QString::fromLocal8Bit( lnftool.readAllStandardOutput() ).trimmed().split('\n');
|
packages = QString::fromLocal8Bit( lnftool.readAllStandardOutput() ).trimmed().split('\n');
|
||||||
@ -96,4 +112,17 @@ QStringList themes_by_lnftool()
|
|||||||
return packages;
|
return packages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList plasma_themes()
|
||||||
|
{
|
||||||
|
QStringList l( themes_by_package() );
|
||||||
|
if (l.isEmpty())
|
||||||
|
return themes_by_lnftool();
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString lnftool()
|
||||||
|
{
|
||||||
|
return "/home/adridg/bin/lookandfeeltool";
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Calamares
|
} // namespace Calamares
|
||||||
|
@ -23,11 +23,15 @@
|
|||||||
|
|
||||||
namespace Calamares
|
namespace Calamares
|
||||||
{
|
{
|
||||||
|
QString lnftool();
|
||||||
|
|
||||||
|
/* Internal */
|
||||||
|
QStringList themes_by_package();
|
||||||
QStringList themes_by_service();
|
QStringList themes_by_service();
|
||||||
QStringList themes_by_kcm();
|
QStringList themes_by_kcm();
|
||||||
QStringList themes_by_lnftool();
|
QStringList themes_by_lnftool();
|
||||||
|
|
||||||
|
QStringList plasma_themes();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // PLASMALNFINFO_H
|
#endif // PLASMALNFINFO_H
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include <QButtonGroup>
|
#include <QButtonGroup>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QProcess>
|
||||||
|
|
||||||
PlasmaLnfPage::PlasmaLnfPage(QWidget *parent)
|
PlasmaLnfPage::PlasmaLnfPage(QWidget *parent)
|
||||||
: QWidget( parent )
|
: QWidget( parent )
|
||||||
@ -45,7 +46,22 @@ PlasmaLnfPage::PlasmaLnfPage(QWidget *parent)
|
|||||||
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." ) );
|
||||||
)
|
)
|
||||||
|
|
||||||
Calamares::themes_by_service();
|
Calamares::themes_by_package();
|
||||||
ui->lnfCombo->addItems( Calamares::themes_by_lnftool() );
|
ui->lnfCombo->addItems( Calamares::plasma_themes() );
|
||||||
|
|
||||||
|
QObject::connect<void(QComboBox::*)(const QString&)>(ui->lnfCombo, &QComboBox::activated, this, &PlasmaLnfPage::activated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PlasmaLnfPage::activated(const QString& name)
|
||||||
|
{
|
||||||
|
cDebug() << "Changed to" << name;
|
||||||
|
|
||||||
|
QProcess lnftool;
|
||||||
|
lnftool.start( Calamares::lnftool(), {"--apply", name} );
|
||||||
|
|
||||||
|
if ( lnftool.waitForStarted(1000) && lnftool.waitForFinished( 1000 ) && (lnftool.exitCode() == 0) && (lnftool.exitStatus() == QProcess::NormalExit ) )
|
||||||
|
; // OK
|
||||||
|
else
|
||||||
|
cDebug() << "WARNING: could not apply look-and-feel" << name;
|
||||||
|
}
|
||||||
|
@ -33,6 +33,9 @@ class PlasmaLnfPage : public QWidget
|
|||||||
public:
|
public:
|
||||||
explicit PlasmaLnfPage( QWidget* parent = nullptr );
|
explicit PlasmaLnfPage( QWidget* parent = nullptr );
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void activated(const QString& name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::PlasmaLnfPage* ui;
|
Ui::PlasmaLnfPage* ui;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user