make the desktop scripting finally work
completely migrate to X-Plasma-ContainmentType from the desktop file, use it to set the containment type as soon as possible (in Containment::init()) in this way the desktop script can recognize panels as what they are immediately
This commit is contained in:
parent
0830c5047b
commit
af6e538fa4
@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
|
#include <QDebug>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QContextMenuEvent>
|
#include <QContextMenuEvent>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
@ -103,7 +104,20 @@ void Containment::init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (d->type == NoContainmentType) {
|
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
|
//connect actions
|
||||||
|
@ -13,8 +13,5 @@ Comment[sv]=Plasmaminiprogram-omgivning och bakgrundsuppritning
|
|||||||
Comment[uk]=Контейнер аплетів Плазми і малювання у тлі
|
Comment[uk]=Контейнер аплетів Плазми і малювання у тлі
|
||||||
Comment[x-test]=xxPlasma applet container and background painterxx
|
Comment[x-test]=xxPlasma applet container and background painterxx
|
||||||
|
|
||||||
[PropertyDef::X-Plasma-ContainmentCategories]
|
|
||||||
Type=QStringList
|
|
||||||
|
|
||||||
[PropertyDef::X-Plasma-ContainmentType]
|
[PropertyDef::X-Plasma-ContainmentType]
|
||||||
Type=QString
|
Type=QString
|
||||||
|
@ -82,18 +82,6 @@ bool DeclarativeAppletScript::init()
|
|||||||
if (pc) {
|
if (pc) {
|
||||||
m_interface = new ContainmentInterface(this);
|
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
|
//fail? so it's a normal Applet
|
||||||
} else {
|
} else {
|
||||||
m_interface = new AppletInterface(this);
|
m_interface = new AppletInterface(this);
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
|
|
||||||
installPackage(testcontainment org.kde.testcontainment)
|
installPackage(testcontainment org.kde.testcontainment)
|
||||||
installPackage(testpanel org.kde.testpanel)
|
installPackage(testpanel org.kde.panel)
|
||||||
|
@ -19,8 +19,8 @@ X-KDE-PluginInfo-Author=Marco Martin
|
|||||||
X-KDE-PluginInfo-Category=
|
X-KDE-PluginInfo-Category=
|
||||||
X-KDE-PluginInfo-Email=mart@kde.org
|
X-KDE-PluginInfo-Email=mart@kde.org
|
||||||
X-KDE-PluginInfo-License=GPLv2+
|
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-Version=
|
||||||
X-KDE-PluginInfo-Website=
|
X-KDE-PluginInfo-Website=
|
||||||
X-Plasma-MainScript=ui/main.qml
|
X-Plasma-MainScript=ui/main.qml
|
||||||
X-Plasma-ContainmentType=PanelContainment
|
X-Plasma-ContainmentType=Panel
|
||||||
|
@ -57,20 +57,12 @@ DesktopCorona::~DesktopCorona()
|
|||||||
|
|
||||||
void DesktopCorona::loadDefaultLayout()
|
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);
|
WorkspaceScripting::DesktopScriptEngine scriptEngine(this, true);
|
||||||
connect(&scriptEngine, SIGNAL(printError(QString)), this, SLOT(printScriptError(QString)));
|
connect(&scriptEngine, SIGNAL(printError(QString)), this, SLOT(printScriptError(QString)));
|
||||||
connect(&scriptEngine, SIGNAL(print(QString)), this, SLOT(printScriptMessage(QString)));
|
connect(&scriptEngine, SIGNAL(print(QString)), this, SLOT(printScriptMessage(QString)));
|
||||||
|
|
||||||
QString script = package().filePath("defaultlayout");
|
QString script = package().filePath("defaultlayout");
|
||||||
|
|
||||||
QFile file(script);
|
QFile file(script);
|
||||||
if (file.open(QIODevice::ReadOnly | QIODevice::Text) ) {
|
if (file.open(QIODevice::ReadOnly | QIODevice::Text) ) {
|
||||||
QString code = file.readAll();
|
QString code = file.readAll();
|
||||||
@ -224,7 +216,7 @@ void DesktopCorona::checkViews()
|
|||||||
|
|
||||||
void DesktopCorona::updateScreenOwner(int wasScreen, int isScreen, Plasma::Containment *containment)
|
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 ||
|
if (containment->formFactor() == Plasma::Horizontal ||
|
||||||
containment->formFactor() == Plasma::Vertical) {
|
containment->formFactor() == Plasma::Vertical) {
|
||||||
|
@ -87,21 +87,27 @@ void Panel::setLocation(const QString &locationString)
|
|||||||
|
|
||||||
const QString lower = locationString.toLower();
|
const QString lower = locationString.toLower();
|
||||||
Plasma::Location loc = Plasma::Floating;
|
Plasma::Location loc = Plasma::Floating;
|
||||||
|
Plasma::FormFactor ff = Plasma::Planar;
|
||||||
if (lower == "desktop") {
|
if (lower == "desktop") {
|
||||||
loc = Plasma::Desktop;
|
loc = Plasma::Desktop;
|
||||||
} else if (lower == "fullscreen") {
|
} else if (lower == "fullscreen") {
|
||||||
loc = Plasma::FullScreen;
|
loc = Plasma::FullScreen;
|
||||||
} else if (lower == "top") {
|
} else if (lower == "top") {
|
||||||
loc = Plasma::TopEdge;
|
loc = Plasma::TopEdge;
|
||||||
|
ff = Plasma::Horizontal;
|
||||||
} else if (lower == "bottom") {
|
} else if (lower == "bottom") {
|
||||||
loc = Plasma::BottomEdge;
|
loc = Plasma::BottomEdge;
|
||||||
|
ff = Plasma::Horizontal;
|
||||||
} else if (lower == "left") {
|
} else if (lower == "left") {
|
||||||
loc = Plasma::LeftEdge;
|
loc = Plasma::LeftEdge;
|
||||||
|
ff = Plasma::Vertical;
|
||||||
} else if (lower == "right") {
|
} else if (lower == "right") {
|
||||||
loc = Plasma::RightEdge;
|
loc = Plasma::RightEdge;
|
||||||
|
ff = Plasma::Vertical;
|
||||||
}
|
}
|
||||||
|
|
||||||
c->setLocation(loc);
|
c->setLocation(loc);
|
||||||
|
c->setFormFactor(ff);
|
||||||
}
|
}
|
||||||
|
|
||||||
PanelView *Panel::panel() const
|
PanelView *Panel::panel() const
|
||||||
|
@ -107,12 +107,13 @@ QScriptValue ScriptEngine::activityForScreen(QScriptContext *context, QScriptEng
|
|||||||
|
|
||||||
QScriptValue ScriptEngine::newActivity(QScriptContext *context, QScriptEngine *engine)
|
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)
|
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,
|
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);
|
ScriptEngine *env = envFor(engine);
|
||||||
Plasma::Containment *c = env->m_corona->createContainment(plugin);
|
Plasma::Containment *c = env->m_corona->createContainment(plugin);
|
||||||
if (c) {
|
if (c) {
|
||||||
if (type == "panel") {
|
if (type == "Panel") {
|
||||||
// some defaults
|
// some defaults
|
||||||
c->setScreen(env->defaultPanelScreen());
|
c->setFormFactor(Plasma::Horizontal);
|
||||||
c->setLocation(Plasma::TopEdge);
|
c->setLocation(Plasma::TopEdge);
|
||||||
|
c->setScreen(env->defaultPanelScreen());
|
||||||
}
|
}
|
||||||
c->updateConstraints(Plasma::AllConstraints | Plasma::StartupCompletedConstraint);
|
c->updateConstraints(Plasma::AllConstraints | Plasma::StartupCompletedConstraint);
|
||||||
c->flushPendingConstraintsEvents();
|
c->flushPendingConstraintsEvents();
|
||||||
emit env->createPendingPanelViews();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return env->wrap(c);
|
return env->wrap(c);
|
||||||
@ -574,7 +575,7 @@ void ScriptEngine::setupEngine()
|
|||||||
|
|
||||||
m_scriptSelf.setProperty("QRectF", constructQRectFClass(this));
|
m_scriptSelf.setProperty("QRectF", constructQRectFClass(this));
|
||||||
m_scriptSelf.setProperty("Activity", newFunction(ScriptEngine::newActivity));
|
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("activities", newFunction(ScriptEngine::activities));
|
||||||
m_scriptSelf.setProperty("activityById", newFunction(ScriptEngine::activityById));
|
m_scriptSelf.setProperty("activityById", newFunction(ScriptEngine::activityById));
|
||||||
m_scriptSelf.setProperty("activityForScreen", newFunction(ScriptEngine::activityForScreen));
|
m_scriptSelf.setProperty("activityForScreen", newFunction(ScriptEngine::activityForScreen));
|
||||||
|
@ -59,7 +59,6 @@ public:
|
|||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void print(const QString &string);
|
void print(const QString &string);
|
||||||
void printError(const QString &string);
|
void printError(const QString &string);
|
||||||
void createPendingPanelViews();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupEngine();
|
void setupEngine();
|
||||||
|
@ -36,10 +36,10 @@ void ShellPackageStructure::initPackage(Plasma::Package *package)
|
|||||||
package->setMimeTypes("views", QStringList() << "text/x-qml");
|
package->setMimeTypes("views", QStringList() << "text/x-qml");
|
||||||
|
|
||||||
//Files
|
//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->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->setMimeTypes("defaults", QStringList() << "text/plain");
|
||||||
|
|
||||||
package->addFileDefinition("appleterror", "components/AppletError.qml", i18n("Error message shown when an applet fails loading"));
|
package->addFileDefinition("appleterror", "components/AppletError.qml", i18n("Error message shown when an applet fails loading"));
|
||||||
|
Loading…
Reference in New Issue
Block a user