diff --git a/src/backendchoosedialog.cpp b/src/backendchoosedialog.cpp index e95b1c6d..5591bb85 100644 --- a/src/backendchoosedialog.cpp +++ b/src/backendchoosedialog.cpp @@ -1,100 +1,119 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --- Copyright (C) 2009 Alexander Rieder */ #include "backendchoosedialog.h" #include #include #include #include #include "lib/backend.h" #include "settings.h" const char* BackendChooseDialog::descriptionTemplate = I18N_NOOP("

%1

" \ "
Recommended version: %4

" \ "
%2

" \ "
See %3 for more information
"); +const char* BackendChooseDialog::requirementsTemplate= I18N_NOOP("

%1

" + "
Recommended version: %3

" + "
Some reqquirements for the backend don't fullfilled:
%2

"); BackendChooseDialog::BackendChooseDialog(QWidget* parent) : QDialog(parent) { QWidget* w=new QWidget(this); m_ui.setupUi(w); QGridLayout *layout = new QGridLayout; setLayout(layout); layout->addWidget(w); m_ui.backendList->setIconSize(QSize(KIconLoader::SizeMedium, KIconLoader::SizeMedium)); m_ui.backendList->setSortingEnabled(true); - connect(m_ui.backendList, &QListWidget::currentItemChanged, this, &BackendChooseDialog::updateDescription); + connect(m_ui.backendList, &QListWidget::currentItemChanged, this, &BackendChooseDialog::updateContent); connect(m_ui.backendList, &QListWidget::itemDoubleClicked, this, &BackendChooseDialog::accept); m_ui.buttonBox->button(QDialogButtonBox::Ok); m_ui.buttonBox->button(QDialogButtonBox::Ok)->setIcon(QApplication::style()->standardIcon(QStyle::SP_DialogOkButton)); m_ui.buttonBox->button(QDialogButtonBox::Cancel)->setIcon(QApplication::style()->standardIcon(QStyle::SP_DialogCancelButton)); foreach(Cantor::Backend* backend, Cantor::Backend::availableBackends()) { - if(!backend->isEnabled()) //don't show disabled backends - continue; + qDebug() << backend->name() << backend->isEnabled() << backend->requirementsFullfilled(); + if(!backend->isEnabled()) + if (backend->requirementsFullfilled()) + continue; QListWidgetItem* item=new QListWidgetItem(m_ui.backendList); item->setText(backend->name()); item->setIcon(QIcon::fromTheme(backend->icon())); m_ui.backendList->addItem(item); if(m_ui.backendList->currentItem() == nullptr) m_ui.backendList->setCurrentItem(item); if(backend->name()==Settings::self()->defaultBackend()) m_ui.backendList->setCurrentItem(item); } connect(m_ui.buttonBox, &QDialogButtonBox::accepted, this, &BackendChooseDialog::accept); connect(m_ui.buttonBox, &QDialogButtonBox::rejected, this, &BackendChooseDialog::close); connect(this, &BackendChooseDialog::accepted, this, &BackendChooseDialog::onAccept); } void BackendChooseDialog::onAccept() { m_backend=m_ui.backendList->currentItem()->text(); if(m_ui.makeDefault->isChecked()) { Settings::self()->setDefaultBackend(m_backend); Settings::self()->save(); } } -void BackendChooseDialog::updateDescription() +void BackendChooseDialog::updateContent() { Cantor::Backend* current=Cantor::Backend::getBackend( m_ui.backendList->currentItem()->text() ); if (current) { - const QString& desc = i18n(BackendChooseDialog::descriptionTemplate, - current->name(), current->description(), current->url(), current->version()); + QString desc; + QString reason; + if (current->requirementsFullfilled(&reason)) + { + desc = i18n(BackendChooseDialog::descriptionTemplate, + current->name(), current->description(), current->url(), current->version()); + m_ui.buttonBox->setEnabled(true); + m_ui.makeDefault->setEnabled(true); + } + else + { + desc = i18n(BackendChooseDialog::requirementsTemplate, + current->name(), reason, current->version()); + m_ui.buttonBox->setEnabled(false); + m_ui.makeDefault->setEnabled(false); + } m_ui.descriptionView->setHtml(desc); } } QString BackendChooseDialog::backendName() { return m_backend; } diff --git a/src/backendchoosedialog.h b/src/backendchoosedialog.h index 4c5b1f9f..b5e1d619 100644 --- a/src/backendchoosedialog.h +++ b/src/backendchoosedialog.h @@ -1,46 +1,47 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --- Copyright (C) 2009 Alexander Rieder */ #ifndef _BACKENDCHOOSEDIALOG_H #define _BACKENDCHOOSEDIALOG_H #include #include class BackendChooseDialog : public QDialog { Q_OBJECT public: explicit BackendChooseDialog( QWidget* parent); ~BackendChooseDialog() override = default; QString backendName(); protected Q_SLOTS: void onAccept(); - void updateDescription(); + void updateContent(); private: static const char* descriptionTemplate; + static const char* requirementsTemplate; Ui::BackendChooserBase m_ui; QString m_backend; }; #endif /* _BACKENDCHOOSEDIALOG_H */ diff --git a/src/backends/R/rbackend.cpp b/src/backends/R/rbackend.cpp index efeae8ef..afa6a079 100644 --- a/src/backends/R/rbackend.cpp +++ b/src/backends/R/rbackend.cpp @@ -1,116 +1,125 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --- Copyright (C) 2009 Alexander Rieder */ #include "rbackend.h" #include "rsession.h" #include "rextensions.h" #include "settings.h" #include "rsettingswidget.h" #include #include "cantor_macros.h" #include RBackend::RBackend(QObject* parent,const QList& args) : Cantor::Backend(parent, args) { setObjectName(QLatin1String("rbackend")); qDebug()<<"Creating RBackend"; new RScriptExtension(this); new RPlotExtension(this); new RVariableManagementExtension(this); } RBackend::~RBackend() { qDebug()<<"Destroying RBackend"; } QString RBackend::id() const { return QLatin1String("r"); } QString RBackend::version() const { return QLatin1String("Undefined"); } Cantor::Session* RBackend::createSession() { qDebug()<<"Spawning a new R session"; return new RSession(this); } Cantor::Backend::Capabilities RBackend::capabilities() const { qDebug()<<"Requesting capabilities of RSession"; Cantor::Backend::Capabilities cap= SyntaxHighlighting| Completion | InteractiveMode; if (RServerSettings::variableManagement()) cap |= VariableManagement; return cap; } -bool RBackend::requirementsFullfilled() const +bool RBackend::requirementsFullfilled(QString* const reason) const { QFileInfo info(QStandardPaths::findExecutable( QLatin1String("cantor_rserver") ) ); - return info.isExecutable(); + if (info.isExecutable()) + { + return true; + } + else + { + if (reason) + *reason = i18n("R backend uses special binary file - cantor_rserver (installed with R backend), which must be executable."); + return false; + } } QWidget* RBackend::settingsWidget(QWidget* parent) const { return new RSettingsWidget(parent); } KConfigSkeleton* RBackend::config() const { return RServerSettings::self(); } QUrl RBackend::helpUrl() const { const QUrl& localDoc = RServerSettings::self()->localDoc(); if (!localDoc.isEmpty()) return localDoc; else return QUrl(i18nc("the url to the documentation of R, please check if there is a translated version and use the correct url", "http://rwiki.sciviews.org/doku.php?id=rdoc:rdoc")); } QString RBackend::description() const { return i18n("R is a language and environment for statistical computing and graphics, similar to the S language and environment.
"\ "It provides a wide variety of statistical (linear and nonlinear modelling, "\ "classical statistical tests, time-series analysis, classification, clustering, ...) "\ "and graphical techniques, and is highly extensible. The S language is often the "\ "vehicle of choice for research in statistical methodology, "\ "and R provides an Open Source route to participation in that activity."); } K_PLUGIN_FACTORY_WITH_JSON(rbackend, "rbackend.json", registerPlugin();) #include "rbackend.moc" diff --git a/src/backends/R/rbackend.h b/src/backends/R/rbackend.h index c1277be7..5719592c 100644 --- a/src/backends/R/rbackend.h +++ b/src/backends/R/rbackend.h @@ -1,47 +1,47 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --- Copyright (C) 2009 Alexander Rieder */ #ifndef _RBACKEND_H #define _RBACKEND_H #include "backend.h" class RBackend : public Cantor::Backend { Q_OBJECT public: explicit RBackend(QObject* parent = nullptr, const QList& args = QList()); ~RBackend() override; QString id() const override; QString version() const override; Cantor::Session *createSession() override; Cantor::Backend::Capabilities capabilities() const override; - bool requirementsFullfilled() const override; + bool requirementsFullfilled(QString* const reason = nullptr) const override; QWidget* settingsWidget(QWidget* parent) const override; KConfigSkeleton* config() const override; QUrl helpUrl() const override; QString description() const override; }; #endif /* _RBACKEND_H */ diff --git a/src/backends/julia/juliabackend.cpp b/src/backends/julia/juliabackend.cpp index bd46f71d..a7beb186 100644 --- a/src/backends/julia/juliabackend.cpp +++ b/src/backends/julia/juliabackend.cpp @@ -1,114 +1,121 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --- Copyright (C) 2016 Ivan Lakhtanov */ #include "juliabackend.h" #include #include "juliasession.h" #include "ui_settings.h" #include "settings.h" #include "juliaextensions.h" JuliaBackend::JuliaBackend(QObject *parent, const QList &args) : Cantor::Backend(parent, args) { setEnabled(true); new JuliaVariableManagementExtension(this); new JuliaPackagingExtension(this); new JuliaPlotExtension(this); new JuliaScriptExtension(this); new JuliaLinearAlgebraExtension(this); } QString JuliaBackend::id() const { return QLatin1String("julia"); } QString JuliaBackend::version() const { return QLatin1String("1.0.0"); } Cantor::Session *JuliaBackend::createSession() { return new JuliaSession(this); } Cantor::Backend::Capabilities JuliaBackend::capabilities() const { Cantor::Backend::Capabilities cap= SyntaxHighlighting| Completion; if (JuliaSettings::variableManagement()) cap |= VariableManagement; return cap; } QString JuliaBackend::description() const { return i18n( "

