Commit 114318a0 authored by Nikita Sirgienko's avatar Nikita Sirgienko

Fix problems with founding cantor files in Labplot2

parent 84ac5a36
......@@ -24,14 +24,18 @@
inline QString loadScript(const QString &scriptName)
{
QFile text(
QStandardPaths::locate(
QStandardPaths::GenericDataLocation,
QString::fromLatin1(
"cantor/juliabackend/scripts/%1.jl"
).arg(scriptName)
)
QString file = QStandardPaths::locate(
QStandardPaths::AppDataLocation,
QString::fromLatin1("juliabackend/scripts/%1.jl").arg(scriptName)
);
if (file.isEmpty())
file = QStandardPaths::locate(
QStandardPaths::GenericDataLocation,
QString::fromLatin1("cantor/juliabackend/scripts/%1.jl").arg(scriptName)
);
QFile text(file);
text.open(QIODevice::ReadOnly);
return QString::fromLatin1(text.readAll());
}
......@@ -64,7 +64,7 @@ void MaximaSession::login()
emit loginStarted();
QStringList arguments;
arguments << QLatin1String("--quiet"); //Suppress Maxima start-up message
const QString initFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("cantor/maximabackend/cantor-initmaxima.lisp"));
const QString initFile = locateCantorFile(QLatin1String("maximabackend/cantor-initmaxima.lisp"));
arguments << QLatin1String("--init-lisp=") + initFile; //Set the name of the Lisp initialization file
m_process = new QProcess(this);
......
......@@ -126,7 +126,7 @@ void SageSession::login()
m_process->setProgram(sageExecFile, QStringList() << QLatin1String("--simple-prompt"));
else
{
const QString& sageStartScript = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("cantor/sagebackend/cantor-execsage"));
const QString& sageStartScript = locateCantorFile(QLatin1String("sagebackend/cantor-execsage"));
m_process->setProgram(sageStartScript, QStringList(sageExecFile));
}
......
......@@ -197,3 +197,13 @@ int Session::nextExpressionId()
{
return d->expressionCount++;
}
QString Session::locateCantorFile(const QString& partialPath, QStandardPaths::LocateOptions options)
{
QString file = QStandardPaths::locate(QStandardPaths::AppDataLocation, partialPath, options);
if (file.isEmpty())
file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("cantor/") + partialPath, options);
return file;
}
......@@ -22,6 +22,7 @@
#define _SESSION_H
#include <QObject>
#include <QStandardPaths>
#include "cantor_export.h"
......@@ -242,6 +243,11 @@ class CANTOR_EXPORT Session : public QObject
*/
void setVariableModel(DefaultVariableModel* model);
/**
* Search file for session in AppDataLocation and in GenericDataLocation
*/
QString locateCantorFile(const QString& partialPath, QStandardPaths::LocateOptions options = QStandardPaths::LocateFile);
Q_SIGNALS:
void statusChanged(Cantor::Session::Status newStatus);
void loginStarted();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment