File indexing completed on 2024-05-26 11:22:03

0001 /*
0002     SPDX-License-Identifier: GPL-2.0-or-later
0003     SPDX-FileCopyrightText: 2016 Ivan Lakhtanov <ivan.lakhtanov@gmail.com>
0004     SPDX-FileCopyrightText: 2019-2023 Alexander Semke <alexander.semke@web.de>
0005 */
0006 
0007 #include "juliabackend.h"
0008 #include "juliaextensions.h"
0009 #include "juliasession.h"
0010 #include "juliasettingswidget.h"
0011 #include "settings.h"
0012 
0013 #include <KPluginFactory>
0014 
0015 JuliaBackend::JuliaBackend(QObject *parent, const QList<QVariant> &args)
0016     : Cantor::Backend(parent, args)
0017 {
0018     setEnabled(true);
0019 
0020     new JuliaVariableManagementExtension(this);
0021     new JuliaPackagingExtension(this);
0022     new JuliaPlotExtension(this);
0023     new JuliaScriptExtension(this);
0024     new JuliaLinearAlgebraExtension(this);
0025 }
0026 
0027 QString JuliaBackend::id() const
0028 {
0029     return QLatin1String("julia");
0030 }
0031 
0032 QString JuliaBackend::version() const
0033 {
0034     return QLatin1String("1.6.7");
0035 }
0036 
0037 Cantor::Session *JuliaBackend::createSession()
0038 {
0039     return new JuliaSession(this);
0040 }
0041 
0042 Cantor::Backend::Capabilities JuliaBackend::capabilities() const
0043 {
0044     Cantor::Backend::Capabilities cap = SyntaxHighlighting | Completion | IntegratedPlots;
0045 
0046     if (JuliaSettings::variableManagement())
0047         cap |= VariableManagement;
0048 
0049     return cap;
0050 }
0051 
0052 QString JuliaBackend::description() const
0053 {
0054     return i18n(
0055         "<b>Julia</b> is a high-level, high-performance dynamic programming "
0056         "language for technical computing, with syntax that is familiar to "
0057         "users of other technical computing environments. It provides a "
0058         "sophisticated compiler, distributed parallel execution, numerical "
0059         "accuracy, and an extensive mathematical function library."
0060     );
0061 }
0062 
0063 QUrl JuliaBackend::helpUrl() const
0064 {
0065     return QUrl(i18nc(
0066         "The url to the documentation of Julia, please check if there is a"
0067         " translated version and use the correct url",
0068         "https://docs.julialang.org/en/latest/"
0069     ));
0070 }
0071 
0072 bool JuliaBackend::requirementsFullfilled(QString* const reason) const
0073 {
0074 #ifdef Q_OS_WIN
0075     const QString& path = QStandardPaths::findExecutable(QLatin1String("cantor_juliaserver.exe"));
0076 #else
0077     const QString& path = QStandardPaths::findExecutable(QLatin1String("cantor_juliaserver"));
0078 #endif
0079     return Cantor::Backend::checkExecutable(QLatin1String("Cantor Julia Server"), path, reason);
0080 }
0081 
0082 QWidget* JuliaBackend::settingsWidget(QWidget *parent) const
0083 {
0084     return new JuliaSettingsWidget(parent, id());
0085 }
0086 
0087 KConfigSkeleton* JuliaBackend::config() const
0088 {
0089     return JuliaSettings::self();
0090 }
0091 
0092 K_PLUGIN_FACTORY_WITH_JSON(
0093     juliabackend,
0094     "juliabackend.json",
0095     registerPlugin<JuliaBackend>();
0096 )
0097 
0098 #include "juliabackend.moc"