2013-04-21 18:04:29 +02:00
|
|
|
#include <platformstatus.h>
|
|
|
|
|
|
|
|
#include <QDBusConnection>
|
|
|
|
#include <QStandardPaths>
|
|
|
|
|
2013-10-05 02:32:44 +02:00
|
|
|
#include <kconfiggroup.h>
|
2014-03-29 08:22:28 +01:00
|
|
|
#include <ksharedconfig.h>
|
2013-08-09 04:14:26 +02:00
|
|
|
#include <QDebug>
|
2013-10-05 02:32:44 +02:00
|
|
|
#include <kdirwatch.h>
|
|
|
|
#include <kpluginfactory.h>
|
2013-10-05 12:49:18 +02:00
|
|
|
#include <qstandardpaths.h>
|
2013-04-21 18:04:29 +02:00
|
|
|
|
2013-06-24 08:59:13 +02:00
|
|
|
#include "platformstatusadaptor.h"
|
|
|
|
|
2013-04-21 18:04:29 +02:00
|
|
|
const char *defaultPackage = "org.kde.desktop";
|
|
|
|
|
|
|
|
K_PLUGIN_FACTORY(PlatformStatusFactory, registerPlugin<PlatformStatus>();)
|
|
|
|
|
|
|
|
PlatformStatus::PlatformStatus(QObject *parent, const QVariantList &)
|
|
|
|
: KDEDModule(parent)
|
|
|
|
{
|
2013-06-24 08:59:13 +02:00
|
|
|
new PlatformStatusAdaptor(this);
|
|
|
|
QDBusConnection::sessionBus().registerObject("/PlatformStatus", this);
|
|
|
|
|
2013-04-21 18:04:29 +02:00
|
|
|
findShellPackage(false);
|
2013-06-24 08:59:13 +02:00
|
|
|
|
2013-12-08 13:30:40 +01:00
|
|
|
const QString globalrcPath = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, "kdeglobals");
|
2013-04-21 18:04:29 +02:00
|
|
|
connect(KDirWatch::self(), SIGNAL(dirty(QString)), this, SLOT(fileDirtied(QString)));
|
|
|
|
KDirWatch::self()->addFile(globalrcPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlatformStatus::findShellPackage(bool sendSignal)
|
|
|
|
{
|
|
|
|
KConfigGroup group(KSharedConfig::openConfig("kdeglobals"), "DesktopShell");
|
|
|
|
const QString package = group.readEntry("shellPackage", defaultPackage);
|
|
|
|
|
2013-04-21 18:36:00 +02:00
|
|
|
const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
|
|
|
|
"plasma/shells/" + package + '/',
|
|
|
|
QStandardPaths::LocateDirectory);
|
2013-04-21 18:04:29 +02:00
|
|
|
if (path.isEmpty()) {
|
|
|
|
if (package != defaultPackage) {
|
|
|
|
group.deleteEntry("ShellPackage");
|
|
|
|
findShellPackage(sendSignal);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_shellPackage = package;
|
|
|
|
|
2013-04-21 18:36:00 +02:00
|
|
|
QString runtimePlatform = group.readEntry("RuntimePlatform", QString());
|
2013-04-21 18:04:29 +02:00
|
|
|
KConfig packageDefaults(path + "contents/defaults", KConfig::SimpleConfig);
|
2013-04-21 18:36:00 +02:00
|
|
|
group = KConfigGroup(&packageDefaults, "Desktop");
|
|
|
|
runtimePlatform = group.readEntry("RuntimePlatform", runtimePlatform);
|
2013-04-21 18:04:29 +02:00
|
|
|
const bool runtimeChanged = runtimePlatform != m_runtimePlatform.join(',');
|
|
|
|
if (runtimeChanged) {
|
|
|
|
m_runtimePlatform = runtimePlatform.split(',');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sendSignal) {
|
|
|
|
emit shellPackageChanged(m_shellPackage);
|
|
|
|
emit runtimePlatformChanged(m_runtimePlatform);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QString PlatformStatus::shellPackage() const
|
|
|
|
{
|
|
|
|
return m_shellPackage;
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList PlatformStatus::runtimePlatform() const
|
|
|
|
{
|
|
|
|
return m_runtimePlatform;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlatformStatus::fileDirtied(const QString &path)
|
|
|
|
{
|
|
|
|
if (path.endsWith("kdeglobals")) {
|
|
|
|
findShellPackage(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "platformstatus.moc"
|