Commit 6216091a authored by Alexander Lohnau's avatar Alexander Lohnau 💬

Remove kjsembed leftovers

It is not included in the build for over 10 years and will be completely
removed in KF6. The parts of the documentation were already commented
out and have now been removed entirely.

Discussion: https://phabricator.kde.org/T11603
parent cce2a797
......@@ -85,7 +85,6 @@
<!-- The next 10 ENTITIES do belong to the krusader-tools chapter -->
<!ENTITY bookmarks SYSTEM "bookmarks.docbook">
<!ENTITY diskusage SYSTEM "diskusage.docbook">
<!-- <!ENTITY java SYSTEM "java.docbook"> disabled due to KrJS does not compile (cannot find kjsembed from kdelibs -->
<!ENTITY search SYSTEM "search.docbook">
<!ENTITY viewer-editor SYSTEM "viewer-editor.docbook">
<!ENTITY locate SYSTEM "locate.docbook">
......
......@@ -1265,18 +1265,6 @@
<link linkend="cmdline">embedded terminal</link>.</para>
</entry>
</row>
<!-- <row>
<entry>
<para>
<keycombo action="simul">
&Ctrl;&Alt;
<keycap>J</keycap></keycombo>
</para>
</entry>
<entry>
<para><link linkend="javascript_console">JavaScript console</link></para>
</entry>
</row> disabled due to KrJS does not compile (cannot find kjsembed from kdelibs -->
<row>
<entry>
<para>
......
......@@ -21,7 +21,6 @@
<!-- call the bookmarks sect1 section --> &bookmarks;
<!-- call the diskusage sect1 section --> &diskusage;
<!-- call the java sect1 section --> <!-- &java; disabled due to KrJS does not compile (cannot find kjsembed from kdelibs -->
<!-- call the search sect1 section --> &search;
<!-- call the viewer-editor sect1 section --> &viewer-editor;
<!-- call the locate sect1 section --> &locate;
......
......@@ -1341,26 +1341,6 @@
</listitem>
</varlistentry>
<!-- vertical bar -->
<!-- disabled due to KrJS does not compile (cannot find kjsembed from kdelibs
<varlistentry>
<term>
<menuchoice>
<shortcut>
<keycombo action="simul">
&Alt;&Ctrl;
<keycap>J</keycap></keycombo>
</shortcut>
<guimenu>Tools</guimenu>
<guimenuitem>Javascript Console</guimenuitem>
</menuchoice>
</term>
<listitem>
<para>Opens the
<link linkend="javascript_console">Javascript
Console</link>.</para>
</listitem>
</varlistentry>
-->
<varlistentry>
<term>
<menuchoice>
......
......@@ -96,10 +96,7 @@
<command>%aPanelSize("80")%</command> will set the width of the
active panel to 80% of the &krusader; mainwindow.
Since the parameter of placeholders can contain other
placeholders, few scripts are possible.
<!--However, scripting can be
done with the <link linkend="javascript_console">JavaScript console</link>.
disabled due to KrJS does not compile (cannot find kjsembed from kdelibs -->
placeholders, few scripts are possible.
</para>
<para>
<emphasis role="bold">Managing UserActions</emphasis>
......@@ -539,41 +536,6 @@ format="PNG"/> </imageobject> </inlinemediaobject>button.</para>
</listitem>
</orderedlist>
</listitem>
<!-- <listitem>
<para>
<userinput>Script</userinput> - executes an external
<link linkend="javascript_console">
Javascript</link> file.</para>
<para>NOTE: This is still experimental and the interface may
change, feedback is always welcome.</para>
<orderedlist>
<listitem>
<para>Parameter: path to the
external foo.js file, absolute path or relative to
<filename>
&lt;kde-app-data&gt;/krusader/js/</filename>.
&lt;kde-app-data&gt; is
<filename>$(kde-config
- -localprefix)/share/apps/</filename> or
<filename>$(kde-config - -prefix)/share/apps/</filename>,
for those who do not know where to copy the
scripts/extensions. If all the needed files (normally
<filename>.js</filename> and maybe
<filename>.ui</filename>) are in one of these dirs it is
sufficient to give the file name only as &lt;first parameter&gt;.
</para>
</listitem>
<listitem>
<para>Parameter (optional): a list
of variables which should be set, like <quote>return=cmd;
a=lalala; b='%_Ask(..)'</quote> so that the placeholder is
replaced be the content of the variable cmd and the other
two have already these values when the script
starts.</para>
</listitem>
</orderedlist>
</listitem>
disabled due to KrJS does not compile (cannot find kjsembed from kdelibs -->
<listitem>
<para>
<userinput>ListFile</userinput> - is replaced by path/file name
......
set(KrJS_SRCS
krjs.cpp)
add_library(KrJS STATIC ${KrJS_SRCS})
/*****************************************************************************
* Copyright (C) 2005 Jonas Bähr <jonas.baehr@web.de> *
* *
* This file is part of Krusader [https://krusader.org]. *
* *
* Krusader is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* Krusader 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 General Public License *
* along with Krusader. If not, see [http://www.gnu.org/licenses/]. *
*****************************************************************************/
#include "krjs.h"
#include "../krglobal.h"
#include "../krusaderview.h"
#include "../panelmanager.h"
#include <KWidgetsAddons/KMessageBox>
KrJS::KrJS() : KJSEmbed::KJSEmbedPart()
{
// make this object, the object Krusader, available for scripting as "Krusader":
addObject(krMainWindow, "Krusader");
// make this object available for scripting
addObject(ACTIVE_MNG, "PanelManager");
}
bool KrJS::runFile(const QString & filename)
{
KJS::ExecState *exec = globalExec();
// set up the variable scriptDir with the directory of the current script
putValue("scriptDir", KJSEmbed::convertToValue(exec, QUrl(filename).directory(false)));
bool ok = KJSEmbedPart::runFile(filename);
KJS::Completion jsres = completion();
// this is based on [this example-code](https://invent.kde.org/frameworks/kjsembed/-/blob/master/src/kjscmd/kjscmd.cpp)
if (jsres.complType() != KJS::Normal) {
switch (jsres.complType()) {
case KJS::Break:
case KJS::Continue:
// TODO: find out what this means
qWarning() << "JavaScript: " << jsres.value().toString(exec).qstring();
break;
case KJS::ReturnValue:
// that's only needed when a specific function is called
//someString = jsres.value().toString(exec).qstring();
break;
case KJS::Throw:
/*
This is the interesting part: If the JS throws an exception which is not handled inside the script,
we can catch it here and handle it with c++
*/
{
KJS::Object exception = jsres.value().toObject(exec);
int line = int(exception.get(exec, KJS::Identifier("line")).toNumber(exec));
QString type = exception.get(exec, KJS::Identifier("name")).toString(exec).qstring();
QString message = exception.get(exec, KJS::Identifier("message")).toString(exec).qstring();
qWarning() << "JavaScript: Uncaught " << type << " exception at line " << line << " in " << filename;
qWarning() << message;
KMessageBox::error(0, //parent
(line < 0 ?
QString(i18n("In %1:\nUncaught JavaScript exception '%2'\n%3", filename, type, message)) :
QString(i18n("In %1:\nUncaught JavaScript exception '%2' at line %3\n%4", filename, type, line, message))
), //text
i18n("JavaScript Error"), //caption
KMessageBox::Dangerous);
break;
}
default:
qWarning() << "JavaScript: Unknown error.";
break;
} // switch
} // if
qWarning() << "JS: done";
return ok;
}
/*****************************************************************************
* Copyright (C) 2005 Jonas Bähr <jonas.baehr@web.de> *
* Copyright (C) 2005-2020 Krusader Krew [https://krusader.org] *
* *
* This file is part of Krusader [https://krusader.org]. *
* *
* Krusader is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* Krusader 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 General Public License *
* along with Krusader. If not, see [http://www.gnu.org/licenses/]. *
*****************************************************************************/
#ifndef KRJS_H
#define KRJS_H
#include <kjsembed/kjsembedpart.h>
/**
* Our own version of KJSEmbedPart.
* Here are all the Krusader-specific extensions implemented.
*/
class KrJS: public KJSEmbed::KJSEmbedPart
{
public:
KrJS();
/**
* This loads and runs a file. In addition to the original runFile function it displays an popup
* on errors and sets some variables
*
* @par filename The file to run
*/
bool runFile(const QString & filename);
};
#endif //KRJS_H
......@@ -37,10 +37,6 @@
#include "../Synchronizer/synchronizergui.h"
#endif
#ifdef __KJSEMBED__
#include "../KrJS/krjs.h"
#endif
// QtCore
#include <QDebug>
#include <QStringList>
......@@ -229,14 +225,6 @@ SIMPLE_PLACEHOLDER_CLASS(exp_ColSort);
*/
SIMPLE_PLACEHOLDER_CLASS(exp_PanelSize);
#ifdef __KJSEMBED__
/**
* This sets relation between the left and right panel
*/
SIMPLE_PLACEHOLDER_CLASS(exp_Script);
#endif
/**
* This loads a file in the internal viewer
*/
......@@ -883,59 +871,6 @@ TagString exp_PanelSize::expFunc(const KrPanel* panel, const QStringList& parame
return QString(); // this doesn't return everything, that's normal!
}
#ifdef __KJSEMBED__
exp_Script::exp_Script()
{
_expression = "Script";
_description = i18n("Execute a JavaScript Extension...");
_needPanel = false;
addParameter(exp_parameter(i18n("Location of the script"), "", true));
addParameter(exp_parameter(i18n("Set some variables for the execution (optional).\ni.e. \"return=return_var;foo=bar\", consult the handbook for more information"), "", false));
}
TagString exp_Script::expFunc(const KrPanel*, const QStringList& parameter, const bool&, Expander& exp) const
{
if (parameter.count() == 0 || parameter[0].isEmpty()) {
setError(exp, Error(Error::exp_S_FATAL, Error::exp_C_ARGUMENT, i18n("Expander: no script specified for %_Script(script)%")));
return QString();
}
QString filename = parameter[0];
if (filename.find('/') && QUrl::isRelativeUrl(filename)) {
// this return the local version of the file if this exists. else the global one is returnd
filename = locate("data", "krusader/js/" + filename);
}
if (! krJS)
krJS = new KrJS();
KJS::ExecState *exec = krJS->globalExec();
QString jsReturn;
if (parameter[1].toLower() == "yes") // to stay compatible with the old-style parameter
jsReturn = "cmd";
else {
QStringList jsVariables = parameter[1].split(';');
QString jsVariable, jsValue;
for (QStringList::Iterator it = jsVariables.begin(); it != jsVariables.end(); ++it) {
jsVariable = (*it).section('=', 0, 0).trimmed();
jsValue = (*it).section('=', 1);
if (jsVariable == "return")
jsReturn = jsValue.trimmed();
else
krJS->putValue(jsVariable, KJSEmbed::convertToValue(exec, jsValue));
}
}
krJS->runFile(filename);
if (! jsReturn.isEmpty())
return krJS->getValue(jsReturn).toString(krJS->globalExec()).qstring();
else
return QString();
}
#endif
exp_View::exp_View()
{
_expression = "View";
......@@ -1214,9 +1149,6 @@ QList<const exp_placeholder*>& Expander::_placeholder()
ret << new exp_Filter;
ret << new exp_Count;
ret << new exp_Path;
#ifdef __KJSEMBED__
ret << new exp_Script;
#endif
}
return ret;
}
......@@ -107,11 +107,6 @@ QAction *KrActions::actJobControl = nullptr;
QAction *KrActions::actJobMode = nullptr;
QAction *KrActions::actJobUndo = nullptr;
#ifdef __KJSEMBED__
static QAction *actShowJSConsole;
#endif
QAction *createAction(const QString& text, const QString& iconName, const QKeySequence& shortcut,
QObject *recv, const char *slot, const QString& name, Krusader *krusaderApp)
{
......@@ -317,9 +312,4 @@ void KrActions::setupActions(Krusader *krusaderApp)
// setup all UserActions
krUserAction = new UserAction();
#ifdef __KJSEMBED__
actShowJSConsole = new QAction(i18n("JavaScript Console..."), Qt::ALT + Qt::CTRL + Qt::Key_J, SLOTS, SLOT(jsConsole()), krusaderApp->actionCollection(), "JS_Console");
#endif
}
......@@ -77,11 +77,6 @@ public:
static QAction *actJobMode;
static QAction *actJobUndo;
#ifdef __KJSEMBED__
static QAction *actShowJSConsole;
#endif
static void setupActions(Krusader *krusader);
};
......@@ -103,8 +98,4 @@ public:
#define krUserMenu KrActions::actUserMenu
#define krPopularUrls KrActions::actPopularUrls
#ifdef __KJSEMBED__
#define krJSConsole KrActions::actShowJSConsole
#endif
#endif
......@@ -41,11 +41,6 @@
#include <KWidgetsAddons/KMessageBox>
#include <utility>
#ifdef __KJSEMBED__
#include <kjsembed/jsconsolewidget.h>
#include "KrJS/krjs.h"
#endif
#include "defaults.h"
#include "icon.h"
#include "kractions.h"
......@@ -728,16 +723,6 @@ void KrSlots::trashPopupMenu()
}
}
//shows the JavaScript-Console
void KrSlots::jsConsole()
{
#ifdef __KJSEMBED__
if (! krJS)
krJS = new KrJS();
krJS->view()->show();
#endif
}
void KrSlots::addBookmark()
{
krBookMan->bookmarkCurrent(ACTIVE_PANEL->virtualPath());
......
......@@ -106,7 +106,6 @@ public slots:
#endif
void slotDiskUsage();
void applicationStateChanged();
void jsConsole();
protected slots:
void configChanged(bool isGUIRestartNeeded);
......
......@@ -89,22 +89,12 @@
#include "UserAction/kraction.h"
#include "UserAction/useraction.h"
#ifdef __KJSEMBED__
#include "KrJS/krjs.h"
#endif
// define the static members
Krusader *Krusader::App = nullptr;
QString Krusader::AppName;
// KrBookmarkHandler *Krusader::bookman = 0;
//QTextOStream *Krusader::_krOut = QTextOStream(::stdout);
#ifdef __KJSEMBED__
KrJS *Krusader::js = 0;
QAction *Krusader::actShowJSConsole = 0;
#endif
// construct the views, statusbar and menu bars and prepare Krusader to start
Krusader::Krusader(const QCommandLineParser &parser) : KParts::MainWindow(nullptr,
Qt::Window | Qt::WindowTitleHint | Qt::WindowContextHelpButtonHint),
......
......@@ -48,10 +48,6 @@
#include <KNotifications/KStatusNotifierItem>
#include <KParts/MainWindow>
#ifdef __KJSEMBED__
class KrJS;
#endif
class KStartupInfoData;
class KStartupInfoId;
......@@ -152,10 +148,6 @@ public:
void stopWait();
bool wasWaitingCancelled() const;
#ifdef __KJSEMBED__
static KrJS *js;
#endif
signals:
void changeMessage(QString);
// emitted when we are about to quit
......@@ -180,8 +172,4 @@ private:
// main modules
#define krApp Krusader::App
#ifdef __KJSEMBED__
#define krJS Krusader::App->js
#endif
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment