Commit 64f32ca2 authored by Shubham  .'s avatar Shubham .
Browse files

[WIP] Add switching ability when in the same backend

parent 76d87771
......@@ -65,11 +65,11 @@ qhp.writelines("""<?xml version="1.0" encoding="UTF-8"?>
<QtHelpProject version="1.0">
<namespace>org.kde.maxima.5.42</namespace>
<virtualFolder>doc</virtualFolder>
<virtualFolder>5.42</virtualFolder>
<customFilter name="Maxima">
<filterAttribute>Maxima Documentation</filterAttribute>
<filterAttribute>5.42</filterAttribute>
<filterAttribute>doc</filterAttribute>
</customFilter>
<filterSection>
......
......@@ -45,7 +45,7 @@ title = soup.find('title').text
# populate qhp file with headers and table of contents
qhp.writelines("""<?xml version="1.0" encoding="UTF-8"?>
<QtHelpProject version="1.0">
<namespace>org.kde.maxima.5.42</namespace>
<namespace>org.kde.maxima.5.44</namespace>
<virtualFolder>doc</virtualFolder>
......@@ -176,7 +176,7 @@ for i in soup.find_all('code'):
keyword = i.text.replace("<", "")
keyword = re.sub(r" ?\([^)]+\)", "", keyword)
ref = i.find_parent('a')
qhp.write('<keyword name = "{}" ref = "{}"/>\n'.format(keyword, ref['href']))
# write the tail
......
......@@ -50,7 +50,7 @@
#include "cantor.h"
#include "settings.h"
#include "ui_settings.h"
#include "backendchoosedialog.h"
#include <QMetaObject>
CantorShell::CantorShell() : KParts::MainWindow(), m_part(nullptr), m_panelHandler(nullptr)
......
......@@ -47,6 +47,7 @@
#include <QWebEngineProfile>
#include <QWebEngineUrlScheme>
#include <QWebEngineView>
#include <QDebug>
DocumentationPanelWidget::DocumentationPanelWidget(QWidget* parent) : QWidget(parent)
{
......@@ -184,7 +185,32 @@ DocumentationPanelWidget::DocumentationPanelWidget(QWidget* parent) : QWidget(pa
m_textBrowser->show();
});
connect(m_documentationSelector, QOverload<int>::of(&QComboBox::currentIndexChanged), [=](int index){
connect(m_documentationSelector, QOverload<int>::of(&QComboBox::currentIndexChanged), [=]{
updateDocumentation();
if(m_displayArea->count())
{
for(int i = m_displayArea->count(); i >= 0; i--)
{
m_displayArea->removeWidget(m_displayArea->widget(i));
}
m_search->clear();
}
m_displayArea->addWidget(m_content);
m_displayArea->addWidget(m_textBrowser);
m_displayArea->addWidget(m_index);
connect(m_content, &QHelpContentWidget::linkActivated, this, &DocumentationPanelWidget::displayHelp);
connect(m_index, &QHelpIndexWidget::linkActivated, this, &DocumentationPanelWidget::displayHelp);
connect(m_search->completer(), QOverload<const QModelIndex&>::of(&QCompleter::activated), this, &DocumentationPanelWidget::returnPressed);
//TODO QHelpIndexWidget::linkActivated is obsolete, use QHelpIndexWidget::documentActivated instead
// display the documentation browser whenever contents are clicked
connect(m_content, &QHelpContentWidget::linkActivated, [=]{
m_displayArea->setCurrentIndex(1);
});
});
connect(m_displayArea, &QStackedWidget::currentChanged, [=]{
......@@ -308,12 +334,13 @@ void DocumentationPanelWidget::updateBackend(const QString& newBackend, const QS
void DocumentationPanelWidget::updateDocumentation()
{
// On first startup, load the first item by default in the QComboBox documnetation selector
// initialize the Qt Help engine and provide the proper help collection file for the current backend
const QString& docSelected = m_documentationSelector->currentText();
const QString& fileName = QStandardPaths::locate(QStandardPaths::AppDataLocation,
QLatin1String("documentation/") + m_backend + QLatin1String("/") + m_helpFiles[m_backend][0] + QLatin1String("/help.qhc"));
QLatin1String("documentation/") + m_backend + QLatin1String("/") +
docSelected + QLatin1String("/help.qhc"));
// initialize the Qt Help engine and provide the proper help collection file for the current backend
m_engine = new QHelpEngine(fileName, this);
if(!m_engine->setupData())
......@@ -338,7 +365,8 @@ void DocumentationPanelWidget::updateDocumentation()
// register the compressed help file (qch)
const QString& qchFileName = QStandardPaths::locate(QStandardPaths::AppDataLocation,
QLatin1String("documentation/") + m_backend + QLatin1String("/") + m_helpFiles[m_backend][0] + QLatin1String("/help.qch"));
QLatin1String("documentation/") + m_backend + QLatin1String("/") + docSelected +
QLatin1String("/help.qch"));
const QString& nameSpace = QHelpEngineCore::namespaceName(qchFileName);
if(!m_engine->registeredDocumentations().contains(nameSpace))
......@@ -352,6 +380,7 @@ void DocumentationPanelWidget::updateDocumentation()
void DocumentationPanelWidget::displayHelp(const QUrl& url)
{
qDebug() << url;
m_textBrowser->load(url);
m_textBrowser->show();
}
......
......@@ -80,10 +80,7 @@ class DocumentationPanelWidget : public QWidget
QToolButton* m_matchCase = nullptr;
QComboBox* m_documentationSelector = nullptr;
// member variables for changing of combobox
QMap<QString, QStringList> m_helpFiles;
int m_currentIndex = 0;
};
// class for handling of custom url scheme ie. qthelp:// inside QWebEngineView
......
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