[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
wilder-5.14
Kai Uwe Broulik 9 years ago
parent 119f250424
commit 605fb9acd8
  1. 3
      runners/calculator/CMakeLists.txt
  2. 6
      runners/calculator/calculatorrunner.cpp

@ -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 ()

@ -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();

Loading…
Cancel
Save