[utilities/krusader] /: Remove kjsembed leftovers

Alexander Lohnau null at kde.org
Mon Jan 4 08:28:29 GMT 2021


Git commit 6216091ae512af4791cc00efa1e508927bffa3a2 by Alexander Lohnau.
Committed on 03/01/2021 at 21:48.
Pushed by alex into branch 'master'.

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

M  +0    -1    doc/index.docbook
M  +0    -12   doc/keyboard-commands.docbook
M  +0    -1    doc/krusader-tools.docbook
M  +0    -20   doc/menu-commands.docbook
M  +1    -39   doc/useractions.docbook
D  +0    -4    krusader/KrJS/CMakeLists.txt
D  +0    -96   krusader/KrJS/krjs.cpp
D  +0    -45   krusader/KrJS/krjs.h
M  +0    -68   krusader/UserAction/expander.cpp
M  +0    -10   krusader/kractions.cpp
M  +0    -9    krusader/kractions.h
M  +0    -15   krusader/krslots.cpp
M  +0    -1    krusader/krslots.h
M  +0    -10   krusader/krusader.cpp
M  +0    -12   krusader/krusader.h

https://invent.kde.org/utilities/krusader/commit/6216091ae512af4791cc00efa1e508927bffa3a2

diff --git a/doc/index.docbook b/doc/index.docbook
index feb71a24..e3c3cfa1 100644
--- a/doc/index.docbook
+++ b/doc/index.docbook
@@ -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">
diff --git a/doc/keyboard-commands.docbook b/doc/keyboard-commands.docbook
index 141856d2..5658905f 100644
--- a/doc/keyboard-commands.docbook
+++ b/doc/keyboard-commands.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>
diff --git a/doc/krusader-tools.docbook b/doc/krusader-tools.docbook
index 3b394b1b..01aed928 100644
--- a/doc/krusader-tools.docbook
+++ b/doc/krusader-tools.docbook
@@ -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;
diff --git a/doc/menu-commands.docbook b/doc/menu-commands.docbook
index e281724c..1d178fb3 100644
--- a/doc/menu-commands.docbook
+++ b/doc/menu-commands.docbook
@@ -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>
diff --git a/doc/useractions.docbook b/doc/useractions.docbook
index b77a7c8f..e1d11042 100644
--- a/doc/useractions.docbook
+++ b/doc/useractions.docbook
@@ -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>
-          <kde-app-data>/krusader/js/</filename>.
-          <kde-app-data> 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 <first parameter>.
-          </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
diff --git a/krusader/KrJS/CMakeLists.txt b/krusader/KrJS/CMakeLists.txt
deleted file mode 100644
index 15d4f11b..00000000
--- a/krusader/KrJS/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-set(KrJS_SRCS
-    krjs.cpp)
-
-add_library(KrJS STATIC ${KrJS_SRCS})
diff --git a/krusader/KrJS/krjs.cpp b/krusader/KrJS/krjs.cpp
deleted file mode 100644
index e4ee40cb..00000000
--- a/krusader/KrJS/krjs.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*****************************************************************************
- * Copyright (C) 2005 Jonas Bähr <jonas.baehr at 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;
-}
-
diff --git a/krusader/KrJS/krjs.h b/krusader/KrJS/krjs.h
deleted file mode 100644
index 3843eb4b..00000000
--- a/krusader/KrJS/krjs.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*****************************************************************************
- * Copyright (C) 2005 Jonas Bähr <jonas.baehr at 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
diff --git a/krusader/UserAction/expander.cpp b/krusader/UserAction/expander.cpp
index 6892291a..3d312436 100644
--- a/krusader/UserAction/expander.cpp
+++ b/krusader/UserAction/expander.cpp
@@ -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;
 }
diff --git a/krusader/kractions.cpp b/krusader/kractions.cpp
index 84ce1bbf..d79be10a 100644
--- a/krusader/kractions.cpp
+++ b/krusader/kractions.cpp
@@ -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
-
 }
diff --git a/krusader/kractions.h b/krusader/kractions.h
index 4b1693a5..9e70a0cf 100644
--- a/krusader/kractions.h
+++ b/krusader/kractions.h
@@ -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
diff --git a/krusader/krslots.cpp b/krusader/krslots.cpp
index 2ae83b7a..7bd75baf 100644
--- a/krusader/krslots.cpp
+++ b/krusader/krslots.cpp
@@ -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());
diff --git a/krusader/krslots.h b/krusader/krslots.h
index f2a9c79c..b4505595 100644
--- a/krusader/krslots.h
+++ b/krusader/krslots.h
@@ -106,7 +106,6 @@ public slots:
 #endif
     void slotDiskUsage();
     void applicationStateChanged();
-    void jsConsole();
 
 protected slots:
     void configChanged(bool isGUIRestartNeeded);
diff --git a/krusader/krusader.cpp b/krusader/krusader.cpp
index ffed049f..fe6da226 100644
--- a/krusader/krusader.cpp
+++ b/krusader/krusader.cpp
@@ -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),
diff --git a/krusader/krusader.h b/krusader/krusader.h
index 7b699734..e2bddc86 100644
--- a/krusader/krusader.h
+++ b/krusader/krusader.h
@@ -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


More information about the kde-doc-english mailing list