Julia is a high-level, high-performance dynamic programming " "language for technical computing, with syntax that is familiar to " "users of other technical computing environments. It provides a " "sophisticated compiler, distributed parallel execution, numerical " "accuracy, and an extensive mathematical function library.

" ); } QUrl JuliaBackend::helpUrl() const { return QUrl(i18nc( "The url to the documentation of Julia, please check if there is a" " translated version and use the correct url", "http://docs.julialang.org/en/latest/" )); } -bool JuliaBackend::requirementsFullfilled() const +bool JuliaBackend::requirementsFullfilled(QString* const reason) const { - return QFileInfo( - JuliaSettings::self()->replPath().toLocalFile() - ).isExecutable(); + const QString& replPath = JuliaSettings::self()->replPath().toLocalFile(); + QFileInfo info(replPath); + if (info.isExecutable()) + return true; + else + { + if (reason) + *reason = i18n("Julia backend uses special binary file - %1 (installed with Julia backend), which must be executable").arg(replPath); + return false; + } } QWidget *JuliaBackend::settingsWidget(QWidget *parent) const { QWidget *widget = new QWidget(parent); Ui::JuliaSettingsBase s; s.setupUi(widget); return widget; } KConfigSkeleton *JuliaBackend::config() const { return JuliaSettings::self(); } K_PLUGIN_FACTORY_WITH_JSON( juliabackend, "juliabackend.json", registerPlugin(); ) #include "juliabackend.moc" diff --git a/src/backends/julia/juliabackend.h b/src/backends/julia/juliabackend.h index da301454..78425829 100644 --- a/src/backends/julia/juliabackend.h +++ b/src/backends/julia/juliabackend.h @@ -1,91 +1,91 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --- Copyright (C) 2016 Ivan Lakhtanov */ #pragma once #include "backend.h" /** * Backend for Julia language * * @see http://julialang.org/ * @see JuliaServer */ class JuliaBackend: public Cantor::Backend { Q_OBJECT public: /** * Constructs julia backend * * @param parent QObject parent. Defaults to nullptr. * @param args Additional arguments for the backend. * Defaults to QList(). */ explicit JuliaBackend( QObject *parent = nullptr, const QList &args = QList()); ~JuliaBackend() override = default; /** * @see Cantor::Backend::id */ QString id() const override; /** * @see Cantor::Backend::version */ QString version() const override; /** * @see Cantor::Backend::createSession */ Cantor::Session *createSession() override; /** * @see Cantor::Backend::capabilities */ Cantor::Backend::Capabilities capabilities() const override; /** * @see Cantor::Backend::description */ QString description() const override; /** * @see Cantor::Backend::helpUrl */ QUrl helpUrl() const override; /** * @see Cantor::Backend::requirementsFullfilled */ - bool requirementsFullfilled() const override; + bool requirementsFullfilled(QString* const reason = nullptr) const override; /** * @see Cantor::Backend::settingsWidget */ QWidget *settingsWidget(QWidget *parent) const override; /** * @see Cantor::Backend::config */ KConfigSkeleton *config() const override; }; diff --git a/src/backends/lua/luabackend.cpp b/src/backends/lua/luabackend.cpp index 557a8388..d43e9ee6 100644 --- a/src/backends/lua/luabackend.cpp +++ b/src/backends/lua/luabackend.cpp @@ -1,93 +1,109 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --- Copyright (C) 2014 Lucas Hermann Negri */ #include "luabackend.h" #include "luasession.h" #include "luaextensions.h" #include "cantor_macros.h" #include "settings.h" #include "ui_settings.h" #include LuaBackend::LuaBackend( QObject* parent,const QList args ) : Cantor::Backend( parent,args ) { setObjectName(QLatin1String("LuaBackend")); new LuaScriptExtension(this); } QString LuaBackend::id() const { return QLatin1String("lua"); } QString LuaBackend::version() const { return QLatin1String("LuaJIT 2.0"); } Cantor::Session* LuaBackend::createSession() { return new LuaSession(this); } Cantor::Backend::Capabilities LuaBackend::capabilities() const { Cantor::Backend::Capabilities cap = Cantor::Backend::SyntaxHighlighting | Cantor::Backend::Completion; return cap; } -bool LuaBackend::requirementsFullfilled() const +bool LuaBackend::requirementsFullfilled(QString* const reason) const { - return QFileInfo(LuaSettings::self()->path().toLocalFile()).isExecutable(); + const QString& replPath = LuaSettings::self()->path().toLocalFile(); + if (replPath.isEmpty()) + { + if (reason) + *reason = i18n("Lua backend needs installed Lua programming language. The backend often automatically founds needed Lua binary file, but not in this case. Please, go to Cantor settings and set path to Lua executable"); + return false; + } + + QFileInfo info(replPath); + if (info.isExecutable()) + return true; + else + { + if (reason) + *reason = i18n("In Lua backend settings a path to Lua binary file set as %1, but this file not executable. Do you sure, that this is correct path to Lua? Change this path in Cantor settings, if no.").arg(replPath); + return false; + } } QUrl LuaBackend::helpUrl() const { return QUrl(i18nc("Lua official documentation", "http://www.lua.org/docs.html")); } QString LuaBackend::description() const { return i18n("

