Commit 09e97143 authored by Nicolas Fella's avatar Nicolas Fella
Browse files

Remove dead calculator Plasmoid

It hasn't been ported to Plasma 5 in ten years
parent 6d6d5d32
Pipeline #224384 passed with stage
in 44 seconds
# add_subdirectory(calculator)
# TODO: port to QML
install(DIRECTORY graphsplasmoid/ DESTINATION ${KDE_INSTALL_DATADIR}/plasma/plasmoids/org.kde.graphsplasmoid)
install(FILES graphsplasmoid/metadata.desktop DESTINATION ${KDE_INSTALL_KSERVICESDIR} RENAME graphsplasmoid.desktop)
project(kalgebra-plasmoid)
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
set(kalgebraplasma_SRCS kalgebraplasma.cpp)
add_library(plasma_applet_kalgebra MODULE ${kalgebraplasma_SRCS})
target_link_libraries(plasma_applet_kalgebra ${KF5::plasma} KF5::Analitza)
set(plugin_dir ${KDE_INSTALL_PLUGINDIR}/plugins/kalgebra)
install(TARGETS plasma_applet_kalgebra DESTINATION ${KDE_INSTALL_PLUGINDIR})
install(FILES kalgebraplasmoid.desktop DESTINATION ${KDE_INSTALL_KSERVICESDIR})
#! /bin/sh
$XGETTEXT *.cpp -o $podir/plasma_applet_kalgebraplasmoid.pot
/*************************************************************************************
* Copyright (C) 2008 by Aleix Pol <aleixpol@kde.org> *
* *
* This program 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. *
* *
* This program 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 this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
*************************************************************************************/
#include "kalgebraplasma.h"
#include <QFontMetrics>
#include <QGraphicsProxyWidget>
#include <QFont>
#include <KIcon>
#include <KIconLoader>
#include <plasma/theme.h>
#include <plasma/dataengine.h>
#include <plasma/tooltipcontent.h>
#include <plasma/tooltipmanager.h>
#include <analitza/expression.h>
using namespace Plasma;
using Analitza::Expression;
QColor KAlgebraPlasmoid::correctColor() { return Theme::defaultTheme()->color(Theme::TextColor);}
QColor KAlgebraPlasmoid::errorColor() { return Qt::red; }
int KAlgebraPlasmoid::simplificationSize() { return Theme::defaultTheme()->font(Theme::DefaultFont).pointSize(); }
KAlgebraPlasmoid::KAlgebraPlasmoid(QObject *parent, const QVariantList &args)
: PopupApplet(parent, args), m_widget(0), m_layout(0)
{
KGlobal::locale()->insertCatalog("kalgebra");
setAspectRatioMode(IgnoreAspectRatio);
setAssociatedApplication("kalgebra");
}
KAlgebraPlasmoid::~KAlgebraPlasmoid() {}
void KAlgebraPlasmoid::init()
{
// updateFactor();
setPopupIcon("kalgebra");
}
QQuickItem* KAlgebraPlasmoid::graphicsWidget()
{
if(!m_widget) {
m_widget = new QQuickItem(this);
m_input = new Plasma::LineEdit(m_widget);
m_input->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
m_input->setClearButtonShown(true);
m_output = new Plasma::Label(m_widget);
m_output->setMinimumSize(20, 20);
m_output->nativeWidget()->setAlignment(Qt::AlignCenter);
m_output->setText(i18n("Enter some expression."));
m_layout = new QGraphicsLinearLayout(m_widget);
m_layout->setOrientation(Qt::Vertical);
m_layout->addItem(m_input);
m_layout->addItem(m_output);
m_widget->setPreferredSize(300,300);
connect(m_input, SIGNAL(editingFinished()), this, SLOT(addOperation()));
connect(m_input->nativeWidget(), SIGNAL(textChanged(QString)), this, SLOT(simplify()));
}
m_input->nativeWidget()->selectAll();
m_input->setFocus();
return m_widget;
}
void KAlgebraPlasmoid::addOperation()
{
if ( m_input->text().isEmpty() )
return;
Expression res;
a.setExpression(Expression(m_input->text(), false));
if(a.isCorrect()) {
res=a.evaluate();
}
QColor c;
if(a.isCorrect()) {
QString result=res.toString();
m_output->setText(result);
Plasma::ToolTipContent data;
data.setMainText(i18n("KAlgebra"));
data.setSubText(i18n("%1 = %2", m_input->text(), result));
data.setImage(QIcon::fromTheme("kalgebra").pixmap(IconSize(KIconLoader::Desktop)));
Plasma::ToolTipManager::self()->setContent(this, data);
c=correctColor();
} else {
m_output->setText(a.errors().join("\n"));
c=errorColor();
}
plasmoidFont(true, c, true);
update();
}
void KAlgebraPlasmoid::plasmoidFont(bool big, const QColor& c, bool bold)
{
QFont f=m_output->nativeWidget()->font();
f.setBold(bold);
int size;
if(big) {
size=(m_output->size().height()*2)/3;
f.setPointSize(size);
QFontMetrics fm(f);
int w=m_output->size().width();
Q_ASSERT(w>0);
for(; fm.width(m_output->text()) > w; size--) {
f.setPointSize(size);
fm=QFontMetrics(f);
}
} else
size=simplificationSize();
f.setPointSize(size);
QPalette palette = m_output->palette();
palette.setColor(QPalette::WindowText, c);
m_output->nativeWidget()->setPalette(palette);
m_output->nativeWidget()->setFont(f);
}
void KAlgebraPlasmoid::simplify()
{
Expression e(m_input->text(), false);
if(e.isCorrect())
a.setExpression(e);
if(e.isCorrect() && a.isCorrect()) {
a.simplify();
m_output->setText(a.expression().toString());
plasmoidFont(false, correctColor(), true);
} else
m_output->setText(QString());
}
/*************************************************************************************
* Copyright (C) 2008 by Aleix Pol <aleixpol@kde.org> *
* *
* This program 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. *
* *
* This program 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 this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
*************************************************************************************/
#ifndef KALGEBRAPLASMA_HEADER
#define KALGEBRAPLASMA_HEADER
#include <Plasma/PopupApplet>
#include <Plasma/Label>
#include <Plasma/LineEdit>
#include <QGraphicsLinearLayout>
#include <analitza/analyzer.h>
class KAlgebraPlasmoid : public Plasma::Applet
{
Q_OBJECT
public:
KAlgebraPlasmoid(QObject *parent, const QVariantList &args);
~KAlgebraPlasmoid();
void init();
virtual QQuickItem* graphicsWidget();
private Q_SLOTS:
void simplify();
void addOperation();
private:
static QColor correctColor();
static QColor errorColor();
static int simplificationSize();
void plasmoidFont(bool big, const QColor& c, bool bold);
QQuickItem* m_widget;
QGraphicsLinearLayout* m_layout;
Plasma::LineEdit *m_input;
Plasma::Label *m_output;
Analitza::Analyzer a;
};
// This is the command that links your applet to the .desktop file
K_EXPORT_PLASMA_APPLET(kalgebraplasmoid, KAlgebraPlasmoid)
#endif
[Desktop Entry]
Name=KAlgebra
Name[ar]=جبرك
Name[bg]=KAlgebra
Name[bs]=Kalgebra
Name[ca]=KAlgebra
Name[ca@valencia]=KAlgebra
Name[cs]=KAlgebra
Name[csb]=KAlgebra
Name[da]=KAlgebra
Name[de]=KAlgebra
Name[el]=KAlgebra
Name[en_GB]=KAlgebra
Name[eo]=KAlgebra
Name[es]=KAlgebra
Name[et]=KAlgebra
Name[eu]=KAlgebra
Name[fa]=KAlgebra
Name[fi]=KAlgebra
Name[fr]=KAlgebra
Name[ga]=KAlgebra
Name[gl]=KAlgebra
Name[gu]=KAlgebra
Name[he]=KAlgebra
Name[hi]=के-अलजेब्रा
Name[hne]=के-अलजेब्रा
Name[hr]=KAlgebra
Name[hu]=KAlgebra
Name[is]=KAlgebra
Name[it]=KAlgebra
Name[ja]=KAlgebra
Name[kk]=KAlgebra
Name[km]=KAlgebra
Name[ko]=KAlgebra
Name[lt]=KAlgebra
Name[lv]=KAlgebra
Name[ml]=കെ-ആള്‍ജിബ്ര
Name[mr]=के-एल्जिब्रा
Name[nb]=KAlgebra
Name[nds]=KAlgebra
Name[ne]=केडीई बीजगणित
Name[nl]=KAlgebra
Name[nn]=KAlgebra
Name[pa]=ਕੇ-ਐਲਜਬਰਾ
Name[pl]=KAlgebra
Name[pt]=KAlgebra
Name[pt_BR]=KAlgebra
Name[ro]=KAlgebra
Name[ru]=KAlgebra
Name[si]=KAlgebra
Name[sk]=KAlgebra
Name[sl]=KAlgebra
Name[sv]=Kalgebra
Name[te]=కె అల్జీబ్రా
Name[tr]=KAlgebra
Name[ug]=KAlgebra
Name[uk]=KАлгебра
Name[x-test]=xxKAlgebraxx
Name[zh_CN]=KAlgebra
Name[zh_TW]=數學_KAlgebra
Icon=kalgebra
Comment=A Calculator
Comment[ar]=حاسبة
Comment[bg]=Калкулатор
Comment[bs]=Kalkulator
Comment[ca]=Una calculadora
Comment[ca@valencia]=Una calculadora
Comment[cs]=Kalkulačka
Comment[da]=En regnemaskine
Comment[de]=Ein Taschenrechner
Comment[el]=Ένας μικροϋπολογιστής
Comment[en_GB]=A Calculator
Comment[es]=Una calculadora
Comment[et]=Arvutaja
Comment[eu]=Kalkulagailu bat
Comment[fa]=یک ماشین حساب
Comment[fi]=Laskin
Comment[fr]=Une calculatrice
Comment[ga]=Áireamhán
Comment[gl]=Unha calculadora
Comment[gu]=કેલ્ક્યુલેટર
Comment[he]=מחשבון
Comment[hne]=गनक
Comment[hr]=Kalkulator
Comment[hu]=Algebrai számológép
Comment[is]=Reiknivél
Comment[it]=Una calcolatrice
Comment[ja]=計算機
Comment[kk]=Калькулятор
Comment[km]=ម៉ាស៊ីន​គិត​លេខ
Comment[ko]=계산기
Comment[lt]=Skaičiuotuvas
Comment[lv]=Kalkulators
Comment[ml]=ഗണനി
Comment[mr]=गणकयंत्र
Comment[nb]=En kalkulator
Comment[nds]=En Rekenprogramm
Comment[nl]=Een rekenmachine
Comment[nn]=Kalkulator
Comment[pa]=ਇੱਕ ਕੈਲਕੂਲੇਟਰ
Comment[pl]=Kalkulator
Comment[pt]=Uma Calculadora
Comment[pt_BR]=Uma calculadora
Comment[ro]=Un calculator
Comment[ru]=Калькулятор
Comment[sk]=Kalkulačka
Comment[sl]=Računalo
Comment[sv]=Kalkylator
Comment[te]=గనన యంత్రము
Comment[tr]=Bir Hesap Makinesi
Comment[ug]=ھېسابلىغۇچ
Comment[uk]=Калькулятор
Comment[x-test]=xxA Calculatorxx
Comment[zh_CN]=一个计算器
Comment[zh_TW]=計算器
Type=Service
ServiceTypes=Plasma/Applet
X-KDE-Library=plasma_applet_kalgebra
X-KDE-PluginInfo-Author=Aleix Pol Gonzalez
X-KDE-PluginInfo-Email=aleixpol@kde.org
X-KDE-PluginInfo-Name=kalgebraplasmoid
X-KDE-PluginInfo-Version=0.1
X-KDE-PluginInfo-Website=https://edu.kde.org/
X-KDE-PluginInfo-Category=Education
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true
Supports Markdown
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