enable build of desktop scripting
it still doesn't do anything and needs porting away from deprecated classes
This commit is contained in:
parent
0af1a25b5e
commit
dcd9954815
@ -19,6 +19,7 @@ add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
|
|||||||
find_package(Qt5Transitional REQUIRED Core)
|
find_package(Qt5Transitional REQUIRED Core)
|
||||||
find_package(Qt5Qml REQUIRED)
|
find_package(Qt5Qml REQUIRED)
|
||||||
find_package(Qt5Quick REQUIRED)
|
find_package(Qt5Quick REQUIRED)
|
||||||
|
find_package(Qt5Script REQUIRED)
|
||||||
find_package(KCoreAddons REQUIRED)
|
find_package(KCoreAddons REQUIRED)
|
||||||
|
|
||||||
|
|
||||||
@ -33,6 +34,17 @@ add_definitions(${Qt5Widgets_DEFINITIONS} ${Qt5Quick_DEFINITIONS} ${Qt5Qml_DEFIN
|
|||||||
# without -fPIE. We add that here.
|
# without -fPIE. We add that here.
|
||||||
set(CMAKE_CXX_FLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
|
set(CMAKE_CXX_FLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
|
||||||
|
|
||||||
|
set(scripting_SRC
|
||||||
|
scripting/appinterface.cpp
|
||||||
|
scripting/applet.cpp
|
||||||
|
scripting/containment.cpp
|
||||||
|
scripting/i18n.cpp
|
||||||
|
scripting/layouttemplatepackagestructure.cpp
|
||||||
|
scripting/rect.cpp
|
||||||
|
scripting/scriptengine.cpp
|
||||||
|
scripting/widget.cpp
|
||||||
|
)
|
||||||
|
|
||||||
add_executable(testplasma2
|
add_executable(testplasma2
|
||||||
main.cpp
|
main.cpp
|
||||||
desktopcorona.cpp
|
desktopcorona.cpp
|
||||||
@ -40,6 +52,7 @@ add_executable(testplasma2
|
|||||||
shellpluginloader.cpp
|
shellpluginloader.cpp
|
||||||
shellpackage.cpp
|
shellpackage.cpp
|
||||||
view.cpp
|
view.cpp
|
||||||
|
${scripting_SRC}
|
||||||
)
|
)
|
||||||
|
|
||||||
# The Qt5Widgets_LIBRARIES variable also includes QtGui and QtCore
|
# The Qt5Widgets_LIBRARIES variable also includes QtGui and QtCore
|
||||||
@ -51,6 +64,7 @@ target_link_libraries(testplasma2
|
|||||||
${KWindowSystem_LIBRARIES}
|
${KWindowSystem_LIBRARIES}
|
||||||
${KCoreAddons_LIBRARIES}
|
${KCoreAddons_LIBRARIES}
|
||||||
plasma
|
plasma
|
||||||
|
${Qt5Script_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
install(TARGETS testplasma2 ${INSTALL_TARGETS_DEFAULT_ARGS})
|
install(TARGETS testplasma2 ${INSTALL_TARGETS_DEFAULT_ARGS})
|
||||||
|
@ -23,10 +23,14 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#include <KGlobalSettings>
|
#include <KGlobalSettings>
|
||||||
|
#include <KComponentData>
|
||||||
|
#include <k4aboutdata.h>
|
||||||
|
|
||||||
#include <Plasma/Containment>
|
#include <Plasma/Containment>
|
||||||
#include <Plasma/Corona>
|
#include <Plasma/Corona>
|
||||||
#include <Plasma/DataEngineManager>
|
#include <Plasma/DataEngine>
|
||||||
|
#include <Plasma/DataEngineConsumer>
|
||||||
|
#include <Plasma/PluginLoader>
|
||||||
#include <Plasma/Theme>
|
#include <Plasma/Theme>
|
||||||
|
|
||||||
#ifdef Q_WS_X11
|
#ifdef Q_WS_X11
|
||||||
@ -89,12 +93,12 @@ QList<int> AppInterface::panelIds() const
|
|||||||
|
|
||||||
QString AppInterface::applicationVersion() const
|
QString AppInterface::applicationVersion() const
|
||||||
{
|
{
|
||||||
return KGlobal::mainComponent().aboutData()->version();
|
return KComponentData::mainComponent().aboutData()->version();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AppInterface::platformVersion() const
|
QString AppInterface::platformVersion() const
|
||||||
{
|
{
|
||||||
return KDE::versionString();
|
return 0;//KDE::versionString();
|
||||||
}
|
}
|
||||||
|
|
||||||
int AppInterface::scriptingVersion() const
|
int AppInterface::scriptingVersion() const
|
||||||
@ -155,11 +159,11 @@ void AppInterface::sleep(int ms)
|
|||||||
|
|
||||||
bool AppInterface::hasBattery() const
|
bool AppInterface::hasBattery() const
|
||||||
{
|
{
|
||||||
Plasma::DataEngineManager *engines = Plasma::DataEngineManager::self();
|
Plasma::DataEngineConsumer *consumer = new Plasma::DataEngineConsumer();
|
||||||
Plasma::DataEngine *power = engines->loadEngine("powermanagement");
|
Plasma::DataEngine *power = consumer->dataEngine("powermanagement");
|
||||||
|
|
||||||
const QStringList batteries = power->query("Battery")["Sources"].toStringList();
|
const QStringList batteries = power->query("Battery")["Sources"].toStringList();
|
||||||
engines->unloadEngine("powermanagement");
|
delete consumer;
|
||||||
return !batteries.isEmpty();
|
return !batteries.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +171,7 @@ QStringList AppInterface::knownWidgetTypes() const
|
|||||||
{
|
{
|
||||||
if (m_knownWidgets.isEmpty()) {
|
if (m_knownWidgets.isEmpty()) {
|
||||||
QStringList widgets;
|
QStringList widgets;
|
||||||
KPluginInfo::List infoLs = Plasma::Applet::listAppletInfo();
|
KPluginInfo::List infoLs = Plasma::PluginLoader::self()->listAppletInfo(QString());
|
||||||
|
|
||||||
foreach (const KPluginInfo &info, infoLs) {
|
foreach (const KPluginInfo &info, infoLs) {
|
||||||
widgets.append(info.pluginName());
|
widgets.append(info.pluginName());
|
||||||
@ -192,7 +196,7 @@ QStringList AppInterface::knownPanelTypes() const
|
|||||||
QStringList AppInterface::knownContainmentTypes(const QString &type) const
|
QStringList AppInterface::knownContainmentTypes(const QString &type) const
|
||||||
{
|
{
|
||||||
QStringList containments;
|
QStringList containments;
|
||||||
KPluginInfo::List infoLs = Plasma::Containment::listContainmentsOfType(type);
|
KPluginInfo::List infoLs = Plasma::PluginLoader::listContainmentsOfType(type);
|
||||||
|
|
||||||
foreach (const KPluginInfo &info, infoLs) {
|
foreach (const KPluginInfo &info, infoLs) {
|
||||||
containments.append(info.pluginName());
|
containments.append(info.pluginName());
|
||||||
|
@ -24,8 +24,6 @@
|
|||||||
#include <QRectF>
|
#include <QRectF>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
#include "../plasmagenericshell_export.h"
|
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
class Applet;
|
class Applet;
|
||||||
@ -38,7 +36,7 @@ namespace WorkspaceScripting
|
|||||||
|
|
||||||
class ScriptEngine;
|
class ScriptEngine;
|
||||||
|
|
||||||
class PLASMAGENERICSHELL_EXPORT AppInterface : public QObject
|
class AppInterface : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool locked READ coronaLocked WRITE lockCorona)
|
Q_PROPERTY(bool locked READ coronaLocked WRITE lockCorona)
|
||||||
|
@ -216,7 +216,7 @@ QString Applet::version() const
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString type = app->pluginName();
|
QString type = app->pluginInfo().pluginName();
|
||||||
KService::List services = KServiceTypeTrader::self()->query("Plasma/Applet", "[X-KDE-PluginInfo-Name] == '" + type + "'");
|
KService::List services = KServiceTypeTrader::self()->query("Plasma/Applet", "[X-KDE-PluginInfo-Name] == '" + type + "'");
|
||||||
if (services.isEmpty()) {
|
if (services.isEmpty()) {
|
||||||
return QString();
|
return QString();
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
|
|
||||||
#include <KConfigGroup>
|
#include <KConfigGroup>
|
||||||
|
|
||||||
#include "../plasmagenericshell_export.h"
|
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
@ -35,7 +34,7 @@ namespace Plasma
|
|||||||
namespace WorkspaceScripting
|
namespace WorkspaceScripting
|
||||||
{
|
{
|
||||||
|
|
||||||
class PLASMAGENERICSHELL_EXPORT Applet : public QObject
|
class Applet : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -40,7 +40,6 @@
|
|||||||
|
|
||||||
#include <QtCore/QSharedData>
|
#include <QtCore/QSharedData>
|
||||||
|
|
||||||
#include "../plasmagenericshell_export.h"
|
|
||||||
|
|
||||||
#define DECLARE_SELF(Class, __fn__) \
|
#define DECLARE_SELF(Class, __fn__) \
|
||||||
Class* self = qscriptvalue_cast<Class*>(ctx->thisObject()); \
|
Class* self = qscriptvalue_cast<Class*>(ctx->thisObject()); \
|
||||||
@ -212,7 +211,7 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class PLASMAGENERICSHELL_EXPORT Pointer : public QSharedData
|
class Pointer : public QSharedData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef T* pointer_type;
|
typedef T* pointer_type;
|
||||||
|
@ -21,9 +21,11 @@
|
|||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
|
||||||
|
#include <klocalizedstring.h>
|
||||||
|
#include <KActionCollection>
|
||||||
|
|
||||||
#include <Plasma/Corona>
|
#include <Plasma/Corona>
|
||||||
#include <Plasma/Containment>
|
#include <Plasma/Containment>
|
||||||
#include <Plasma/Wallpaper>
|
|
||||||
|
|
||||||
#include "scriptengine.h"
|
#include "scriptengine.h"
|
||||||
#include "widget.h"
|
#include "widget.h"
|
||||||
@ -48,9 +50,8 @@ Containment::Containment(Plasma::Containment *containment, QObject *parent)
|
|||||||
d->containment = containment;
|
d->containment = containment;
|
||||||
setCurrentConfigGroup(QStringList());
|
setCurrentConfigGroup(QStringList());
|
||||||
setCurrentGlobalConfigGroup(QStringList());
|
setCurrentGlobalConfigGroup(QStringList());
|
||||||
if (containment && containment->wallpaper()) {
|
if (containment) {
|
||||||
d->oldWallpaperPlugin = d->wallpaperPlugin = containment->wallpaper()->pluginName();
|
d->oldWallpaperPlugin = d->wallpaperPlugin = containment->wallpaper();
|
||||||
d->oldWallpaperMode = d->wallpaperMode = containment->wallpaper()->renderingMode().name();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,12 +61,11 @@ Containment::~Containment()
|
|||||||
Plasma::Containment *containment = d->containment.data();
|
Plasma::Containment *containment = d->containment.data();
|
||||||
if (d->oldWallpaperPlugin != d->wallpaperPlugin ||
|
if (d->oldWallpaperPlugin != d->wallpaperPlugin ||
|
||||||
d->oldWallpaperMode != d->wallpaperMode) {
|
d->oldWallpaperMode != d->wallpaperMode) {
|
||||||
containment->setWallpaper(d->wallpaperPlugin, d->wallpaperMode);
|
containment->setWallpaper(d->wallpaperPlugin);
|
||||||
} else if (wallpaperConfigDirty() && containment->wallpaper()) {
|
} else if (wallpaperConfigDirty()) {
|
||||||
KConfigGroup cg(containment->config());
|
KConfigGroup cg(containment->config());
|
||||||
cg = KConfigGroup(&cg, "Wallpaper");
|
cg = KConfigGroup(&cg, "Wallpaper");
|
||||||
cg = KConfigGroup(&cg, containment->wallpaper()->pluginName());
|
cg = KConfigGroup(&cg, containment->wallpaper());
|
||||||
containment->wallpaper()->restore(cg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,22 +110,6 @@ void Containment::setWallpaperMode(const QString &wallpaperMode)
|
|||||||
d->wallpaperMode = wallpaperMode;
|
d->wallpaperMode = wallpaperMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Containment::desktop() const
|
|
||||||
{
|
|
||||||
if (!d->containment) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return d->containment.data()->desktop();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Containment::setDesktop(int desktop)
|
|
||||||
{
|
|
||||||
if (d->containment) {
|
|
||||||
d->containment.data()->setScreen(d->containment.data()->screen(), desktop);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Containment::formFactor() const
|
QString Containment::formFactor() const
|
||||||
{
|
{
|
||||||
if (!d->containment) {
|
if (!d->containment) {
|
||||||
@ -208,7 +192,7 @@ QScriptValue Containment::addWidget(QScriptContext *context, QScriptEngine *engi
|
|||||||
QScriptValue v = context->argument(0);
|
QScriptValue v = context->argument(0);
|
||||||
Plasma::Applet *applet = 0;
|
Plasma::Applet *applet = 0;
|
||||||
if (v.isString()) {
|
if (v.isString()) {
|
||||||
applet = c->d->containment.data()->addApplet(v.toString());
|
applet = c->d->containment.data()->createApplet(v.toString());
|
||||||
if (applet) {
|
if (applet) {
|
||||||
ScriptEngine *env = ScriptEngine::envFor(engine);
|
ScriptEngine *env = ScriptEngine::envFor(engine);
|
||||||
return env->wrap(applet);
|
return env->wrap(applet);
|
||||||
@ -236,7 +220,7 @@ QScriptValue Containment::widgets(QScriptContext *context, QScriptEngine *engine
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
foreach (Plasma::Applet *widget, c->d->containment.data()->applets()) {
|
foreach (Plasma::Applet *widget, c->d->containment.data()->applets()) {
|
||||||
if (widgetType.isEmpty() || widget->pluginName() == widgetType) {
|
if (widgetType.isEmpty() || widget->pluginInfo().pluginName() == widgetType) {
|
||||||
widgets.setProperty(count, env->wrap(widget));
|
widgets.setProperty(count, env->wrap(widget));
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
@ -277,20 +261,20 @@ QString Containment::type() const
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
return d->containment.data()->pluginName();
|
return d->containment.data()->pluginInfo().pluginName();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Containment::remove()
|
void Containment::remove()
|
||||||
{
|
{
|
||||||
if (d->containment) {
|
if (d->containment) {
|
||||||
d->containment.data()->destroy(false);
|
d->containment.data()->destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Containment::showConfigurationInterface()
|
void Containment::showConfigurationInterface()
|
||||||
{
|
{
|
||||||
if (d->containment) {
|
if (d->containment) {
|
||||||
QAction *configAction = d->containment.data()->action("configure");
|
QAction *configAction = d->containment.data()->actions()->action("configure");
|
||||||
if (configAction && configAction->isEnabled()) {
|
if (configAction && configAction->isEnabled()) {
|
||||||
configAction->trigger();
|
configAction->trigger();
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,6 @@
|
|||||||
|
|
||||||
#include "applet.h"
|
#include "applet.h"
|
||||||
|
|
||||||
#include "../plasmagenericshell_export.h"
|
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
class Containment;
|
class Containment;
|
||||||
@ -36,7 +34,7 @@ namespace Plasma
|
|||||||
namespace WorkspaceScripting
|
namespace WorkspaceScripting
|
||||||
{
|
{
|
||||||
|
|
||||||
class PLASMAGENERICSHELL_EXPORT Containment : public Applet
|
class Containment : public Applet
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString version READ version)
|
Q_PROPERTY(QString version READ version)
|
||||||
@ -53,7 +51,6 @@ class PLASMAGENERICSHELL_EXPORT Containment : public Applet
|
|||||||
Q_PROPERTY(QString formFactor READ formFactor)
|
Q_PROPERTY(QString formFactor READ formFactor)
|
||||||
Q_PROPERTY(QList<int> widgetIds READ widgetIds)
|
Q_PROPERTY(QList<int> widgetIds READ widgetIds)
|
||||||
Q_PROPERTY(int screen READ screen WRITE setScreen)
|
Q_PROPERTY(int screen READ screen WRITE setScreen)
|
||||||
Q_PROPERTY(int desktop READ desktop WRITE setDesktop)
|
|
||||||
Q_PROPERTY(int id READ id)
|
Q_PROPERTY(int id READ id)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -68,9 +65,6 @@ public:
|
|||||||
QString name() const;
|
QString name() const;
|
||||||
void setName(const QString &name);
|
void setName(const QString &name);
|
||||||
|
|
||||||
int desktop() const;
|
|
||||||
void setDesktop(int desktop);
|
|
||||||
|
|
||||||
int screen() const;
|
int screen() const;
|
||||||
void setScreen(int screen);
|
void setScreen(int screen);
|
||||||
|
|
||||||
|
@ -19,21 +19,17 @@
|
|||||||
|
|
||||||
#include "layouttemplatepackagestructure.h"
|
#include "layouttemplatepackagestructure.h"
|
||||||
|
|
||||||
|
#include <KLocalizedString>
|
||||||
|
|
||||||
namespace WorkspaceScripting
|
namespace WorkspaceScripting
|
||||||
{
|
{
|
||||||
|
|
||||||
LayoutTemplatePackageStructure::LayoutTemplatePackageStructure(QObject *parent)
|
void LayoutTemplatePackageStructure::initPackage(Plasma::Package *package)
|
||||||
: Plasma::PackageStructure(parent)
|
|
||||||
{
|
{
|
||||||
setServicePrefix("plasma-layout-template");
|
package->setServicePrefix("plasma-layout-template");
|
||||||
setDefaultPackageRoot("plasma/layout-templates");
|
package->setDefaultPackageRoot("plasma/layout-templates");
|
||||||
addFileDefinition("mainscript", "layout.js", i18n("Main Script File"));
|
package->addFileDefinition("mainscript", "layout.js", i18n("Main Script File"));
|
||||||
setRequired("mainscript", true);
|
package->setRequired("mainscript", true);
|
||||||
}
|
|
||||||
|
|
||||||
LayoutTemplatePackageStructure::~LayoutTemplatePackageStructure()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,18 +21,16 @@
|
|||||||
#define TEMPLATETEMPLATEPACKAGE_H
|
#define TEMPLATETEMPLATEPACKAGE_H
|
||||||
|
|
||||||
#include <Plasma/PackageStructure>
|
#include <Plasma/PackageStructure>
|
||||||
#include "../plasmagenericshell_export.h"
|
|
||||||
|
|
||||||
namespace WorkspaceScripting
|
namespace WorkspaceScripting
|
||||||
{
|
{
|
||||||
|
|
||||||
class PLASMAGENERICSHELL_EXPORT LayoutTemplatePackageStructure : public Plasma::PackageStructure
|
class LayoutTemplatePackageStructure : public Plasma::PackageStructure
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LayoutTemplatePackageStructure(QObject *parent = 0);
|
void initPackage(Plasma::Package *package);
|
||||||
~LayoutTemplatePackageStructure();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,12 +27,16 @@
|
|||||||
#include <QScriptValueIterator>
|
#include <QScriptValueIterator>
|
||||||
|
|
||||||
#include <KDebug>
|
#include <KDebug>
|
||||||
|
#include <KGlobal>
|
||||||
#include <kdeversion.h>
|
#include <kdeversion.h>
|
||||||
#include <KGlobalSettings>
|
#include <KGlobalSettings>
|
||||||
|
#include <KLocalizedString>
|
||||||
#include <KMimeTypeTrader>
|
#include <KMimeTypeTrader>
|
||||||
#include <KServiceTypeTrader>
|
#include <KServiceTypeTrader>
|
||||||
#include <KShell>
|
#include <KShell>
|
||||||
#include <KStandardDirs>
|
#include <KStandardDirs>
|
||||||
|
#include <KComponentData>
|
||||||
|
#include <k4aboutdata.h>
|
||||||
|
|
||||||
// KIO
|
// KIO
|
||||||
#include <kemailsettings.h> // no camelcase include
|
#include <kemailsettings.h> // no camelcase include
|
||||||
@ -41,7 +45,7 @@
|
|||||||
#include <Plasma/Containment>
|
#include <Plasma/Containment>
|
||||||
#include <Plasma/Corona>
|
#include <Plasma/Corona>
|
||||||
#include <Plasma/Package>
|
#include <Plasma/Package>
|
||||||
#include <Plasma/Wallpaper>
|
#include <Plasma/PluginLoader>
|
||||||
|
|
||||||
#include "appinterface.h"
|
#include "appinterface.h"
|
||||||
#include "containment.h"
|
#include "containment.h"
|
||||||
@ -97,9 +101,8 @@ QScriptValue ScriptEngine::activityForScreen(QScriptContext *context, QScriptEng
|
|||||||
}
|
}
|
||||||
|
|
||||||
const uint screen = context->argument(0).toInt32();
|
const uint screen = context->argument(0).toInt32();
|
||||||
const uint desktop = context->argumentCount() > 1 ? context->argument(1).toInt32() : -1;
|
|
||||||
ScriptEngine *env = envFor(engine);
|
ScriptEngine *env = envFor(engine);
|
||||||
return env->wrap(env->m_corona->containmentForScreen(screen, desktop));
|
return env->wrap(env->m_corona->containmentForScreen(screen));
|
||||||
}
|
}
|
||||||
|
|
||||||
QScriptValue ScriptEngine::newActivity(QScriptContext *context, QScriptEngine *engine)
|
QScriptValue ScriptEngine::newActivity(QScriptContext *context, QScriptEngine *engine)
|
||||||
@ -119,7 +122,7 @@ QScriptValue ScriptEngine::createContainment(const QString &type, const QString
|
|||||||
defaultPlugin;
|
defaultPlugin;
|
||||||
|
|
||||||
bool exists = false;
|
bool exists = false;
|
||||||
const KPluginInfo::List list = Plasma::Containment::listContainmentsOfType(type);
|
const KPluginInfo::List list = Plasma::PluginLoader::listContainmentsOfType(type);
|
||||||
foreach (const KPluginInfo &info, list) {
|
foreach (const KPluginInfo &info, list) {
|
||||||
if (info.pluginName() == plugin) {
|
if (info.pluginName() == plugin) {
|
||||||
exists = true;
|
exists = true;
|
||||||
@ -133,7 +136,7 @@ QScriptValue ScriptEngine::createContainment(const QString &type, const QString
|
|||||||
|
|
||||||
|
|
||||||
ScriptEngine *env = envFor(engine);
|
ScriptEngine *env = envFor(engine);
|
||||||
Plasma::Containment *c = env->m_corona->addContainment(plugin);
|
Plasma::Containment *c = env->m_corona->createContainment(plugin);
|
||||||
if (c) {
|
if (c) {
|
||||||
if (type == "panel") {
|
if (type == "panel") {
|
||||||
// some defaults
|
// some defaults
|
||||||
@ -261,7 +264,7 @@ QScriptValue ScriptEngine::loadTemplate(QScriptContext *context, QScriptEngine *
|
|||||||
}
|
}
|
||||||
|
|
||||||
const QString constraint = QString("[X-Plasma-Shell] == '%1' and [X-KDE-PluginInfo-Name] == '%2'")
|
const QString constraint = QString("[X-Plasma-Shell] == '%1' and [X-KDE-PluginInfo-Name] == '%2'")
|
||||||
.arg(KGlobal::mainComponent().componentName(),layout);
|
.arg(KComponentData::mainComponent().componentName(),layout);
|
||||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/LayoutTemplate", constraint);
|
KService::List offers = KServiceTypeTrader::self()->query("Plasma/LayoutTemplate", constraint);
|
||||||
|
|
||||||
if (offers.isEmpty()) {
|
if (offers.isEmpty()) {
|
||||||
@ -269,15 +272,16 @@ QScriptValue ScriptEngine::loadTemplate(QScriptContext *context, QScriptEngine *
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Plasma::PackageStructure::Ptr structure(new LayoutTemplatePackageStructure);
|
LayoutTemplatePackageStructure structure;
|
||||||
|
Plasma::Package package(&structure);
|
||||||
KPluginInfo info(offers.first());
|
KPluginInfo info(offers.first());
|
||||||
const QString path = KStandardDirs::locate("data", structure->defaultPackageRoot() + '/' + info.pluginName() + '/');
|
const QString path = KStandardDirs::locate("data", package.defaultPackageRoot() + '/' + info.pluginName() + '/');
|
||||||
if (path.isEmpty()) {
|
if (path.isEmpty()) {
|
||||||
kDebug() << "script path is empty";
|
kDebug() << "script path is empty";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
package.setPath(path);
|
||||||
|
|
||||||
Plasma::Package package(path, structure);
|
|
||||||
const QString scriptFile = package.filePath("mainscript");
|
const QString scriptFile = package.filePath("mainscript");
|
||||||
if (scriptFile.isEmpty()) {
|
if (scriptFile.isEmpty()) {
|
||||||
kDebug() << "scriptfile is empty";
|
kDebug() << "scriptfile is empty";
|
||||||
@ -511,8 +515,6 @@ QScriptValue ScriptEngine::userDataPath(QScriptContext *context, QScriptEngine *
|
|||||||
|
|
||||||
if (type.compare("desktop", Qt::CaseInsensitive) == 0) {
|
if (type.compare("desktop", Qt::CaseInsensitive) == 0) {
|
||||||
return KGlobalSettings::desktopPath();
|
return KGlobalSettings::desktopPath();
|
||||||
} else if (type.compare("autostart", Qt::CaseInsensitive) == 0) {
|
|
||||||
return KGlobalSettings::autostartPath();
|
|
||||||
} else if (type.compare("documents", Qt::CaseInsensitive) == 0) {
|
} else if (type.compare("documents", Qt::CaseInsensitive) == 0) {
|
||||||
return KGlobalSettings::documentPath();
|
return KGlobalSettings::documentPath();
|
||||||
} else if (type.compare("music", Qt::CaseInsensitive) == 0) {
|
} else if (type.compare("music", Qt::CaseInsensitive) == 0) {
|
||||||
@ -595,8 +597,8 @@ bool ScriptEngine::isPanel(const Plasma::Containment *c)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return c->containmentType() == Plasma::Containment::PanelContainment ||
|
return c->containmentType() == Plasma::PanelContainment ||
|
||||||
c->containmentType() == Plasma::Containment::CustomPanelContainment;
|
c->containmentType() == Plasma::CustomPanelContainment;
|
||||||
}
|
}
|
||||||
|
|
||||||
QScriptValue ScriptEngine::activities(QScriptContext *context, QScriptEngine *engine)
|
QScriptValue ScriptEngine::activities(QScriptContext *context, QScriptEngine *engine)
|
||||||
|
@ -23,8 +23,6 @@
|
|||||||
#include <QScriptEngine>
|
#include <QScriptEngine>
|
||||||
#include <QScriptValue>
|
#include <QScriptValue>
|
||||||
|
|
||||||
#include "../plasmagenericshell_export.h"
|
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
class Applet;
|
class Applet;
|
||||||
@ -37,7 +35,7 @@ namespace WorkspaceScripting
|
|||||||
|
|
||||||
class Containment;
|
class Containment;
|
||||||
|
|
||||||
class PLASMAGENERICSHELL_EXPORT ScriptEngine : public QScriptEngine
|
class ScriptEngine : public QScriptEngine
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ uint Widget::id() const
|
|||||||
QString Widget::type() const
|
QString Widget::type() const
|
||||||
{
|
{
|
||||||
if (d->applet) {
|
if (d->applet) {
|
||||||
return d->applet.data()->pluginName();
|
return d->applet.data()->pluginInfo().pluginName();
|
||||||
}
|
}
|
||||||
|
|
||||||
return QString();
|
return QString();
|
||||||
@ -113,7 +113,7 @@ int Widget::index() const
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
QGraphicsLayout *layout = c->layout();
|
/*QGraphicsLayout *layout = c->layout();
|
||||||
if (!layout) {
|
if (!layout) {
|
||||||
return - 1;
|
return - 1;
|
||||||
}
|
}
|
||||||
@ -122,7 +122,7 @@ int Widget::index() const
|
|||||||
if (layout->itemAt(i) == applet) {
|
if (layout->itemAt(i) == applet) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -138,41 +138,41 @@ void Widget::setIndex(int index)
|
|||||||
if (!c) {
|
if (!c) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
//FIXME: this is hackish. would be nice to define this for gridlayouts too
|
//FIXME: this is hackish. would be nice to define this for gridlayouts too
|
||||||
QGraphicsLinearLayout *layout = dynamic_cast<QGraphicsLinearLayout *>(c->layout());
|
QGraphicsLinearLayout *layout = dynamic_cast<QGraphicsLinearLayout *>(c->layout());
|
||||||
if (!layout) {
|
if (!layout) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
layout->insertItem(index, applet);
|
layout->insertItem(index, applet);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF Widget::geometry() const
|
QRectF Widget::geometry() const
|
||||||
{
|
{
|
||||||
if (d->applet) {
|
/*if (d->applet) {
|
||||||
return d->applet.data()->geometry();
|
return d->applet.data()->geometry();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return QRectF();
|
return QRectF();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::setGeometry(const QRectF &geometry)
|
void Widget::setGeometry(const QRectF &geometry)
|
||||||
{
|
{
|
||||||
if (d->applet) {
|
/*if (d->applet) {
|
||||||
d->applet.data()->setGeometry(geometry);
|
d->applet.data()->setGeometry(geometry);
|
||||||
KConfigGroup cg = d->applet.data()->config().parent();
|
KConfigGroup cg = d->applet.data()->config().parent();
|
||||||
if (cg.isValid()) {
|
if (cg.isValid()) {
|
||||||
cg.writeEntry("geometry", geometry);
|
cg.writeEntry("geometry", geometry);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::showConfigurationInterface()
|
void Widget::showConfigurationInterface()
|
||||||
{
|
{
|
||||||
if (d->applet) {
|
/* if (d->applet) {
|
||||||
d->applet.data()->showConfigurationInterface();
|
d->applet.data()->showConfigurationInterface();
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,6 @@
|
|||||||
|
|
||||||
#include "applet.h"
|
#include "applet.h"
|
||||||
|
|
||||||
#include "../plasmagenericshell_export.h"
|
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
class Applet;
|
class Applet;
|
||||||
@ -34,7 +32,7 @@ namespace Plasma
|
|||||||
namespace WorkspaceScripting
|
namespace WorkspaceScripting
|
||||||
{
|
{
|
||||||
|
|
||||||
class PLASMAGENERICSHELL_EXPORT Widget : public Applet
|
class Widget : public Applet
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString type READ type)
|
Q_PROPERTY(QString type READ type)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user