Lua is a fast and lightweight scripting language, with a simple procedural syntax." \ " There are several libraries in Lua aimed at math and science.

" "

This backend supports luajit 2.

"); } QWidget* LuaBackend::settingsWidget(QWidget* parent) const { QWidget* widget = new QWidget(parent); Ui::LuaSettingsBase s; s.setupUi(widget); return widget; } KConfigSkeleton* LuaBackend::config() const { return LuaSettings::self(); } K_PLUGIN_FACTORY_WITH_JSON(luabackend, "luabackend.json", registerPlugin();) #include "luabackend.moc" diff --git a/src/backends/lua/luabackend.h b/src/backends/lua/luabackend.h index a22584b3..7d363422 100644 --- a/src/backends/lua/luabackend.h +++ b/src/backends/lua/luabackend.h @@ -1,48 +1,48 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --- Copyright (C) 2014 Lucas Hermann Negri */ #ifndef _LUABACKEND_H #define _LUABACKEND_H #include "backend.h" class LuaBackend : public Cantor::Backend { Q_OBJECT public: explicit LuaBackend( QObject* parent = nullptr, const QList args = QList()); ~LuaBackend() override = default; QString id() const override; QString version() const override; Cantor::Session* createSession() override; Cantor::Backend::Capabilities capabilities() const override; - bool requirementsFullfilled() const override; + bool requirementsFullfilled(QString* const reason = nullptr) const override; QUrl helpUrl() const override; QString description() const override; QWidget *settingsWidget(QWidget *parent) const override; KConfigSkeleton *config() const override; }; #endif /* _LUABACKEND_H */ diff --git a/src/backends/maxima/maximabackend.cpp b/src/backends/maxima/maximabackend.cpp index 9657d625..13fb9299 100644 --- a/src/backends/maxima/maximabackend.cpp +++ b/src/backends/maxima/maximabackend.cpp @@ -1,125 +1,140 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --- Copyright (C) 2009 Alexander Rieder */ #include "maximabackend.h" #include "maximasession.h" #include "settings.h" #include "ui_settings.h" #include "maximaextensions.h" #include #include #include "cantor_macros.h" MaximaBackend::MaximaBackend( QObject* parent,const QList args ) : Cantor::Backend( parent,args ) { setObjectName(QLatin1String("maximabackend")); qDebug()<<"Creating MaximaBackend"; //initialize the supported extensions new MaximaHistoryExtension(this); new MaximaScriptExtension(this); new MaximaCASExtension(this); new MaximaCalculusExtension(this); new MaximaLinearAlgebraExtension(this); new MaximaPlotExtension(this); new MaximaVariableManagementExtension(this); } MaximaBackend::~MaximaBackend() { qDebug()<<"Destroying MaximaBackend"; } QString MaximaBackend::id() const { return QLatin1String("maxima"); } QString MaximaBackend::version() const { return QLatin1String("5.41 and 5.42"); } Cantor::Session* MaximaBackend::createSession() { qDebug()<<"Spawning a new Maxima session"; return new MaximaSession(this); } Cantor::Backend::Capabilities MaximaBackend::capabilities() const { qDebug()<<"Requesting capabilities of MaximaSession"; Cantor::Backend::Capabilities cap= Cantor::Backend::LaTexOutput | Cantor::Backend::InteractiveMode| Cantor::Backend::SyntaxHighlighting| Cantor::Backend::Completion | Cantor::Backend::SyntaxHelp; if(MaximaSettings::self()->variableManagement()) cap|=Cantor::Backend::VariableManagement; return cap; } -bool MaximaBackend::requirementsFullfilled() const +bool MaximaBackend::requirementsFullfilled(QString* const reason) const { - QFileInfo info(MaximaSettings::self()->path().toLocalFile()); - return info.isExecutable(); + const QString& replPath = MaximaSettings::self()->path().toLocalFile(); + if (replPath.isEmpty()) + { + if (reason) + *reason = i18n("Maxima backend needs installed Maxima - a computer algebra system. The backend often automatically founds needed binary file, but not in this case. Please, go to Cantor settings and set path to Maxima executable"); + return false; + } + + QFileInfo info(replPath); + if (info.isExecutable()) + return true; + else + { + if (reason) + *reason = i18n("In Maxima backend settings a path to maxima binary file set as %1, but this file not executable. Do you sure, that this is correct path to Maxima? Change this path in Cantor settings, if no.").arg(replPath); + return false; + } } QUrl MaximaBackend::helpUrl() const { const QUrl& localDoc = MaximaSettings::self()->localDoc(); if (!localDoc.isEmpty()) return localDoc; else return QUrl(i18nc("the url to the documentation of Maxima, please check if there is a translated version and use the correct url", "http://maxima.sourceforge.net/docs/manual/en/maxima.html")); } QWidget* MaximaBackend::settingsWidget(QWidget* parent) const { QWidget* widget=new QWidget(parent); Ui::MaximaSettingsBase s; s.setupUi(widget); return widget; } KConfigSkeleton* MaximaBackend::config() const { return MaximaSettings::self(); } QString MaximaBackend::description() const { return i18n("Maxima is a system for the manipulation of symbolic and numerical expressions, "\ "including differentiation, integration, Taylor series, Laplace transforms, "\ "ordinary differential equations, systems of linear equations, polynomials, and sets, "\ "lists, vectors, matrices, and tensors. Maxima yields high precision numeric results "\ "by using exact fractions, arbitrary precision integers, and variable precision "\ "floating point numbers. Maxima can plot functions and data in two and three dimensions. "); } K_PLUGIN_FACTORY_WITH_JSON(maximabackend, "maximabackend.json", registerPlugin();) #include "maximabackend.moc" diff --git a/src/backends/maxima/maximabackend.h b/src/backends/maxima/maximabackend.h index a4dfaaa4..5f20eff7 100644 --- a/src/backends/maxima/maximabackend.h +++ b/src/backends/maxima/maximabackend.h @@ -1,47 +1,47 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --- Copyright (C) 2009 Alexander Rieder */ #ifndef _MAXIMABACKEND_H #define _MAXIMABACKEND_H #include "backend.h" class MaximaBackend : public Cantor::Backend { Q_OBJECT public: explicit MaximaBackend( QObject* parent = nullptr,const QList args = QList()); ~MaximaBackend() override; QString id() const override; QString version() const override; Cantor::Session *createSession() override; Cantor::Backend::Capabilities capabilities() const override; - bool requirementsFullfilled() const override; + bool requirementsFullfilled(QString* const reason = nullptr) const override; QUrl helpUrl() const override; QWidget* settingsWidget(QWidget* parent) const override; KConfigSkeleton* config() const override; QString description() const override; }; #endif /* _MAXIMABACKEND_H */ diff --git a/src/backends/octave/octavebackend.cpp b/src/backends/octave/octavebackend.cpp index 8076791c..ea5d4c59 100644 --- a/src/backends/octave/octavebackend.cpp +++ b/src/backends/octave/octavebackend.cpp @@ -1,104 +1,120 @@ /* Copyright (C) 2010 Miha Čančula This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "octavebackend.h" #include "octavesession.h" #include "octaveextensions.h" #include "settings.h" #include "cantor_macros.h" #include #include #include "ui_settings.h" OctaveBackend::OctaveBackend(QObject* parent, const QList& args): Backend(parent, args) { new OctaveHistoryExtension(this); new OctaveScriptExtension(this); new OctavePlotExtension(this); new OctaveLinearAlgebraExtension(this); new OctaveVariableManagementExtension(this); new OctavePackagingExtension(this); } QString OctaveBackend::id() const { return QLatin1String("octave"); } QString OctaveBackend::version() const { return QLatin1String("4.0 and 4.2"); } Cantor::Backend::Capabilities OctaveBackend::capabilities() const { Cantor::Backend::Capabilities cap= SyntaxHighlighting| Completion | SyntaxHelp; if (OctaveSettings::self()->variableManagement()) cap |= VariableManagement; return cap; } Cantor::Session* OctaveBackend::createSession() { return new OctaveSession(this); } -bool OctaveBackend::requirementsFullfilled() const +bool OctaveBackend::requirementsFullfilled(QString* const reason) const { - return QFileInfo(OctaveSettings::path().toLocalFile()).isExecutable(); + const QString& replPath = OctaveSettings::path().toLocalFile(); + if (replPath.isEmpty()) + { + if (reason) + *reason = i18n("Octave backend needs installed Octave programming language. The backend often automatically founds needed Octave binary file, but not in this case. Please, go to Cantor settings and set path to Octave binary file with command line interface (CLI)"); + return false; + } + + QFileInfo info(replPath); + if (info.isExecutable()) + return true; + else + { + if (reason) + *reason = i18n("In Octave backend settings a path to Octave binary file set as %1, but this file not executable. Do you sure, that this is correct path to Octave? Change this path in Cantor settings, if no.").arg(replPath); + return false; + } } QUrl OctaveBackend::helpUrl() const { const QUrl& localDoc = OctaveSettings::self()->localDoc(); if (!localDoc.isEmpty()) return localDoc; else return QUrl(i18nc("the url to the documentation of Octave, please check if there is a translated version (currently Czech and Japanese) and use the correct url", "http://www.gnu.org/software/octave/doc/interpreter/")); } QString OctaveBackend::description() const { return i18n("GNU Octave is a high-level language, primarily intended for numerical computations.
" "It provides a convenient command line interface for solving linear and nonlinear problems numerically, and for performing other numerical experiments using a language that is mostly compatible with Matlab."); } QWidget* OctaveBackend::settingsWidget(QWidget* parent) const { QWidget* widget = new QWidget(parent); Ui::OctaveSettingsBase ui; ui.setupUi(widget); return widget; } KConfigSkeleton* OctaveBackend::config() const { return OctaveSettings::self(); } K_PLUGIN_FACTORY_WITH_JSON(octavebackend, "octavebackend.json", registerPlugin();) #include "octavebackend.moc" diff --git a/src/backends/octave/octavebackend.h b/src/backends/octave/octavebackend.h index 39563e0c..e578e4d8 100644 --- a/src/backends/octave/octavebackend.h +++ b/src/backends/octave/octavebackend.h @@ -1,43 +1,43 @@ /* Copyright (C) 2010 Miha Čančula This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef CANTOR_OCTAVE_BACKEND_H #define CANTOR_OCTAVE_BACKEND_H #include class OctaveBackend : public Cantor::Backend { Q_OBJECT public: explicit OctaveBackend( QObject* parent = nullptr,const QList& args = QList()); ~OctaveBackend() override = default; QString id() const override; QString version() const override; Cantor::Backend::Capabilities capabilities() const override; Cantor::Session* createSession() override; - bool requirementsFullfilled() const override; + bool requirementsFullfilled(QString* const reason = nullptr) const override; QUrl helpUrl() const override; QString description() const override; QWidget* settingsWidget(QWidget* parent) const override; KConfigSkeleton* config() const override; }; #endif diff --git a/src/backends/sage/sagebackend.cpp b/src/backends/sage/sagebackend.cpp index 0e4b3679..a0fd0ede 100644 --- a/src/backends/sage/sagebackend.cpp +++ b/src/backends/sage/sagebackend.cpp @@ -1,110 +1,125 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --- Copyright (C) 2009 Alexander Rieder */ #include "sagebackend.h" #include "sagesession.h" #include "settings.h" #include "ui_settings.h" #include "sageextensions.h" #include "sagehighlighter.h" #include #include #include "cantor_macros.h" SageBackend::SageBackend( QObject* parent,const QList& args ) : Cantor::Backend( parent,args ) { setObjectName(QLatin1String("sagebackend")); qDebug()<<"Creating SageBackend"; //initialize the supported extensions new SageHistoryExtension(this); new SageScriptExtension(this); new SageCASExtension(this); new SageCalculusExtension(this); new SageLinearAlgebraExtension(this); new SagePlotExtension(this); new SagePackagingExtension(this); } SageBackend::~SageBackend() { qDebug()<<"Destroying SageBackend"; } QString SageBackend::id() const { return QLatin1String("sage"); } QString SageBackend::version() const { return QLatin1String("8.1 and 8.2"); } Cantor::Session* SageBackend::createSession() { qDebug()<<"Spawning a new Sage session"; return new SageSession(this); } Cantor::Backend::Capabilities SageBackend::capabilities() const { qDebug()<<"Requesting capabilities of SageSession"; //Disable Cantor::Backend::LaTexOutput, see sagesession.cpp:421 - return Cantor::Backend::SyntaxHighlighting|Cantor::Backend::Completion; + return Cantor::Backend::SyntaxHighlighting|Cantor::Backend::Completion; } -bool SageBackend::requirementsFullfilled() const +bool SageBackend::requirementsFullfilled(QString* const reason) const { - QFileInfo info(SageSettings::self()->path().toLocalFile()); - return info.isExecutable(); + const QString& replPath = SageSettings::self()->path().toLocalFile(); + if (replPath.isEmpty()) + { + if (reason) + *reason = i18n("Sage backend needs installed Sage programming language. The backend often automatically founds needed Sage binary file, but not in this case. Please, go to Cantor settings and set path to Sage executable"); + return false; + } + + QFileInfo info(replPath); + if (info.isExecutable()) + return true; + else + { + if (reason) + *reason = i18n("In Sage backend settings a path to Sage binary file set as %1, but this file not executable. Do you sure, that this is correct path to Sage? Change this path in Cantor settings, if no.").arg(replPath); + return false; + } } QWidget* SageBackend::settingsWidget(QWidget* parent) const { QWidget* widget=new QWidget(parent); Ui::SageSettingsBase s; s.setupUi(widget); return widget; } KConfigSkeleton* SageBackend::config() const { return SageSettings::self(); } QUrl SageBackend::helpUrl() const { return QUrl(i18nc("the url to the documentation of Sage, please check if there is a translated version and use the correct url", "http://www.sagemath.org/doc/reference/index.html")); } QString SageBackend::description() const { return i18n("Sage is a free open-source mathematics software system licensed under the GPL.
" \ "It combines the power of many existing open-source packages into a common Python-based interface."); } K_PLUGIN_FACTORY_WITH_JSON(sagebackend, "sagebackend.json", registerPlugin();) #include "sagebackend.moc" diff --git a/src/backends/sage/sagebackend.h b/src/backends/sage/sagebackend.h index 218b70eb..db9fa362 100644 --- a/src/backends/sage/sagebackend.h +++ b/src/backends/sage/sagebackend.h @@ -1,47 +1,47 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --- Copyright (C) 2009 Alexander Rieder */ #ifndef _SAGEBACKEND_H #define _SAGEBACKEND_H #include "backend.h" class SageBackend : public Cantor::Backend { Q_OBJECT public: explicit SageBackend( QObject* parent = nullptr, const QList& args = QList()); ~SageBackend() override; QString id() const override; QString version() const override; Cantor::Session *createSession() override; Cantor::Backend::Capabilities capabilities() const override; - bool requirementsFullfilled() const override; + bool requirementsFullfilled(QString* const reason = nullptr) const override; QWidget* settingsWidget(QWidget* parent) const override; KConfigSkeleton* config() const override; QUrl helpUrl() const override; QString description() const override; }; #endif /* _SAGEBACKEND_H */ diff --git a/src/backends/scilab/scilabbackend.cpp b/src/backends/scilab/scilabbackend.cpp index 57ff0124..3f12ee56 100644 --- a/src/backends/scilab/scilabbackend.cpp +++ b/src/backends/scilab/scilabbackend.cpp @@ -1,106 +1,121 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --- Copyright (C) 2011 Filipe Saraiva */ #include "scilabbackend.h" #include "scilabsession.h" #include "scilabextensions.h" #include "settings.h" #include "ui_settings.h" #include #include #include "cantor_macros.h" ScilabBackend::ScilabBackend(QObject* parent,const QList args) : Cantor::Backend(parent, args) { qDebug()<<"Creating ScilabBackend"; new ScilabVariableManagementExtension(this); new ScilabScriptExtension(this); setObjectName(QLatin1String("scilabbackend")); } ScilabBackend::~ScilabBackend() { qDebug()<<"Destroying ScilabBackend"; } QString ScilabBackend::id() const { return QLatin1String("scilab"); } QString ScilabBackend::version() const { return QLatin1String("5.5, 6.0"); } Cantor::Session* ScilabBackend::createSession() { qDebug()<<"Spawning a new Scilab session"; return new ScilabSession(this); } Cantor::Backend::Capabilities ScilabBackend::capabilities() const { qDebug()<<"Requesting capabilities of ScilabSession"; return Cantor::Backend::SyntaxHighlighting | Cantor::Backend::Completion | Cantor::Backend::VariableManagement; } -bool ScilabBackend::requirementsFullfilled() const +bool ScilabBackend::requirementsFullfilled(QString* const reason) const { - QFileInfo info(ScilabSettings::self()->path().toLocalFile()); - return info.isExecutable(); + const QString& replPath = ScilabSettings::self()->path().toLocalFile(); + if (replPath.isEmpty()) + { + if (reason) + *reason = i18n("Scilab backend needs installed Scilab programming language. The backend often automatically founds needed Scilab binary file, but not in this case. Please, go to Cantor settings and set path to Scilab executable"); + return false; + } + + QFileInfo info(replPath); + if (info.isExecutable()) + return true; + else + { + if (reason) + *reason = i18n("In Scilab backend settings a path to Scilab binary file set as %1, but this file not executable. Do you sure, that this is correct path to Scilab? Change this path in Cantor settings, if no.").arg(replPath); + return false; + } } QWidget* ScilabBackend::settingsWidget(QWidget* parent) const { QWidget* widget=new QWidget(parent); Ui::ScilabSettingsBase s; s.setupUi(widget); return widget; } KConfigSkeleton* ScilabBackend::config() const { return ScilabSettings::self(); } QUrl ScilabBackend::helpUrl() const { return QUrl(i18nc("the url to the documentation of Scilab, please check if there is a translated version and use the correct url", "http://www.scilab.org/support/documentation")); } QString ScilabBackend::description() const { return i18n("

