1 /*
2 SPDX-License-Identifier: GPL-2.0-or-later
3 SPDX-FileCopyrightText: 2009 Alexander Rieder <alexanderrieder@gmail.com>
4 SPDX-FileCopyrightText: 2019 Alexander Semke <alexander.semke@web.de>
5 */
6
7 #include "sagebackend.h"
8 #include "sageextensions.h"
9 #include "sagesession.h"
10 #include "sagesettingswidget.h"
11 #include "settings.h"
12
SageBackend(QObject * parent,const QList<QVariant> & args)13 SageBackend::SageBackend( QObject* parent,const QList<QVariant>& args ) : Cantor::Backend( parent,args )
14 {
15 //initialize the supported extensions
16 new SageHistoryExtension(this);
17 new SageScriptExtension(this);
18 new SageCASExtension(this);
19 new SageCalculusExtension(this);
20 new SageLinearAlgebraExtension(this);
21 new SagePlotExtension(this);
22 new SagePackagingExtension(this);
23 }
24
~SageBackend()25 SageBackend::~SageBackend()
26 {
27 qDebug()<<"Destroying SageBackend";
28 }
29
id() const30 QString SageBackend::id() const
31 {
32 return QLatin1String("sage");
33 }
34
version() const35 QString SageBackend::version() const
36 {
37 return QLatin1String("8.3");
38 }
39
createSession()40 Cantor::Session* SageBackend::createSession()
41 {
42 qDebug()<<"Spawning a new Sage session";
43
44 return new SageSession(this);
45 }
46
capabilities() const47 Cantor::Backend::Capabilities SageBackend::capabilities() const
48 {
49 Cantor::Backend::Capabilities caps = Cantor::Backend::SyntaxHighlighting|Cantor::Backend::Completion;
50
51 // Latex output from sage sometimes correct, sometimes not, so allow disable typesetting, if user want it
52 if (SageSettings::self()->allowLatex())
53 caps |= Cantor::Backend::LaTexOutput;
54
55 return caps;
56 }
57
requirementsFullfilled(QString * const reason) const58 bool SageBackend::requirementsFullfilled(QString* const reason) const
59 {
60 const QString& path = SageSettings::self()->path().toLocalFile();
61 return Cantor::Backend::checkExecutable(QLatin1String("Sage"), path, reason);
62 }
63
settingsWidget(QWidget * parent) const64 QWidget* SageBackend::settingsWidget(QWidget* parent) const
65 {
66 return new SageSettingsWidget(parent, id());
67 }
68
config() const69 KConfigSkeleton* SageBackend::config() const
70 {
71 return SageSettings::self();
72 }
73
helpUrl() const74 QUrl SageBackend::helpUrl() const
75 {
76 return QUrl(i18nc("the url to the documentation of Sage, please check if there is a translated version and use the correct url",
77 "https://doc.sagemath.org/html/en/reference/index.html"));
78 }
79
description() const80 QString SageBackend::description() const
81 {
82 return i18n("<b>Sage</b> is a free open-source mathematics software system licensed under the GPL. <br/>" \
83 "It combines the power of many existing open-source packages into a common Python-based interface.");
84 }
85
86 K_PLUGIN_FACTORY_WITH_JSON(sagebackend, "sagebackend.json", registerPlugin<SageBackend>();)
87 #include "sagebackend.moc"
88