File indexing completed on 2023-05-30 09:03:12
0001 /* 0002 SPDX-License-Identifier: GPL-2.0-or-later 0003 SPDX-FileCopyrightText: 2012 Filipe Saraiva <filipe@kde.org> 0004 */ 0005 0006 #include "pythonbackend.h" 0007 #include "pythonsession.h" 0008 #include "pythonextensions.h" 0009 #include "pythonsettingswidget.h" 0010 #include "settings.h" 0011 #include "ui_settings.h" 0012 0013 #include <QDebug> 0014 #include <QWidget> 0015 0016 #include <KPluginFactory> 0017 0018 PythonBackend::PythonBackend(QObject* parent, const QList<QVariant>& args) : Cantor::Backend(parent, args) 0019 { 0020 new PythonLinearAlgebraExtension(this); 0021 new PythonPackagingExtension(this); 0022 new PythonPlotExtension(this); 0023 new PythonScriptExtension(this); 0024 new PythonVariableManagementExtension(this); 0025 0026 //setObjectName(QLatin1String("python3backend")); 0027 } 0028 0029 QWidget* PythonBackend::settingsWidget(QWidget* parent) const 0030 { 0031 return new PythonSettingsWidget(parent, id()); 0032 } 0033 0034 Cantor::Session* PythonBackend::createSession() 0035 { 0036 return new PythonSession(this); 0037 } 0038 0039 QString PythonBackend::id() const 0040 { 0041 return QLatin1String("python"); 0042 } 0043 0044 QString PythonBackend::version() const 0045 { 0046 return QLatin1String("3.6"); 0047 } 0048 0049 Cantor::Backend::Capabilities PythonBackend::capabilities() const 0050 { 0051 qDebug()<<"Requesting capabilities of PythonSession"; 0052 0053 Backend::Capabilities cap = 0054 Cantor::Backend::SyntaxHighlighting | 0055 Cantor::Backend::Completion | 0056 Cantor::Backend::SyntaxHelp | 0057 Cantor::Backend::IntegratedPlots; 0058 0059 if(PythonSettings::variableManagement()) 0060 cap |= Cantor::Backend::VariableManagement; 0061 0062 return cap; 0063 } 0064 0065 QUrl PythonBackend::helpUrl() const 0066 { 0067 return QUrl(i18nc("The url to the documentation Python", "https://docs.python.org/3/")); 0068 } 0069 0070 QString PythonBackend::description() const 0071 { 0072 return i18n("<b>Python</b> is a remarkably powerful dynamic programming language that is used in a wide variety of application domains. " \ 0073 "There are several Python packages to scientific programming."); 0074 } 0075 0076 KConfigSkeleton* PythonBackend::config() const 0077 { 0078 return PythonSettings::self(); 0079 } 0080 0081 bool PythonBackend::requirementsFullfilled(QString* const reason) const 0082 { 0083 #ifdef Q_OS_WIN 0084 const QString& path = QStandardPaths::findExecutable(QLatin1String("cantor_pythonserver.exe")); 0085 #else 0086 const QString& path = QStandardPaths::findExecutable(QLatin1String("cantor_pythonserver")); 0087 #endif 0088 return Cantor::Backend::checkExecutable(QLatin1String("Cantor Python Server"), path, reason); 0089 } 0090 0091 K_PLUGIN_FACTORY_WITH_JSON(pythonbackend, "pythonbackend.json", registerPlugin<PythonBackend>();) 0092 #include "pythonbackend.moc" 0093