1 /* 2 SPDX-License-Identifier: GPL-2.0-or-later 3 SPDX-FileCopyrightText: 2012 Filipe Saraiva <filipe@kde.org> 4 */ 5 6 #include "pythonbackend.h" 7 #include "pythonsession.h" 8 #include "pythonextensions.h" 9 #include "pythonsettingswidget.h" 10 #include "settings.h" 11 #include "ui_settings.h" 12 13 #include <QDebug> 14 #include <QWidget> 15 PythonBackend(QObject * parent,const QList<QVariant> & args)16PythonBackend::PythonBackend(QObject* parent, const QList<QVariant>& args) : Cantor::Backend(parent, args) 17 { 18 new PythonLinearAlgebraExtension(this); 19 new PythonPackagingExtension(this); 20 new PythonPlotExtension(this); 21 new PythonScriptExtension(this); 22 new PythonVariableManagementExtension(this); 23 24 //setObjectName(QLatin1String("python3backend")); 25 } 26 settingsWidget(QWidget * parent) const27QWidget* PythonBackend::settingsWidget(QWidget* parent) const 28 { 29 return new PythonSettingsWidget(parent, id()); 30 } 31 createSession()32Cantor::Session* PythonBackend::createSession() 33 { 34 return new PythonSession(this); 35 } 36 id() const37QString PythonBackend::id() const 38 { 39 return QLatin1String("python"); 40 } 41 version() const42QString PythonBackend::version() const 43 { 44 return QLatin1String("3.6"); 45 } 46 capabilities() const47Cantor::Backend::Capabilities PythonBackend::capabilities() const 48 { 49 qDebug()<<"Requesting capabilities of PythonSession"; 50 51 Backend::Capabilities cap = 52 Cantor::Backend::SyntaxHighlighting | 53 Cantor::Backend::Completion | 54 Cantor::Backend::SyntaxHelp | 55 Cantor::Backend::IntegratedPlots; 56 57 if(PythonSettings::variableManagement()) 58 cap |= Cantor::Backend::VariableManagement; 59 60 return cap; 61 } 62 helpUrl() const63QUrl PythonBackend::helpUrl() const 64 { 65 return QUrl(i18nc("The url to the documentation Python", "https://docs.python.org/3/")); 66 } 67 description() const68QString PythonBackend::description() const 69 { 70 return i18n("<b>Python</b> is a remarkably powerful dynamic programming language that is used in a wide variety of application domains. " \ 71 "There are several Python packages to scientific programming."); 72 } 73 config() const74KConfigSkeleton* PythonBackend::config() const 75 { 76 return PythonSettings::self(); 77 } 78 requirementsFullfilled(QString * const reason) const79bool PythonBackend::requirementsFullfilled(QString* const reason) const 80 { 81 #ifdef Q_OS_WIN 82 const QString& path = QStandardPaths::findExecutable(QLatin1String("cantor_pythonserver.exe")); 83 #else 84 const QString& path = QStandardPaths::findExecutable(QLatin1String("cantor_pythonserver")); 85 #endif 86 return Cantor::Backend::checkExecutable(QLatin1String("Cantor Python Server"), path, reason); 87 } 88 89 K_PLUGIN_FACTORY_WITH_JSON(pythonbackend, "pythonbackend.json", registerPlugin<PythonBackend>();) 90 #include "pythonbackend.moc" 91 92