Remove X-Plasma-MainScript from C++ codepaths
This commit is contained in:
parent
bf713d3892
commit
43174a9771
5 changed files with 15 additions and 27 deletions
|
@ -70,10 +70,8 @@ static QString locateMainScript(const QString &pluginName)
|
|||
if (offers.isEmpty()) {
|
||||
return QString();
|
||||
}
|
||||
const KPluginMetaData &metaData = offers.first();
|
||||
const QString mainScriptFileName = metaData.value(QStringLiteral("X-Plasma-MainScript"));
|
||||
const QFileInfo metaDataFileInfo(metaData.fileName());
|
||||
return metaDataFileInfo.path() + QLatin1String("/contents/") + mainScriptFileName;
|
||||
const QFileInfo metaDataFileInfo(offers.first().fileName());
|
||||
return metaDataFileInfo.path() + QLatin1String("/contents/code/main.js");
|
||||
}
|
||||
|
||||
void MinimizeAllScriptTest::init()
|
||||
|
|
|
@ -167,14 +167,10 @@ void KWinTabBoxConfig::initLayoutLists()
|
|||
|
||||
for (const auto &offer : offers) {
|
||||
const QString pluginName = offer.pluginId();
|
||||
if (offer.value("X-Plasma-API") != "declarativeappletscript") {
|
||||
continue;
|
||||
}
|
||||
const QString scriptName = offer.value("X-Plasma-MainScript");
|
||||
const QString scriptFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
|
||||
QLatin1String("kwin/tabbox/") + pluginName + QLatin1String("/contents/")
|
||||
+ scriptName);
|
||||
if (scriptFile.isNull()) {
|
||||
QLatin1String("kwin/tabbox/") + pluginName + QLatin1String("/contents/ui/main.qml"));
|
||||
if (scriptFile.isEmpty()) {
|
||||
qWarning() << "scriptfile is null" << pluginName;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -156,10 +156,9 @@ QQmlComponent *Helper::loadComponent(const QString &themeName)
|
|||
// TODO: what to do in error case?
|
||||
return nullptr;
|
||||
}
|
||||
const KPluginMetaData &service = offers.first();
|
||||
const KPluginMetaData service = offers.first();
|
||||
const QString pluginName = service.pluginId();
|
||||
const QString scriptName = service.value(QStringLiteral("X-Plasma-MainScript"));
|
||||
const QString file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, s_qmlPackageFolder + pluginName + QLatin1String("/contents/") + scriptName);
|
||||
const QString file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, s_qmlPackageFolder + pluginName + QLatin1String("/contents/ui/main.qml"));
|
||||
if (file.isNull()) {
|
||||
qCDebug(AURORAE) << "Could not find script file for " << pluginName;
|
||||
// TODO: what to do in error case?
|
||||
|
|
|
@ -156,15 +156,10 @@ static KWin::FPx2 fpx2FromScriptValue(const QJSValue &value)
|
|||
ScriptedEffect *ScriptedEffect::create(const KPluginMetaData &effect)
|
||||
{
|
||||
const QString name = effect.pluginId();
|
||||
const QString scriptName = effect.value(QStringLiteral("X-Plasma-MainScript"));
|
||||
if (scriptName.isEmpty()) {
|
||||
qCDebug(KWIN_SCRIPTING) << "X-Plasma-MainScript not set";
|
||||
return nullptr;
|
||||
}
|
||||
const QString scriptFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
|
||||
QLatin1String("kwin/effects/") + name + QLatin1String("/contents/") + scriptName);
|
||||
if (scriptFile.isNull()) {
|
||||
qCDebug(KWIN_SCRIPTING) << "Could not locate the effect script";
|
||||
QLatin1String("kwin/effects/") + name + QLatin1String("/contents/code/main.js"));
|
||||
if (scriptFile.isEmpty()) {
|
||||
qCDebug(KWIN_SCRIPTING) << "Could not locate effect script" << name;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -830,8 +825,7 @@ void ScriptedEffect::setUniform(uint shaderId, const QString &name, const QJSVal
|
|||
m_engine->throwError(QStringLiteral("Failed to make OpenGL context current"));
|
||||
return;
|
||||
}
|
||||
auto setColorUniform = [this, shader, name] (const QColor &color)
|
||||
{
|
||||
auto setColorUniform = [this, shader, name](const QColor &color) {
|
||||
if (!color.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -721,9 +721,10 @@ LoadScriptList KWin::Scripting::queryScriptsToLoad()
|
|||
continue;
|
||||
}
|
||||
const QString pluginName = service.pluginId();
|
||||
const QString scriptName = service.value(QStringLiteral("X-Plasma-MainScript"));
|
||||
const QString file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, scriptFolder + pluginName + QLatin1String("/contents/") + scriptName);
|
||||
if (file.isNull()) {
|
||||
// The file we want to load depends on the specified API. We could check if one or the other file exists, but that is more error prone and causes IO overhead
|
||||
const QString relScriptPath = scriptFolder + pluginName + QLatin1String("/contents/") + (javaScript ? QLatin1String("code/main.js") : QLatin1String("ui/main.qml"));
|
||||
const QString file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, relScriptPath);
|
||||
if (file.isEmpty()) {
|
||||
qCDebug(KWIN_SCRIPTING) << "Could not find script file for " << pluginName;
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue