CalculatorRunner: Port away from KDELibs4Support

wilder-5.14
Vishesh Handa 12 years ago
parent bdf18be495
commit 9b05b96515
  1. 1
      runners/calculator/CMakeLists.txt
  2. 18
      runners/calculator/calculatorrunner.cpp

@ -30,7 +30,6 @@ set(krunner_calculatorrunner_SRCS
KF5::Plasma KF5::Plasma
KF5::Runner KF5::Runner
KF5::I18n KF5::I18n
KF5::KDELibs4Support
Qt5::Script Qt5::Script
) )
#endif () #endif ()

@ -27,10 +27,10 @@
#include <QScriptEngine> #include <QScriptEngine>
#endif #endif
#include <KIcon> #include <QIcon>
#include <QDebug> #include <QDebug>
#include <KGlobal>
#include <KLocalizedString>
#include <krunner/querymatch.h> #include <krunner/querymatch.h>
K_EXPORT_PLASMA_RUNNER(calculatorrunner, CalculatorRunner) K_EXPORT_PLASMA_RUNNER(calculatorrunner, CalculatorRunner)
@ -83,7 +83,7 @@ void CalculatorRunner::powSubstitutions(QString& cmd)
int postIndex = where + 1; int postIndex = where + 1;
int count = 0; int count = 0;
QChar decimalSymbol = KGlobal::locale()->decimalSymbol().at(0); QChar decimalSymbol = QLocale().decimalPoint();
//avoid out of range on weird commands //avoid out of range on weird commands
preIndex = qMax(0, preIndex); preIndex = qMax(0, preIndex);
postIndex = qMin(postIndex, cmd.length()-1); postIndex = qMin(postIndex, cmd.length()-1);
@ -178,8 +178,8 @@ void CalculatorRunner::hexSubstitutions(QString& cmd)
void CalculatorRunner::userFriendlySubstitutions(QString& cmd) void CalculatorRunner::userFriendlySubstitutions(QString& cmd)
{ {
if (cmd.contains(KGlobal::locale()->decimalSymbol(), Qt::CaseInsensitive)) { if (cmd.contains(QLocale().decimalPoint(), Qt::CaseInsensitive)) {
cmd=cmd.replace(KGlobal::locale()->decimalSymbol(), QChar('.'), Qt::CaseInsensitive); cmd=cmd.replace(QLocale().decimalPoint(), QChar('.'), Qt::CaseInsensitive);
} }
// the following substitutions are not needed with libqalculate // the following substitutions are not needed with libqalculate
@ -215,7 +215,7 @@ void CalculatorRunner::match(Plasma::RunnerContext &context)
if (cmd.toLower() == "universe" || cmd.toLower() == "life") { if (cmd.toLower() == "universe" || cmd.toLower() == "life") {
Plasma::QueryMatch match(this); Plasma::QueryMatch match(this);
match.setType(Plasma::QueryMatch::InformationalMatch); match.setType(Plasma::QueryMatch::InformationalMatch);
match.setIcon(KIcon("accessories-calculator")); match.setIcon(QIcon::fromTheme("accessories-calculator"));
match.setText("42"); match.setText("42");
match.setData("42"); match.setData("42");
match.setId(term); match.setId(term);
@ -264,7 +264,7 @@ void CalculatorRunner::match(Plasma::RunnerContext &context)
Plasma::QueryMatch match(this); Plasma::QueryMatch match(this);
match.setType(Plasma::QueryMatch::InformationalMatch); match.setType(Plasma::QueryMatch::InformationalMatch);
match.setIcon(KIcon("accessories-calculator")); match.setIcon(QIcon::fromTheme("accessories-calculator"));
match.setText(result); match.setText(result);
match.setData(result); match.setData(result);
match.setId(term); match.setId(term);
@ -283,7 +283,7 @@ QString CalculatorRunner::calculate(const QString& term)
qDebug() << "qalculate error: " << e.what(); qDebug() << "qalculate error: " << e.what();
} }
return result.replace('.', KGlobal::locale()->decimalSymbol(), Qt::CaseInsensitive); return result.replace('.', QLocale().decimalPoint(), Qt::CaseInsensitive);
#else #else
//qDebug() << "calculating" << term; //qDebug() << "calculating" << term;
QScriptEngine eng; QScriptEngine eng;
@ -308,7 +308,7 @@ QString CalculatorRunner::calculate(const QString& term)
var order=Math.pow(10,exponent);\ var order=Math.pow(10,exponent);\
(order > 0? Math.round(result*order)/order : 0)").toString(); (order > 0? Math.round(result*order)/order : 0)").toString();
roundedResultString.replace('.', KGlobal::locale()->decimalSymbol(), Qt::CaseInsensitive); roundedResultString.replace('.', QLocale().decimalPoint(), Qt::CaseInsensitive);
return roundedResultString; return roundedResultString;
#endif #endif

Loading…
Cancel
Save