diff --git a/src/plasma/containment.cpp b/src/plasma/containment.cpp index 2085e9c0d..2cd7890d2 100644 --- a/src/plasma/containment.cpp +++ b/src/plasma/containment.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -103,7 +104,20 @@ void Containment::init() } if (d->type == NoContainmentType) { - setContainmentType(DesktopContainment); + //setContainmentType(Plasma::DesktopContainment); + //Try to determine the containment type. It must be done as soon as possible + QString type = pluginInfo().property("X-Plasma-ContainmentType").toString(); + + if (type == "Panel") { + setContainmentType(Plasma::PanelContainment); + } else if (type == "Custom") { + setContainmentType(Plasma::CustomContainment); + } else if (type == "CustomPanel") { + setContainmentType(Plasma::CustomPanelContainment); + //default to desktop + } else { + setContainmentType(Plasma::DesktopContainment); + } } //connect actions diff --git a/src/plasma/data/servicetypes/plasma-containment.desktop b/src/plasma/data/servicetypes/plasma-containment.desktop index 9336d99d4..a0930c273 100644 --- a/src/plasma/data/servicetypes/plasma-containment.desktop +++ b/src/plasma/data/servicetypes/plasma-containment.desktop @@ -13,8 +13,5 @@ Comment[sv]=Plasmaminiprogram-omgivning och bakgrundsuppritning Comment[uk]=Контейнер аплетів Плазми і малювання у тлі Comment[x-test]=xxPlasma applet container and background painterxx -[PropertyDef::X-Plasma-ContainmentCategories] -Type=QStringList - [PropertyDef::X-Plasma-ContainmentType] Type=QString diff --git a/src/scriptengines/qml/plasmoid/declarativeappletscript.cpp b/src/scriptengines/qml/plasmoid/declarativeappletscript.cpp index b0f107d62..fc3dcbec7 100644 --- a/src/scriptengines/qml/plasmoid/declarativeappletscript.cpp +++ b/src/scriptengines/qml/plasmoid/declarativeappletscript.cpp @@ -82,18 +82,6 @@ bool DeclarativeAppletScript::init() if (pc) { m_interface = new ContainmentInterface(this); - //Try to determine the containment type - QString type = pc->pluginInfo().property("X-Plasma-ContainmentType").toString(); - - if (type == "DesktopContainment") { - pc->setContainmentType(Plasma::DesktopContainment); - } else if (type == "PanelContainment") { - pc->setContainmentType(Plasma::PanelContainment); - } if (type == "CustomContainment") { - pc->setContainmentType(Plasma::CustomContainment); - } else if (type == "CustomPanelContainment") { - pc->setContainmentType(Plasma::CustomPanelContainment); - } //fail? so it's a normal Applet } else { m_interface = new AppletInterface(this); diff --git a/src/shell/containments/CMakeLists.txt b/src/shell/containments/CMakeLists.txt index 03da6caa7..3572355fa 100644 --- a/src/shell/containments/CMakeLists.txt +++ b/src/shell/containments/CMakeLists.txt @@ -1,3 +1,3 @@ installPackage(testcontainment org.kde.testcontainment) -installPackage(testpanel org.kde.testpanel) +installPackage(testpanel org.kde.panel) diff --git a/src/shell/containments/testpanel/metadata.desktop b/src/shell/containments/testpanel/metadata.desktop index 3f9fd3db3..aff9e248c 100644 --- a/src/shell/containments/testpanel/metadata.desktop +++ b/src/shell/containments/testpanel/metadata.desktop @@ -19,8 +19,8 @@ X-KDE-PluginInfo-Author=Marco Martin X-KDE-PluginInfo-Category= X-KDE-PluginInfo-Email=mart@kde.org X-KDE-PluginInfo-License=GPLv2+ -X-KDE-PluginInfo-Name=org.kde.testpanel +X-KDE-PluginInfo-Name=org.kde.panel X-KDE-PluginInfo-Version= X-KDE-PluginInfo-Website= X-Plasma-MainScript=ui/main.qml -X-Plasma-ContainmentType=PanelContainment +X-Plasma-ContainmentType=Panel diff --git a/src/shell/desktopcorona.cpp b/src/shell/desktopcorona.cpp index 755319c1d..0e5df678c 100644 --- a/src/shell/desktopcorona.cpp +++ b/src/shell/desktopcorona.cpp @@ -57,20 +57,12 @@ DesktopCorona::~DesktopCorona() void DesktopCorona::loadDefaultLayout() { - //TODO: use Javascript here - /*Plasma::Containment *cont = createContainment("org.kde.testcontainment"); - cont->setScreen(0); - qDebug() << containmentForScreen(0); - Plasma::Applet *appl = cont->createApplet("org.kde.testapplet"); - qDebug() << "Containment:" << cont << cont->title(); - qDebug() << "Applet:" << appl->title() << appl;*/ - - WorkspaceScripting::DesktopScriptEngine scriptEngine(this, true); connect(&scriptEngine, SIGNAL(printError(QString)), this, SLOT(printScriptError(QString))); connect(&scriptEngine, SIGNAL(print(QString)), this, SLOT(printScriptMessage(QString))); QString script = package().filePath("defaultlayout"); + QFile file(script); if (file.open(QIODevice::ReadOnly | QIODevice::Text) ) { QString code = file.readAll(); @@ -224,7 +216,7 @@ void DesktopCorona::checkViews() void DesktopCorona::updateScreenOwner(int wasScreen, int isScreen, Plasma::Containment *containment) { - qDebug() << "Was screen" << wasScreen << "Is screen" << isScreen <<"Containment" << containment; + qDebug() << "Was screen" << wasScreen << "Is screen" << isScreen <<"Containment" << containment << containment->title(); if (containment->formFactor() == Plasma::Horizontal || containment->formFactor() == Plasma::Vertical) { diff --git a/src/shell/scripting/panel.cpp b/src/shell/scripting/panel.cpp index fed709855..59182ce78 100644 --- a/src/shell/scripting/panel.cpp +++ b/src/shell/scripting/panel.cpp @@ -87,21 +87,27 @@ void Panel::setLocation(const QString &locationString) const QString lower = locationString.toLower(); Plasma::Location loc = Plasma::Floating; + Plasma::FormFactor ff = Plasma::Planar; if (lower == "desktop") { loc = Plasma::Desktop; } else if (lower == "fullscreen") { loc = Plasma::FullScreen; } else if (lower == "top") { loc = Plasma::TopEdge; + ff = Plasma::Horizontal; } else if (lower == "bottom") { loc = Plasma::BottomEdge; + ff = Plasma::Horizontal; } else if (lower == "left") { loc = Plasma::LeftEdge; + ff = Plasma::Vertical; } else if (lower == "right") { loc = Plasma::RightEdge; + ff = Plasma::Vertical; } c->setLocation(loc); + c->setFormFactor(ff); } PanelView *Panel::panel() const diff --git a/src/shell/scripting/scriptengine.cpp b/src/shell/scripting/scriptengine.cpp index d6479054b..849ec7c7d 100644 --- a/src/shell/scripting/scriptengine.cpp +++ b/src/shell/scripting/scriptengine.cpp @@ -107,12 +107,13 @@ QScriptValue ScriptEngine::activityForScreen(QScriptContext *context, QScriptEng QScriptValue ScriptEngine::newActivity(QScriptContext *context, QScriptEngine *engine) { - return createContainment("desktop", "desktop", context, engine); + //FIXME: will be org.kde.desktop + return createContainment("Desktop", "org.kde.testcontainment", context, engine); } QScriptValue ScriptEngine::newPanel(QScriptContext *context, QScriptEngine *engine) { - return createContainment("panel", "panel", context, engine); + return createContainment("Panel", "org.kde.panel", context, engine); } QScriptValue ScriptEngine::createContainment(const QString &type, const QString &defaultPlugin, @@ -138,14 +139,14 @@ QScriptValue ScriptEngine::createContainment(const QString &type, const QString ScriptEngine *env = envFor(engine); Plasma::Containment *c = env->m_corona->createContainment(plugin); if (c) { - if (type == "panel") { + if (type == "Panel") { // some defaults - c->setScreen(env->defaultPanelScreen()); + c->setFormFactor(Plasma::Horizontal); c->setLocation(Plasma::TopEdge); + c->setScreen(env->defaultPanelScreen()); } c->updateConstraints(Plasma::AllConstraints | Plasma::StartupCompletedConstraint); c->flushPendingConstraintsEvents(); - emit env->createPendingPanelViews(); } return env->wrap(c); @@ -574,7 +575,7 @@ void ScriptEngine::setupEngine() m_scriptSelf.setProperty("QRectF", constructQRectFClass(this)); m_scriptSelf.setProperty("Activity", newFunction(ScriptEngine::newActivity)); - m_scriptSelf.setProperty("Panel", newFunction(ScriptEngine::newPanel)); + m_scriptSelf.setProperty("Panel", newFunction(ScriptEngine::newPanel, newObject())); m_scriptSelf.setProperty("activities", newFunction(ScriptEngine::activities)); m_scriptSelf.setProperty("activityById", newFunction(ScriptEngine::activityById)); m_scriptSelf.setProperty("activityForScreen", newFunction(ScriptEngine::activityForScreen)); diff --git a/src/shell/scripting/scriptengine.h b/src/shell/scripting/scriptengine.h index af93e80ce..761706d1b 100644 --- a/src/shell/scripting/scriptengine.h +++ b/src/shell/scripting/scriptengine.h @@ -59,7 +59,6 @@ public: Q_SIGNALS: void print(const QString &string); void printError(const QString &string); - void createPendingPanelViews(); private: void setupEngine(); diff --git a/src/shell/shellpackage.cpp b/src/shell/shellpackage.cpp index 7703e1b7e..e06778167 100644 --- a/src/shell/shellpackage.cpp +++ b/src/shell/shellpackage.cpp @@ -36,10 +36,10 @@ void ShellPackageStructure::initPackage(Plasma::Package *package) package->setMimeTypes("views", QStringList() << "text/x-qml"); //Files - package->addFileDefinition("layout", "layout.js", i18n("Default layout file")); + package->addFileDefinition("defaultlayout", "layout.js", i18n("Default layout file")); package->addFileDefinition("defaults", "defaults", i18n("Default plugins for containments, containmentActions etc")); - package->setMimeTypes("layout", QStringList() << "application/javascript"); + package->setMimeTypes("defaultlayout", QStringList() << "application/javascript"); package->setMimeTypes("defaults", QStringList() << "text/plain"); package->addFileDefinition("appleterror", "components/AppletError.qml", i18n("Error message shown when an applet fails loading"));