Commit 2ba6e78e authored by Shubham  .'s avatar Shubham .
Browse files

Improve the code layout, tranfer backend and icon memeber fucntions to plugin

parent bdcc740e
......@@ -20,6 +20,8 @@
#include "documentationpanelplugin.h"
#include "session.h"
#include <QDebug>
#include <QIcon>
DocumentationPanelPlugin::DocumentationPanelPlugin(QObject* parent, QList<QVariant> args) : Cantor::PanelPlugin(parent), m_widget(nullptr)
{
......@@ -42,6 +44,7 @@ QWidget* DocumentationPanelPlugin::widget()
if(!m_widget)
{
m_widget = new DocumentationPanelWidget(session(), parentWidget());
qDebug() << backendName();
connect(parent()->parent(), SIGNAL(requestDocumentation(QString)), m_widget, SLOT(contextSensitiveHelp(QString)));
connect(parent()->parent(), SIGNAL(requestDocumentation(QString)), this, SIGNAL(visibilityRequested()));
}
......@@ -54,5 +57,15 @@ bool DocumentationPanelPlugin::showOnStartup()
return true;
}
QIcon DocumentationPanelPlugin::icon() const
{
return QIcon::fromTheme(m_widget->m_session->backend()->icon());
}
QString DocumentationPanelPlugin::backendName() const
{
return m_widget->m_session->backend()->name();
}
K_PLUGIN_FACTORY_WITH_JSON(documentationpanelplugin, "documentationpanelplugin.json", registerPlugin<DocumentationPanelPlugin>();)
#include "documentationpanelplugin.moc"
......@@ -37,6 +37,12 @@ class DocumentationPanelPlugin : public Cantor::PanelPlugin
bool showOnStartup() override;
/** @return icon of the current backend **/
QIcon icon() const;
/** @return name of the current backend **/
QString backendName() const;
protected:
void onSessionChanged() override;
......
......@@ -42,11 +42,10 @@
#include <QWebEngineView>
#include <QWidget>
DocumentationPanelWidget::DocumentationPanelWidget(Cantor::Session* session, QWidget* parent) :QWidget(parent), m_engine(nullptr), m_textBrowser(nullptr), m_tabWidget(nullptr), m_splitter(nullptr), m_session(nullptr)
DocumentationPanelWidget::DocumentationPanelWidget(Cantor::Session* session, QWidget* parent) :QWidget(parent), m_session(nullptr), m_engine(nullptr), m_textBrowser(nullptr), m_tabWidget(nullptr), m_splitter(nullptr), m_backend(QString())
{
const QString backend = session->backend()->name();
qDebug() << backend;
const QString fileName = QStandardPaths::locate(QStandardPaths::AppDataLocation, QLatin1String("documentation/") + backend + QLatin1String("/help.qhc"));
m_backend = session->backend()->name();
const QString fileName = QStandardPaths::locate(QStandardPaths::AppDataLocation, QLatin1String("documentation/") + m_backend + QLatin1String("/help.qhc"));
m_engine = new QHelpEngine(fileName, this);
if(!m_engine->setupData())
......@@ -85,7 +84,6 @@ DocumentationPanelWidget::DocumentationPanelWidget(Cantor::Session* session, QWi
m_textBrowser->show();
//const QByteArray contents = m_engine->fileData(QUrl(QLatin1String("qthelp://org.kde.cantor/doc/figures/plotting1.png")));
//const QByteArray contents = m_engine->fileData(QUrl(QLatin1String("qthelp://org.kde.cantor/doc/maxima_91.html#SEC433")));
//m_textBrowser->setContent(contents, QLatin1String("image/png;charset=UTF-8"));
m_splitter = new QSplitter(Qt::Horizontal, this);
......@@ -150,12 +148,7 @@ void DocumentationPanelWidget::unloadDocumentation()
m_engine->unregisterDocumentation(QLatin1String("org.kde.cantor"));
}
QIcon DocumentationPanelWidget::icon() const
{
return QIcon::fromTheme(m_session->backend()->icon());
}
QString DocumentationPanelWidget::backendName() const
{
return QString(QLatin1String("Maxima"));//m_session->backend()->name();
return m_backend;//m_session->backend()->name();
}
......@@ -44,15 +44,15 @@ class DocumentationPanelWidget : public QWidget
void setSession(Cantor::Session* session);
/** @return icon of the current backend **/
QIcon icon() const;
/** @return name of the current backend **/
QString backendName() const;
void loadDocumentation();
void unloadDocumentation();
public:
Cantor::Session* m_session;
private Q_SLOTS:
void displayHelp(const QUrl&);
void doSearch(const QString&);
......@@ -63,8 +63,7 @@ class DocumentationPanelWidget : public QWidget
QPointer<QWebEngineView> m_textBrowser;
QPointer<QTabWidget> m_tabWidget;
QPointer<QSplitter> m_splitter;
Cantor::Session* m_session;
QString m_backend;
};
#endif /* _DOCUMENTATIONPANELWIDGET_H */
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