libs: remove non-operational WorkspaceScripting::ScriptEngine::loadTemplate() method

plasma layout templates are no longer a thing

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-08-11 18:35:39 +03:00
parent e484245630
commit 5353b11a26
5 changed files with 0 additions and 163 deletions

View file

@ -16,7 +16,6 @@ set(scripting_SRC
scripting/containment.cpp
scripting/configgroup.cpp
scripting/i18n.cpp
scripting/layouttemplatepackagestructure.cpp
scripting/rect.cpp
scripting/scriptengine.cpp
scripting/widget.cpp
@ -67,8 +66,3 @@ install(
EXPORT kdeworkspaceTargets
DESTINATION ${KDE4_LIB_INSTALL_DIR}
)
install(
FILES plasma-layout-template.desktop
DESTINATION ${KDE4_SERVICETYPES_INSTALL_DIR}
)

View file

@ -1,7 +0,0 @@
[Desktop Entry]
Type=ServiceType
X-KDE-ServiceType=Plasma/LayoutTemplate
[PropertyDef::X-Plasma-Shell]
Type=QString

View file

@ -1,42 +0,0 @@
/*
* Copyright 2010 Aaron Seigo <aseigo@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "layouttemplatepackagestructure.h"
namespace WorkspaceScripting
{
LayoutTemplatePackageStructure::LayoutTemplatePackageStructure(QObject *parent)
: Plasma::PackageStructure(parent)
{
setServicePrefix("plasma-layout-template");
setDefaultPackageRoot("plasma/layout-templates");
addFileDefinition("mainscript", "layout.js", i18n("Main Script File"));
setRequired("mainscript", true);
}
LayoutTemplatePackageStructure::~LayoutTemplatePackageStructure()
{
}
}
#include "moc_layouttemplatepackagestructure.cpp"

View file

@ -1,42 +0,0 @@
/*
* Copyright 2010 Aaron Seigo <aseigo@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef TEMPLATETEMPLATEPACKAGE_H
#define TEMPLATETEMPLATEPACKAGE_H
#include <Plasma/PackageStructure>
#include "plasmagenericshell_export.h"
namespace WorkspaceScripting
{
class PLASMAGENERICSHELL_EXPORT LayoutTemplatePackageStructure : public Plasma::PackageStructure
{
Q_OBJECT
public:
LayoutTemplatePackageStructure(QObject *parent = 0);
~LayoutTemplatePackageStructure();
};
}
#endif

View file

@ -44,7 +44,6 @@
#include "containment.h"
#include "configgroup.h"
#include "i18n.h"
#include "layouttemplatepackagestructure.h"
#include "widget.h"
QScriptValue constructQRectFClass(QScriptEngine *engine);
@ -215,70 +214,6 @@ QScriptValue ScriptEngine::fileExists(QScriptContext *context, QScriptEngine *en
return f.exists();
}
QScriptValue ScriptEngine::loadTemplate(QScriptContext *context, QScriptEngine *engine)
{
Q_UNUSED(engine)
if (context->argumentCount() == 0) {
kDebug() << "no arguments";
return false;
}
const QString layout = context->argument(0).toString();
if (layout.isEmpty() || layout.contains("'")) {
kDebug() << "layout is empty";
return false;
}
const QString constraint = QString("[X-Plasma-Shell] == '%1' and [X-KDE-PluginInfo-Name] == '%2'")
.arg(KGlobal::mainComponent().componentName(),layout);
KService::List offers = KServiceTypeTrader::self()->query("Plasma/LayoutTemplate", constraint);
if (offers.isEmpty()) {
kDebug() << "offers fail" << constraint;
return false;
}
Plasma::PackageStructure::Ptr structure(new LayoutTemplatePackageStructure);
KPluginInfo info(offers.first());
const QString path = KStandardDirs::locate("data", structure->defaultPackageRoot() + '/' + info.pluginName() + '/');
if (path.isEmpty()) {
kDebug() << "script path is empty";
return false;
}
Plasma::Package package(path, structure);
const QString scriptFile = package.filePath("mainscript");
if (scriptFile.isEmpty()) {
kDebug() << "scriptfile is empty";
return false;
}
QFile file(scriptFile);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
kWarning() << i18n("Unable to load script file: %1", path);
return false;
}
QString script = file.readAll();
if (script.isEmpty()) {
kDebug() << "script is empty";
return false;
}
ScriptEngine *env = envFor(engine);
env->globalObject().setProperty("templateName", env->newVariant(info.name()), QScriptValue::ReadOnly | QScriptValue::Undeletable);
env->globalObject().setProperty("templateComment", env->newVariant(info.comment()), QScriptValue::ReadOnly | QScriptValue::Undeletable);
QScriptValue rv = env->newObject();
QScriptContext *ctx = env->pushContext();
ctx->setThisObject(rv);
env->evaluateScript(script, path);
env->popContext();
return rv;
}
QScriptValue ScriptEngine::applicationExists(QScriptContext *context, QScriptEngine *engine)
{
Q_UNUSED(engine)
@ -477,7 +412,6 @@ void ScriptEngine::setupEngine()
m_scriptSelf.setProperty("panelById", newFunction(ScriptEngine::panelById));
m_scriptSelf.setProperty("panels", newFunction(ScriptEngine::panels));
m_scriptSelf.setProperty("fileExists", newFunction(ScriptEngine::fileExists));
m_scriptSelf.setProperty("loadTemplate", newFunction(ScriptEngine::loadTemplate));
m_scriptSelf.setProperty("applicationExists", newFunction(ScriptEngine::applicationExists));
m_scriptSelf.setProperty("userDataPath", newFunction(ScriptEngine::userDataPath));
m_scriptSelf.setProperty("applicationPath", newFunction(ScriptEngine::applicationPath));