summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Uwe Broulik <[email protected]>2017-02-07 11:40:42 +0100
committerKai Uwe Broulik <[email protected]>2017-02-07 11:40:42 +0100
commit605fb9acd867e22e171184a08d9dfd2d1d4e893e (patch)
treeecd9d67eb3016e0a6925d11d7c9c29b4620eda45
parent119f2504246d4b8b25eee2f7d197dfd8555c643d (diff)
[Calculator Runner] Port non-Qalculate codepath from QtScript to QtQml
QtScript is deprecated and at least in this place it's a straight-forward port. The Qalculate code path also doesn't need it, so remove it from CMake there. Differential Revision: https://phabricator.kde.org/D4472
-rw-r--r--runners/calculator/CMakeLists.txt3
-rw-r--r--runners/calculator/calculatorrunner.cpp6
2 files changed, 4 insertions, 5 deletions
diff --git a/runners/calculator/CMakeLists.txt b/runners/calculator/CMakeLists.txt
index b1ab6e6..652a28a 100644
--- a/runners/calculator/CMakeLists.txt
+++ b/runners/calculator/CMakeLists.txt
@@ -33,7 +33,6 @@ if ( QALCULATE_FOUND )
KF5::Runner
KF5::I18n
Qt5::Network
- Qt5::Script
Qt5::Widgets
)
else ()
@@ -42,7 +41,7 @@ else ()
KF5::Runner
KF5::I18n
Qt5::Gui
- Qt5::Script
+ Qt5::Qml
)
endif ()
diff --git a/runners/calculator/calculatorrunner.cpp b/runners/calculator/calculatorrunner.cpp
index 68e48ca..cba5498 100644
--- a/runners/calculator/calculatorrunner.cpp
+++ b/runners/calculator/calculatorrunner.cpp
@@ -24,7 +24,7 @@
#ifdef ENABLE_QALCULATE
#include "qalculate_engine.h"
#else
-#include <QScriptEngine>
+#include <QJSEngine>
#include <QGuiApplication>
#include <QClipboard>
#endif
@@ -292,8 +292,8 @@ QString CalculatorRunner::calculate(const QString& term)
return result.replace('.', QLocale().decimalPoint(), Qt::CaseInsensitive);
#else
//qDebug() << "calculating" << term;
- QScriptEngine eng;
- QScriptValue result = eng.evaluate(" var result ="+term+"; result");
+ QJSEngine eng;
+ QJSValue result = eng.evaluate(QStringLiteral("var result = %1; result").arg(term));
if (result.isError()) {
return QString();