Commit 11dd741d authored by Alexander Semke's avatar Alexander Semke
Browse files

Open the default URL for the online documentation in case no local documentation is installed.

parent 28c1b395
......@@ -134,7 +134,7 @@ CantorPart::CantorPart( QWidget *parentWidget, QObject *parent, const QVariantLi
connect(m_worksheet, &Worksheet::hierarhyEntryNameChange, this, &CantorPart::hierarhyEntryNameChange);
connect(this, &CantorPart::requestScrollToHierarchyEntry, m_worksheet, &Worksheet::requestScrollToHierarchyEntry);
connect(this, &CantorPart::settingsChanges, m_worksheet, &Worksheet::handleSettingsChanges);
connect(m_worksheet, &Worksheet::requestDocumentation, this, &CantorPart::requestDocumentation);
connect(m_worksheet, &Worksheet::requestDocumentation, this, &CantorPart::documentationRequested);
layout->addWidget(m_worksheetview);
setWidget(widget);
......@@ -727,13 +727,27 @@ void CantorPart::enableTypesetting(bool enable)
m_worksheet->session()->setTypesettingEnabled(enable);
}
/*!
* called when the current worksheet has requested to show the documentation for \c keyword.
* In case the local documentation is available for the current backend, the signal is
* forwarded to the shell to show the documentation plugin/widget.
* If no local documentation is available, the defaul online URL for the backend documentation
* is openned.
*/
void CantorPart::documentationRequested(const QString& keyword) {
auto* backend = m_worksheet->session()->backend();
const KConfigGroup& group = KSharedConfig::openConfig()->group(backend->name().toLower());
const auto& docNames = group.readEntry(QLatin1String("Names"), QStringList());
if (!docNames.isEmpty())
emit requestDocumentation(keyword);
else
showBackendHelp();
}
void CantorPart::showBackendHelp()
{
qDebug()<<"Showing backend's help";
auto* backend = m_worksheet->session()->backend();
QUrl url = backend->helpUrl();
qDebug()<<"launching url "<<url;
auto *job = new KIO::OpenUrlJob(url);
auto* job = new KIO::OpenUrlJob(backend->helpUrl());
job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, widget()));
job->start();
}
......
......@@ -151,6 +151,7 @@ protected Q_SLOTS:
where set during the block
**/
void unblockStatusBar();
private:
Worksheet *m_worksheet;
WorksheetView *m_worksheetview;
......@@ -177,6 +178,9 @@ private:
QString m_cachedStatusMessage;
bool m_statusBarBlocked;
unsigned int m_sessionStatusCounter;
private Q_SLOTS:
void documentationRequested(const QString&);
};
#endif // CANTORPART_H
......@@ -375,6 +375,9 @@ void DocumentationPanelWidget::contextSensitiveHelp(const QString& keyword)
//make sure first we show the web view in the stack widget
m_stackedWidget->setCurrentIndex(0);
if (!m_indexWidget)
return;
m_indexWidget->filterIndices(keyword); // filter exactly, no wildcards
m_indexWidget->activateCurrentItem(); // this internally emitts the QHelpIndexWidget::linkActivated signal
......
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