File indexing completed on 2024-04-28 11:20:41

0001 /*
0002     SPDX-License-Identifier: GPL-2.0-or-later
0003     SPDX-FileCopyrightText: 2009 Alexander Rieder <alexanderrieder@gmail.com>
0004     SPDX-FileCopyrightText: 2019 Alexander Semke <alexander.semke@web.de>
0005 */
0006 
0007 #include "sagebackend.h"
0008 #include "sageextensions.h"
0009 #include "sagesession.h"
0010 #include "sagesettingswidget.h"
0011 #include "settings.h"
0012 
0013 #include <KPluginFactory>
0014 
0015 SageBackend::SageBackend( QObject* parent,const QList<QVariant>& args ) : Cantor::Backend( parent,args )
0016 {
0017     //initialize the supported extensions
0018     new SageHistoryExtension(this);
0019     new SageScriptExtension(this);
0020     new SageCASExtension(this);
0021     new SageCalculusExtension(this);
0022     new SageLinearAlgebraExtension(this);
0023     new SagePlotExtension(this);
0024     new SagePackagingExtension(this);
0025 }
0026 
0027 SageBackend::~SageBackend()
0028 {
0029     qDebug()<<"Destroying SageBackend";
0030 }
0031 
0032 QString SageBackend::id() const
0033 {
0034     return QLatin1String("sage");
0035 }
0036 
0037 QString SageBackend::version() const
0038 {
0039     return QLatin1String("9.5");
0040 }
0041 
0042 Cantor::Session* SageBackend::createSession()
0043 {
0044     qDebug()<<"Spawning a new Sage session";
0045 
0046     return new SageSession(this);
0047 }
0048 
0049 Cantor::Backend::Capabilities SageBackend::capabilities() const
0050 {
0051     Cantor::Backend::Capabilities caps = Cantor::Backend::SyntaxHighlighting|Cantor::Backend::Completion;
0052 
0053     // Latex output from sage sometimes correct, sometimes not, so allow disable typesetting, if user want it
0054     if (SageSettings::self()->allowLatex())
0055         caps |= Cantor::Backend::LaTexOutput;
0056 
0057     return caps;
0058 }
0059 
0060 bool SageBackend::requirementsFullfilled(QString* const reason) const
0061 {
0062     const QString& path = SageSettings::self()->path().toLocalFile();
0063     return Cantor::Backend::checkExecutable(QLatin1String("Sage"), path, reason);
0064 }
0065 
0066 QWidget* SageBackend::settingsWidget(QWidget* parent) const
0067 {
0068     return new SageSettingsWidget(parent, id());
0069 }
0070 
0071 KConfigSkeleton* SageBackend::config() const
0072 {
0073     return SageSettings::self();
0074 }
0075 
0076 QUrl SageBackend::helpUrl() const
0077 {
0078     return QUrl(i18nc("the url to the documentation of Sage, please check if there is a translated version and use the correct url",
0079                  "https://doc.sagemath.org/html/en/reference/index.html"));
0080 }
0081 
0082 QString SageBackend::description() const
0083 {
0084     return i18n("<b>Sage</b> is a free open-source mathematics software system licensed under the GPL. <br/>" \
0085                 "It combines the power of many existing open-source packages into a common Python-based interface.");
0086 }
0087 
0088 K_PLUGIN_FACTORY_WITH_JSON(sagebackend, "sagebackend.json", registerPlugin<SageBackend>();)
0089 #include "sagebackend.moc"