diff --git a/clients/aurorae/src/CMakeLists.txt b/clients/aurorae/src/CMakeLists.txt
index 71be39a9f7..6d2f9de9ad 100644
--- a/clients/aurorae/src/CMakeLists.txt
+++ b/clients/aurorae/src/CMakeLists.txt
@@ -26,3 +26,4 @@ install( FILES
qml/DecorationButton.qml
qml/MenuButton.qml
DESTINATION ${DATA_INSTALL_DIR}/kwin/aurorae )
+install( FILES kwindecoration.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR} )
diff --git a/clients/aurorae/src/aurorae.cpp b/clients/aurorae/src/aurorae.cpp
index 4277b65bef..57e4af6b9b 100644
--- a/clients/aurorae/src/aurorae.cpp
+++ b/clients/aurorae/src/aurorae.cpp
@@ -17,6 +17,7 @@ along with this program. If not, see .
#include "aurorae.h"
#include "auroraetheme.h"
+#include "config-kwin.h"
#include
#include
@@ -27,6 +28,9 @@ along with this program. If not, see .
#include
#include
+#include
+#include
+#include
#include
#include
@@ -39,6 +43,7 @@ AuroraeFactory::AuroraeFactory()
, m_theme(new AuroraeTheme(this))
, m_engine(new QDeclarativeEngine(this))
, m_component(new QDeclarativeComponent(m_engine, this))
+ , m_engineType(AuroraeEngine)
{
init();
}
@@ -49,7 +54,23 @@ void AuroraeFactory::init()
KConfig conf("auroraerc");
KConfigGroup group(&conf, "Engine");
+ if (group.hasKey("EngineType")) {
+ const QString engineType = group.readEntry("EngineType", "aurorae").toLower();
+ if (engineType == "qml") {
+ initQML(group);
+ } else {
+ // fallback to classic Aurorae Themes
+ initAurorae(conf, group);
+ }
+ } else {
+ // fallback to classic Aurorae Themes
+ initAurorae(conf, group);
+ }
+}
+void AuroraeFactory::initAurorae(KConfig &conf, KConfigGroup &group)
+{
+ m_engineType = AuroraeEngine;
const QString themeName = group.readEntry("ThemeName", "example-deco");
KConfig config("aurorae/themes/" + themeName + '/' + themeName + "rc", KConfig::FullConfig, "data");
KConfigGroup themeGroup(&conf, themeName);
@@ -66,6 +87,41 @@ void AuroraeFactory::init()
m_engine->rootContext()->setContextProperty("options", this);
}
+void AuroraeFactory::initQML(const KConfigGroup &group)
+{
+ // try finding the QML package
+ const QString themeName = group.readEntry("ThemeName");
+ kDebug(1212) << "Trying to load QML Decoration " << themeName;
+ const QString internalname = themeName.toLower();
+
+ QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(internalname);
+ KService::List offers = KServiceTypeTrader::self()->query("KWin/Decoration", constraint);
+ if (offers.isEmpty()) {
+ kError(1212) << "Couldn't find QML Decoration " << themeName << endl;
+ // TODO: what to do in error case?
+ return;
+ }
+ KService::Ptr service = offers.first();
+ KPluginInfo plugininfo(service);
+ const QString pluginName = service->property("X-KDE-PluginInfo-Name").toString();
+ const QString scriptName = service->property("X-Plasma-MainScript").toString();
+ const QString file = KStandardDirs::locate("data", QLatin1String(KWIN_NAME) + "/decorations/" + pluginName + "/contents/" + scriptName);
+ if (file.isNull()) {
+ kDebug(1212) << "Could not find script file for " << pluginName;
+ // TODO: what to do in error case?
+ return;
+ }
+ m_engineType = QMLEngine;
+ // setup the QML engine
+ foreach (const QString &importPath, KGlobal::dirs()->findDirs("module", "imports")) {
+ m_engine->addImportPath(importPath);
+ }
+ foreach (const QString &importPath, KGlobal::dirs()->findDirs("data", QLatin1String(KWIN_NAME) + "/aurorae/")) {
+ m_engine->addImportPath(importPath);
+ }
+ m_component->loadUrl(QUrl::fromLocalFile(file));
+}
+
AuroraeFactory::~AuroraeFactory()
{
s_instance = NULL;
@@ -88,6 +144,7 @@ bool AuroraeFactory::reset(unsigned long changed)
if (changed & SettingFont){
emit titleFontChanged();
}
+ // TODO: adjust reset behavior
const KConfig conf("auroraerc");
const KConfigGroup group(&conf, "Engine");
const QString themeName = group.readEntry("ThemeName", "example-deco");
diff --git a/clients/aurorae/src/aurorae.h b/clients/aurorae/src/aurorae.h
index fabd828ff3..48bc347d9d 100644
--- a/clients/aurorae/src/aurorae.h
+++ b/clients/aurorae/src/aurorae.h
@@ -29,6 +29,8 @@ class QDeclarativeItem;
class QGraphicsSceneMouseEvent;
class QGraphicsScene;
class QGraphicsView;
+class KConfig;
+class KConfigGroup;
namespace Aurorae
{
@@ -64,8 +66,14 @@ public:
QFont inactiveTitleFont();
private:
+ enum EngineType {
+ AuroraeEngine,
+ QMLEngine
+ };
AuroraeFactory();
void init();
+ void initAurorae(KConfig &conf, KConfigGroup &group);
+ void initQML(const KConfigGroup& group);
Q_SIGNALS:
void buttonsChanged();
@@ -77,6 +85,7 @@ private:
AuroraeTheme *m_theme;
QDeclarativeEngine *m_engine;
QDeclarativeComponent *m_component;
+ EngineType m_engineType;
};
class AuroraeClient : public KDecorationUnstable
diff --git a/clients/aurorae/src/kwindecoration.desktop b/clients/aurorae/src/kwindecoration.desktop
new file mode 100644
index 0000000000..bbb23aa1d3
--- /dev/null
+++ b/clients/aurorae/src/kwindecoration.desktop
@@ -0,0 +1,8 @@
+[Desktop Entry]
+Type=ServiceType
+X-KDE-ServiceType=KWin/Decoration
+
+Comment=KWin Window Decoration
+
+[PropertyDef::X-Plasma-MainScript]
+Type=QString