Commit bdcc740e authored by Shubham  .'s avatar Shubham .
Browse files

Include session in DocumentationPanel

parent 3782766d
add_subdirectory(maxima)
add_subdirectory(Maxima)
......@@ -19,6 +19,7 @@
*/
#include "documentationpanelplugin.h"
#include "session.h"
DocumentationPanelPlugin::DocumentationPanelPlugin(QObject* parent, QList<QVariant> args) : Cantor::PanelPlugin(parent), m_widget(nullptr)
{
......@@ -30,11 +31,17 @@ DocumentationPanelPlugin::~DocumentationPanelPlugin()
delete m_widget;
}
void DocumentationPanelPlugin::onSessionChanged()
{
if(m_widget)
m_widget->setSession(session());
}
QWidget* DocumentationPanelPlugin::widget()
{
if(!m_widget)
{
m_widget = new DocumentationPanelWidget(parentWidget());
m_widget = new DocumentationPanelWidget(session(), parentWidget());
connect(parent()->parent(), SIGNAL(requestDocumentation(QString)), m_widget, SLOT(contextSensitiveHelp(QString)));
connect(parent()->parent(), SIGNAL(requestDocumentation(QString)), this, SIGNAL(visibilityRequested()));
}
......
......@@ -37,6 +37,9 @@ class DocumentationPanelPlugin : public Cantor::PanelPlugin
bool showOnStartup() override;
protected:
void onSessionChanged() override;
private:
QPointer<DocumentationPanelWidget> m_widget;
};
......
......@@ -20,6 +20,7 @@
#include "cantor_macros.h"
#include "documentationpanelplugin.h"
#include "session.h"
#include <KLocalizedString>
......@@ -41,10 +42,11 @@
#include <QWebEngineView>
#include <QWidget>
DocumentationPanelWidget::DocumentationPanelWidget(QWidget* parent) :QWidget(parent), m_engine(nullptr), m_textBrowser(nullptr), m_tabWidget(nullptr), m_splitter(nullptr)
DocumentationPanelWidget::DocumentationPanelWidget(Cantor::Session* session, QWidget* parent) :QWidget(parent), m_engine(nullptr), m_textBrowser(nullptr), m_tabWidget(nullptr), m_splitter(nullptr), m_session(nullptr)
{
const QString backendName = QLatin1String("maxima");
const QString fileName = QStandardPaths::locate(QStandardPaths::AppDataLocation, QLatin1String("documentation/") + backendName + QLatin1String("/help.qhc"));
const QString backend = session->backend()->name();
qDebug() << backend;
const QString fileName = QStandardPaths::locate(QStandardPaths::AppDataLocation, QLatin1String("documentation/") + backend + QLatin1String("/help.qhc"));
m_engine = new QHelpEngine(fileName, this);
if(!m_engine->setupData())
......@@ -96,6 +98,13 @@ DocumentationPanelWidget::DocumentationPanelWidget(QWidget* parent) :QWidget(par
connect(m_engine->contentWidget(), &QHelpContentWidget::linkActivated, this, &DocumentationPanelWidget::displayHelp);
connect(m_engine->indexWidget(), &QHelpIndexWidget::linkActivated, this, &DocumentationPanelWidget::displayHelp);
//connect(search, SIGNAL(clicked(bool)), this, SLOT(doSearch(QString)));
setSession(session);
}
void DocumentationPanelWidget::setSession(Cantor::Session* session)
{
m_session = session;
}
void DocumentationPanelWidget::displayHelp(const QUrl& url)
......@@ -130,30 +139,23 @@ void DocumentationPanelWidget::contextSensitiveHelp(const QString& keyword)
void DocumentationPanelWidget::loadDocumentation()
{
//1. Get the backend name
//2. Load their documentation
const QString backendName = QLatin1String("maxima");
const QString fileName = QStandardPaths::locate(QStandardPaths::AppDataLocation, QLatin1String("documentation/") + backendName + QLatin1String("/help.qch"));
const QString backend = backendName();
const QString fileName = QStandardPaths::locate(QStandardPaths::AppDataLocation, QLatin1String("documentation/") + backend + QLatin1String("/help.qch"));
m_engine->registerDocumentation(fileName);
}
void DocumentationPanelWidget::unloadDocumentation()
{
//1. Get the backend name
//2. Unload their documentation
//Call this function when the user changes the current backend
m_engine->unregisterDocumentation(QLatin1String("org.kde.cantor"));
}
QIcon DocumentationPanelWidget::icon() const
{
// return backend's icon
return QIcon();
return QIcon::fromTheme(m_session->backend()->icon());
}
QString DocumentationPanelWidget::name() const
QString DocumentationPanelWidget::backendName() const
{
// return backend's name
return QString(QLatin1String("maxima"));
return QString(QLatin1String("Maxima"));//m_session->backend()->name();
}
......@@ -24,6 +24,10 @@
#include <QPointer>
#include <QWidget>
namespace Cantor{
class Session;
}
class QHelpEngine;
class QSplitter;
class QTabWidget;
......@@ -35,14 +39,16 @@ class DocumentationPanelWidget : public QWidget
Q_OBJECT
public:
DocumentationPanelWidget(QWidget*);
DocumentationPanelWidget(Cantor::Session* session, QWidget* parent);
~DocumentationPanelWidget() override = default;
void setSession(Cantor::Session* session);
/** @return icon of the current backend **/
QIcon icon() const;
/** @return name of the current backend **/
QString name() const;
QString backendName() const;
void loadDocumentation();
void unloadDocumentation();
......@@ -58,7 +64,7 @@ class DocumentationPanelWidget : public QWidget
QPointer<QTabWidget> m_tabWidget;
QPointer<QSplitter> m_splitter;
// later add member variable for path to help files
Cantor::Session* m_session;
};
#endif /* _DOCUMENTATIONPANELWIDGET_H */
......@@ -34,7 +34,7 @@ class VariableManagerWidget : public QWidget
{
Q_OBJECT
public:
VariableManagerWidget( Cantor::Session* session,QWidget* parent );
VariableManagerWidget(Cantor::Session* session, QWidget* parent);
~VariableManagerWidget() override = default;
void setSession(Cantor::Session* session);
......
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