Scilab is a free software, cross-platform numerical computational package and a high-level, numerically oriented programming language.

" \ "Scilab is distributed under CeCILL license (GPL compatible)"); } K_PLUGIN_FACTORY_WITH_JSON(scilabbackend, "scilabbackend.json", registerPlugin();) #include "scilabbackend.moc" diff --git a/src/backends/scilab/scilabbackend.h b/src/backends/scilab/scilabbackend.h index e0b1e463..b0ef0137 100644 --- a/src/backends/scilab/scilabbackend.h +++ b/src/backends/scilab/scilabbackend.h @@ -1,47 +1,47 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --- Copyright (C) 2011 Filipe Saraiva */ #ifndef _SCILABBACKEND_H #define _SCILABBACKEND_H #include "backend.h" class ScilabBackend : public Cantor::Backend { Q_OBJECT - + public: explicit ScilabBackend( QObject* parent = nullptr,const QList args = QList()); ~ScilabBackend() override; QString id() const override; QString version() const override; Cantor::Session *createSession() override; Cantor::Backend::Capabilities capabilities() const override; - bool requirementsFullfilled() const override; + bool requirementsFullfilled(QString* const reason = nullptr) const override; QWidget* settingsWidget(QWidget* parent) const override; KConfigSkeleton* config() const override; QUrl helpUrl() const override; QString description() const override; }; #endif /* _SCILABBACKEND_H */ diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index a9956219..027ebdac 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -1,99 +1,99 @@ set( cantor_LIB_SRCS session.cpp expression.cpp backend.cpp result.cpp textresult.cpp imageresult.cpp epsresult.cpp latexresult.cpp latexrenderer.cpp helpresult.cpp animationresult.cpp extension.cpp assistant.cpp completionobject.cpp syntaxhelpobject.cpp defaulthighlighter.cpp defaultvariablemodel.cpp panelplugin.cpp panelpluginhandler.cpp worksheetaccess.cpp directives/plotdirectives.cpp ) Set( cantor_LIB_HDRS cantor_macros.h #base classes backend.h session.h expression.h extension.h syntaxhelpobject.h completionobject.h #results animationresult.h epsresult.h helpresult.h imageresult.h latexresult.h result.h textresult.h #helper classes defaulthighlighter.h defaultvariablemodel.h worksheetaccess.h ) ki18n_wrap_ui(cantor_LIB_SRCS directives/axisrange.ui directives/plottitle.ui) kconfig_add_kcfg_files(cantor_LIB_SRCS settings.kcfgc) install(FILES cantor_libs.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR}) configure_file (config-cantorlib.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-cantorlib.h ) add_library( cantorlibs SHARED ${cantor_LIB_SRCS} ) generate_export_header(cantorlibs BASE_NAME cantor) kcoreaddons_desktop_to_json(cantorlibs cantor_assistant.desktop DEFAULT_SERVICE_TYPE) kcoreaddons_desktop_to_json(cantorlibs cantor_backend.desktop DEFAULT_SERVICE_TYPE) kcoreaddons_desktop_to_json(cantorlibs cantor_panelplugin.desktop DEFAULT_SERVICE_TYPE) target_link_libraries( cantorlibs KF5::Completion KF5::IconThemes KF5::KIOCore KF5::KIOFileWidgets KF5::KIOWidgets KF5::Archive KF5::ConfigCore KF5::ConfigGui KF5::I18n KF5::XmlGui ${QT5_LIBRARIES} Qt5::Xml ) -set (CANTORLIBS_SOVERSION 20) +set (CANTORLIBS_SOVERSION 21) set_target_properties( cantorlibs PROPERTIES VERSION ${KDE_APPLICATIONS_VERSION} SOVERSION ${CANTORLIBS_SOVERSION}) ecm_setup_version(${KDE_APPLICATIONS_VERSION} VARIABLE_PREFIX CANTOR SOVERSION ${CANTORLIBS_SOVERSION} VERSION_HEADER ${CMAKE_CURRENT_BINARY_DIR}/cantorlibs_version.h ) install( TARGETS cantorlibs EXPORT CantorTargets ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} ) install( FILES ${cantor_LIB_HDRS} ${CMAKE_CURRENT_BINARY_DIR}/cantor_export.h ${CMAKE_CURRENT_BINARY_DIR}/cantorlibs_version.h DESTINATION ${KDE_INSTALL_INCLUDEDIR}/cantor COMPONENT Devel ) if(BUILD_TESTING) add_subdirectory(test) endif() diff --git a/src/lib/backend.cpp b/src/lib/backend.cpp index 261d9f7b..3056926e 100644 --- a/src/lib/backend.cpp +++ b/src/lib/backend.cpp @@ -1,206 +1,207 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --- Copyright (C) 2009 Alexander Rieder */ #include "backend.h" using namespace Cantor; #include #include #include #include #include #include #include #include #include "extension.h" class Cantor::BackendPrivate { public: QString name; QString comment; QString icon; QString url; bool enabled; }; Backend::Backend(QObject* parent, const QList& args) : QObject(parent), d(new BackendPrivate) { Q_UNUSED(args) d->enabled=true; } Backend::~Backend() { delete d; } QString Backend::name() const { return d->name; } QString Backend::comment() const { return d->comment; } QString Backend::description() const { return comment(); } QString Backend::icon() const { return d->icon; } QString Backend::version() const { return QLatin1String(); } QString Backend::url() const { return d->url; } QUrl Backend::helpUrl() const { return QUrl(); } bool Backend::isEnabled() const { return d->enabled&&requirementsFullfilled(); } void Backend::setEnabled(bool enabled) { d->enabled=enabled; } QStringList Backend::listAvailableBackends() { QList backends=availableBackends(); QStringList l; foreach(Backend* b, backends) { if(b->isEnabled()) l<name(); } return l; } QList Backend::availableBackends() { static QList backendCache; //if we already have all backends Cached, just return the cache. //otherwise create the available backends if(!backendCache.isEmpty()) { return backendCache; } QStringList pluginDirs; foreach(const QString &dir, QCoreApplication::libraryPaths()){ pluginDirs << dir + QDir::separator() + QLatin1String("cantor/backends"); } QPluginLoader loader; foreach(const QString &dir, pluginDirs){ qDebug() << "dir: " << dir; QStringList plugins; QDir pluginDir = QDir(dir); plugins = pluginDir.entryList(); foreach (const QString &plugin, plugins){ if (plugin==QLatin1String(".") || plugin==QLatin1String("..")) continue; loader.setFileName(dir + QDir::separator() + plugin); if (!loader.load()){ qDebug() << "Error while loading plugin: " << plugin; continue; } KPluginFactory* factory = KPluginLoader(loader.fileName()).factory(); Backend* backend = factory->create(); KPluginMetaData info(loader); backend->d->name=info.name(); backend->d->comment=info.description(); backend->d->icon=info.iconName(); backend->d->url=info.website(); backendCache< backends=availableBackends(); foreach(Backend* b, backends) { if(b->name().toLower()==name.toLower() || b->id().toLower()==name.toLower()) return b; } return nullptr; } QWidget* Backend::settingsWidget(QWidget* parent) const { Q_UNUSED(parent) return nullptr; } KConfigSkeleton* Backend::config() const { return nullptr; } QStringList Backend::extensions() const { QList extensions=findChildren(QRegExp(QLatin1String(".*Extension"))); QStringList names; foreach(Extension* e, extensions) names<objectName(); return names; } Extension* Backend::extension(const QString& name) const { return findChild(name); } -bool Backend::requirementsFullfilled() const +bool Backend::requirementsFullfilled(QString* const reason) const { + Q_UNUSED(reason); return true; } diff --git a/src/lib/backend.h b/src/lib/backend.h index 981bc594..ce1c8d75 100644 --- a/src/lib/backend.h +++ b/src/lib/backend.h @@ -1,218 +1,219 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --- Copyright (C) 2009 Alexander Rieder */ #ifndef _BACKEND_H #define _BACKEND_H #include #include #include #include #include "cantor_export.h" class KConfigSkeleton; class QWidget; /** * Namespace collecting all Classes of the Cantor Libraries */ namespace Cantor { class Session; class Extension; class BackendPrivate; /** * The Backend class provides access to information about the backend. * It provides access to what features are supported by the backend, and * a factory method to create a new Session * It needs to be subclassed by all Backends. * * @author Alexander Rieder */ class CANTOR_EXPORT Backend : public QObject, public KXMLGUIClient { Q_OBJECT public: /** * This enum is used to specify the Features, supported by a backend. */ enum Capability{ Nothing = 0x0, ///< the Backend doesn't support any of the optional features LaTexOutput = 0x1, ///< it can output results as LaTeX code InteractiveMode = 0x2, /**< it supports an interactive workflow. (It means a command can ask for additional input while running */ SyntaxHighlighting = 0x4, ///< it offers a custom Syntax Highlighter Completion = 0x8, ///< it offers completion of partially typed commands SyntaxHelp = 0x10, /**< it offers help about a commands syntax, that will be shown in a tooltip */ VariableManagement= 0x20 ///< it offers access to the variables (for variable management panel) }; Q_DECLARE_FLAGS(Capabilities, Capability) protected: /** * Create a new Backend. Normally the static createBackend factory method * should be used. * @param parent the Parent object * @param args optional arguments (not used) */ explicit Backend( QObject* parent = nullptr,const QList& args=QList() ); /** * Destructor. Doesn't anything. */ ~Backend() override; public: /** * Creates a new Session. It is the way to go to create a Session, * don't call new Session on your own. * @return a new Session of this Backend, or 0 if creating failed */ virtual Session* createSession() = 0; /** * Returns list of the supported optional features * @return a list of features, containing items of the Capability enum, ORed together */ virtual Capabilities capabilities() const = 0; /** * Returns whether all of this backends requirements are fulfilled, or if some are missing. + * @param reason if set, backend write information about missing requirements, if they exists * @return @c true if all the requirements needed to use this Backend are fulfilled * @return @c false some requirements are missing. e.g. the maxima executable can not be found * @see Capability */ - virtual bool requirementsFullfilled() const; + virtual bool requirementsFullfilled(QString* const reason = nullptr) const; /** * Returns a unique string to identify this backend. * In contrast to name() this string isn't translated * @return string to identify backend */ virtual QString id() const = 0; /** * Returns the recommended version of the backend supported by Cantor * @return the recommended version of the backend */ virtual QString version() const; //Stuff extracted from the .desktop file /** * Returns the name of the backend * @return the backends name */ QString name() const; /** * Returns a short comment about the backend. * @return comment about the backend */ QString comment() const; /** * Returns the icon to use with this backend * @return name of the icon */ QString icon() const; /** * Returns the Url of the Homepage for the Backend * @return the url */ QString url() const; /** * Returns an Url pointing to the Help of the Backend * The method should be overwritten by all Backends(who have an online help) * You should make the returned Url translateble, e.g. by doing something like: * return i18nc("the url to the documentation of KAlgebra, please check if there is a translated version and use the correct url", * "http://docs.kde.org/stable/en/kdeedu/kalgebra/"); * @return Url of the help */ virtual QUrl helpUrl() const; /** * Returns if the backend should be enabled (shown in the Backend dialog) * @return @c true, if the enabled flag is set to true, and the requirements are fulfilled * @return @c false, if the backend was purposly disabled, or requirements are missing * @see requirementsFullfilled() */ bool isEnabled() const; /** * Enables/disables this backend * @param enabled true to enable backend false to disable */ void setEnabled(bool enabled); /** * Returns a longer description of the Backend, e.g. purpose, strengths etc. * It should help the user to decide between the different Backends * @return a description of the backend. It can contain html */ virtual QString description() const; /** * Returns a Widget for configuring this backend * @return Widget for usage in the Settings dialog */ virtual QWidget* settingsWidget(QWidget* parent) const; /** * Returns a KConfig object, containing all the settings, * the backend might need * @return a KConfigSkeleton object, for configuring this backend */ virtual KConfigSkeleton* config() const; /** * Returns a list of the names of all the Extensions supported by this backend * @return a list of the names of all the Extensions supported by this backend * @see extension(const QString& name) */ QStringList extensions() const; /** * Returns an Extension of this backend for the given name, or null * if the Backend doesn't have an extension with this name. * @return Pointer to the Extension object with the given name */ Extension * extension(const QString& name) const; /** * Returns a list of the names of all the installed and enabled backends * @return a list of the names of all the installed and enabled backends * @see isEnabled() */ static QStringList listAvailableBackends(); /** * Returns Pointers to all the installed backends * @return Pointers to all the installed backends */ static QList availableBackends(); /** * Returns the backend with the given name, or null if it isn't found * @return the backend with the given name, or null if it isn't found */ static Backend* getBackend(const QString& name); private: BackendPrivate* d; }; Q_DECLARE_OPERATORS_FOR_FLAGS(Backend::Capabilities) } #endif /* _BACKEND_H */