expose lookandfeelPackage
This commit is contained in:
parent
5e73293ec1
commit
8a5f3dc5a7
@ -2,16 +2,23 @@
|
||||
<node>
|
||||
<interface name="org.kde.PlatformStatus">
|
||||
<property name="shellPackage" type="s" access="read"/>
|
||||
<property name="lookAndFeelPackage" type="s" access="read"/>
|
||||
<property name="runtimePlatform" type="as" access="read"/>
|
||||
<signal name="shellPackageChanged">
|
||||
<arg name="package" type="s" direction="out"/>
|
||||
</signal>
|
||||
<signal name="lookAndFeelPackageChanged">
|
||||
<arg name="package" type="s" direction="out"/>
|
||||
</signal>
|
||||
<signal name="runtimePlatformChanged">
|
||||
<arg name="runtimePlatform" type="as" direction="out"/>
|
||||
</signal>
|
||||
<method name="shellPackage">
|
||||
<arg type="s" direction="out"/>
|
||||
</method>
|
||||
<method name="lookAndFeelPackage">
|
||||
<arg type="s" direction="out"/>
|
||||
</method>
|
||||
<method name="runtimePlatform">
|
||||
<arg type="as" direction="out"/>
|
||||
</method>
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "../plasma/config-plasma.h"
|
||||
|
||||
const char *defaultPackage = "org.kde.plasma.desktop";
|
||||
const char *defaultLnFPackage = "org.kde.breeze.desktop";
|
||||
|
||||
K_PLUGIN_FACTORY(PlatformStatusFactory, registerPlugin<PlatformStatus>();)
|
||||
|
||||
@ -24,9 +25,11 @@ PlatformStatus::PlatformStatus(QObject *parent, const QVariantList &)
|
||||
QDBusConnection::sessionBus().registerObject("/PlatformStatus", this);
|
||||
|
||||
findShellPackage(false);
|
||||
findLookAndFeelPackage(false);
|
||||
|
||||
const QString globalrcPath = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, "kdeglobals");
|
||||
connect(KDirWatch::self(), SIGNAL(dirty(QString)), this, SLOT(fileDirtied(QString)));
|
||||
connect(KDirWatch::self(), SIGNAL(created(QString)), this, SLOT(fileDirtied(QString)));
|
||||
KDirWatch::self()->addFile(globalrcPath);
|
||||
}
|
||||
|
||||
@ -64,11 +67,53 @@ void PlatformStatus::findShellPackage(bool sendSignal)
|
||||
}
|
||||
}
|
||||
|
||||
void PlatformStatus::findLookAndFeelPackage(bool sendSignal)
|
||||
{
|
||||
|
||||
KConfigGroup group(KSharedConfig::openConfig("kdeglobals"), "KDE");
|
||||
QString package = group.readEntry("LookAndFeelPackage", QString());
|
||||
|
||||
if (package.isEmpty()) {
|
||||
const QString shellPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
|
||||
PLASMA_RELATIVE_DATA_INSTALL_DIR "/shells/" + m_shellPackage + '/',
|
||||
QStandardPaths::LocateDirectory);
|
||||
KConfig packageDefaults(shellPath + "contents/defaults", KConfig::SimpleConfig);
|
||||
group = KConfigGroup(&packageDefaults, "Desktop");
|
||||
package = group.readEntry("LookAndFeel", defaultLnFPackage);
|
||||
|
||||
} else {
|
||||
const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
|
||||
PLASMA_RELATIVE_DATA_INSTALL_DIR "/look-and-feel/" + package + '/',
|
||||
QStandardPaths::LocateDirectory);
|
||||
if (path.isEmpty()) {
|
||||
if (package != defaultPackage) {
|
||||
group.deleteEntry(m_shellPackage);
|
||||
findLookAndFeelPackage(sendSignal);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const bool lnfChanged = (m_lookAndFeelPackage != package);
|
||||
m_lookAndFeelPackage = package;
|
||||
|
||||
if (sendSignal && lnfChanged) {
|
||||
emit lookAndFeelPackageChanged(m_lookAndFeelPackage);
|
||||
}
|
||||
}
|
||||
|
||||
QString PlatformStatus::shellPackage() const
|
||||
{
|
||||
return m_shellPackage;
|
||||
}
|
||||
|
||||
QString PlatformStatus::lookAndFeelPackage() const
|
||||
{
|
||||
return m_lookAndFeelPackage;
|
||||
}
|
||||
|
||||
QStringList PlatformStatus::runtimePlatform() const
|
||||
{
|
||||
return m_runtimePlatform;
|
||||
@ -78,6 +123,7 @@ void PlatformStatus::fileDirtied(const QString &path)
|
||||
{
|
||||
if (path.endsWith("kdeglobals")) {
|
||||
findShellPackage(true);
|
||||
findLookAndFeelPackage(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ class PlatformStatus : public KDEDModule
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "org.kde.PlatformStatus")
|
||||
Q_PROPERTY(QString shellPackage READ shellPackage NOTIFY shellPackageChanged)
|
||||
Q_PROPERTY(QString lookAndFeelPackage READ lookAndFeelPackage NOTIFY lookAndFeelPackageChanged)
|
||||
Q_PROPERTY(QStringList runtimePlatform READ runtimePlatform NOTIFY runtimePlatformChanged)
|
||||
|
||||
public:
|
||||
@ -17,20 +18,24 @@ public:
|
||||
|
||||
public Q_SLOTS:
|
||||
QString shellPackage() const;
|
||||
QString lookAndFeelPackage() const;
|
||||
QStringList runtimePlatform() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void shellPackageChanged(const QString &package);
|
||||
void lookAndFeelPackageChanged(const QString &package);
|
||||
void runtimePlatformChanged(const QStringList &runtimePlatform);
|
||||
|
||||
private:
|
||||
void findShellPackage(bool sendSignal);
|
||||
void findLookAndFeelPackage(bool sendSignal);
|
||||
|
||||
private Q_SLOTS:
|
||||
void fileDirtied(const QString &path);
|
||||
|
||||
private:
|
||||
QString m_shellPackage;
|
||||
QString m_lookAndFeelPackage;
|
||||
QStringList m_runtimePlatform;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user