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

Remove session handling from documentationpanelwidget

parent cecaf6b2
......@@ -21,7 +21,6 @@
#include "documentationpanelplugin.h"
#include "session.h"
#include <QDebug>
#include <QIcon>
DocumentationPanelPlugin::DocumentationPanelPlugin(QObject* parent, QList<QVariant> args) : Cantor::PanelPlugin(parent), m_widget(nullptr)
......@@ -37,14 +36,20 @@ DocumentationPanelPlugin::~DocumentationPanelPlugin()
void DocumentationPanelPlugin::onSessionChanged()
{
if(m_widget)
m_widget->setSession(session());
{
m_widget->setBackend(m_backendName);
m_widget->setBackendIcon(m_backendIcon);
}
}
QWidget* DocumentationPanelPlugin::widget()
{
m_backendName = session()->backend()->name();
m_backendIcon = session()->backend()->icon();
if(!m_widget)
{
m_widget = new DocumentationPanelWidget(session(), parentWidget());
m_widget = new DocumentationPanelWidget(m_backendName, m_backendIcon, parentWidget());
connect(parent()->parent(), SIGNAL(requestDocumentation(QString)), m_widget, SLOT(contextSensitiveHelp(QString)));
connect(parent()->parent(), SIGNAL(requestDocumentation(QString)), this, SIGNAL(visibilityRequested()));
}
......@@ -59,12 +64,12 @@ bool DocumentationPanelPlugin::showOnStartup()
QIcon DocumentationPanelPlugin::icon() const
{
return QIcon::fromTheme(m_widget->m_session->backend()->icon());
return QIcon::fromTheme(m_backendIcon);
}
QString DocumentationPanelPlugin::backendName() const
{
return m_widget->m_session->backend()->name();
return m_backendName;
}
K_PLUGIN_FACTORY_WITH_JSON(documentationpanelplugin, "documentationpanelplugin.json", registerPlugin<DocumentationPanelPlugin>();)
......
......@@ -48,6 +48,8 @@ class DocumentationPanelPlugin : public Cantor::PanelPlugin
private:
QPointer<DocumentationPanelWidget> m_widget;
QString m_backendName;
QString m_backendIcon;
};
#endif /* _DOCUMENTATIONPANELPLUGIN_H */
......@@ -20,7 +20,6 @@
#include "cantor_macros.h"
#include "documentationpanelplugin.h"
#include "session.h"
#include <KLocalizedString>
......@@ -45,9 +44,11 @@
#include <QWebEngineUrlScheme>
#include <QWebEngineView>
DocumentationPanelWidget::DocumentationPanelWidget(Cantor::Session* session, QWidget* parent) :QWidget(parent), m_backend(QString())
DocumentationPanelWidget::DocumentationPanelWidget(const QString& backend, const QString& backendIcon, QWidget* parent) :QWidget(parent)
{
m_backend = session->backend()->name();
m_backend = backend;
m_icon = backendIcon;
const QString& fileName = QStandardPaths::locate(QStandardPaths::AppDataLocation, QLatin1String("documentation/") + m_backend + QLatin1String("/help.qhc"));
m_engine = new QHelpEngine(fileName, this);
......@@ -72,7 +73,7 @@ DocumentationPanelWidget::DocumentationPanelWidget(Cantor::Session* session, QWi
QComboBox* documentationSelector = new QComboBox(this);
// iterate through the available docs for current backend, for example python may have matplotlib, scikitlearn etc
documentationSelector->addItem(QIcon::fromTheme(session->backend()->icon()), m_backend);
documentationSelector->addItem(QIcon::fromTheme(m_icon), m_backend);
// Add a seperator
QFrame *seperator = new QFrame(this);
......@@ -231,8 +232,6 @@ DocumentationPanelWidget::DocumentationPanelWidget(Cantor::Session* session, QWi
connect(m_matchCase, &QAbstractButton::toggled, this, [=]{
m_textBrowser->findText(QString());
});
setSession(session);
}
DocumentationPanelWidget::~DocumentationPanelWidget()
......@@ -246,9 +245,14 @@ DocumentationPanelWidget::~DocumentationPanelWidget()
delete m_matchCase;
}
void DocumentationPanelWidget::setSession(Cantor::Session* session)
void DocumentationPanelWidget::setBackend(const QString& backend)
{
m_backend = backend;
}
void DocumentationPanelWidget::setBackendIcon(const QString& icon)
{
m_session = session;
m_icon = icon;
}
void DocumentationPanelWidget::displayHelp(const QUrl& url)
......
......@@ -27,11 +27,6 @@
#include <QWebEngineUrlSchemeHandler>
#include <QWidget>
namespace Cantor
{
class Session;
}
class QHelpEngine;
class QHelpIndexWidget;
class QLineEdit;
......@@ -45,19 +40,18 @@ class DocumentationPanelWidget : public QWidget
Q_OBJECT
public:
DocumentationPanelWidget(Cantor::Session* session, QWidget* parent);
DocumentationPanelWidget(const QString& backend, const QString& backendIcon, QWidget* parent);
~DocumentationPanelWidget();
void setSession(Cantor::Session* session);
void setBackend(const QString&);
void setBackendIcon(const QString&);
/** @return name of the current backend **/
QString backendName() const;
void loadDocumentation();
public:
Cantor::Session* m_session = nullptr;
Q_SIGNALS:
void activateBrowser();
......@@ -76,6 +70,7 @@ class DocumentationPanelWidget : public QWidget
QStackedWidget* m_displayArea = nullptr;
QHelpIndexWidget* m_index = nullptr;
QString m_backend;
QString m_icon;
// member variables for find in page text widget
QLineEdit* m_search = nullptr; // for searching through keywords
......
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