first draft of the platform status kded module
This commit is contained in:
parent
4c21d54980
commit
dad03a43ce
@ -2,5 +2,6 @@ add_subdirectory(plasma)
|
||||
add_subdirectory(declarativeimports)
|
||||
#add_subdirectory(kpart)
|
||||
add_subdirectory(plasmapkg)
|
||||
add_subdirectory(platformstatus)
|
||||
add_subdirectory(scriptengines)
|
||||
add_subdirectory(shell)
|
||||
|
10
src/platformstatus/CMakeLists.txt
Normal file
10
src/platformstatus/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
||||
set(kded_platformstatus_SRCS platformstatus.cpp )
|
||||
|
||||
kde4_add_plugin(kded_platformstatus ${kded_platformstatus_SRCS})
|
||||
|
||||
target_link_libraries(kded_platformstatus ${KDE4_KDECORE_LIBS} ${KCoreAddons_LIBRARIES} Qt5::DBus)
|
||||
|
||||
install(TARGETS kded_platformstatus DESTINATION ${PLUGIN_INSTALL_DIR} )
|
||||
install( FILES kded-platformstatus.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kded )
|
||||
install( FILES org.kde.platformstatus.xml DESTINATION ${DBUS_INTERFACES_INSTALL_DIR} )
|
||||
|
9
src/platformstatus/kded-platformstatus.desktop
Normal file
9
src/platformstatus/kded-platformstatus.desktop
Normal file
@ -0,0 +1,9 @@
|
||||
[Desktop Entry]
|
||||
Type=Service
|
||||
X-KDE-ServiceTypes=KDEDModule
|
||||
X-KDE-Library=kded_platformstatus
|
||||
X-KDE-DBus-ModuleName=plaformstatus
|
||||
X-KDE-Kded-autoload=true
|
||||
X-KDE-Kded-load-on-demand=false
|
||||
Name=Platform Status
|
||||
Comment=Tracks the current shell package and the platform definition strings.
|
19
src/platformstatus/org.kde.platformstatus.xml
Normal file
19
src/platformstatus/org.kde.platformstatus.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
||||
<node>
|
||||
<interface name="org.kde.PlatformStatus">
|
||||
<property name="shellPackage" type="s" access="read"/>
|
||||
<property name="runtimePlatform" type="as" access="read"/>
|
||||
<signal name="shellPackageChanged">
|
||||
<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="runtimePlatform">
|
||||
<arg type="as" direction="out"/>
|
||||
</method>
|
||||
</interface>
|
||||
</node>
|
76
src/platformstatus/platformstatus.cpp
Normal file
76
src/platformstatus/platformstatus.cpp
Normal file
@ -0,0 +1,76 @@
|
||||
#include <platformstatus.h>
|
||||
|
||||
#include <QDBusConnection>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include <KConfigGroup>
|
||||
#include <KDirWatch>
|
||||
#include <KPluginFactory>
|
||||
|
||||
const char *defaultPackage = "org.kde.desktop";
|
||||
|
||||
K_PLUGIN_FACTORY(PlatformStatusFactory, registerPlugin<PlatformStatus>();)
|
||||
K_EXPORT_PLUGIN(PlatformStatusFactory("platformstatus"))
|
||||
|
||||
PlatformStatus::PlatformStatus(QObject *parent, const QVariantList &)
|
||||
: KDEDModule(parent)
|
||||
{
|
||||
QDBusConnection::sessionBus().registerObject("/PlatformStatus", this,
|
||||
QDBusConnection::ExportAllProperties |
|
||||
QDBusConnection::ExportAllSignals);
|
||||
findShellPackage(false);
|
||||
const QString globalrcPath = QStandardPaths::locate(QStandardPaths::ConfigLocation, "kdeglobals");
|
||||
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);
|
||||
|
||||
const QString path = QStandardPaths::locate(QStandardPaths::DataLocation, "plasma/shells/" + package + "/");
|
||||
if (path.isEmpty()) {
|
||||
if (package != defaultPackage) {
|
||||
group.deleteEntry("ShellPackage");
|
||||
findShellPackage(sendSignal);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
m_shellPackage = package;
|
||||
|
||||
QString runtimePlatform = group.readEntry("runtimePlatform", QString());
|
||||
KConfig packageDefaults(path + "contents/defaults", KConfig::SimpleConfig);
|
||||
group = KConfigGroup(&packageDefaults, "DesktopShell");
|
||||
runtimePlatform = group.readEntry("runtimePlatform", runtimePlatform);
|
||||
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"
|
38
src/platformstatus/platformstatus.h
Normal file
38
src/platformstatus/platformstatus.h
Normal file
@ -0,0 +1,38 @@
|
||||
#ifndef PLATFORMSTATUS_H
|
||||
#define PLATFORMSTATUS_H
|
||||
|
||||
#include <KDEDModule>
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
class PlatformStatus : public KDEDModule
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "org.kde.PlatformStatus")
|
||||
Q_PROPERTY(QString shellPackage READ shellPackage NOTIFY shellPackageChanged)
|
||||
Q_PROPERTY(QStringList runtimePlatform READ runtimePlatform NOTIFY runtimePlatformChanged)
|
||||
|
||||
public:
|
||||
PlatformStatus(QObject *parent, const QVariantList &);
|
||||
|
||||
public Q_SLOTS:
|
||||
QString shellPackage() const;
|
||||
QStringList runtimePlatform() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void shellPackageChanged(const QString &package);
|
||||
void runtimePlatformChanged(const QStringList &runtimePlatform);
|
||||
|
||||
private:
|
||||
void findShellPackage(bool sendSignal);
|
||||
|
||||
private Q_SLOTS:
|
||||
void fileDirtied(const QString &path);
|
||||
|
||||
private:
|
||||
QString m_shellPackage;
|
||||
QStringList m_runtimePlatform;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user