mirror of
https://github.com/chris2511/xca.git
synced 2026-09-14 02:56:18 +05:00
- Always build html documentation if sphinx-build is available.
to be installable during install
- Collect "${D}/qthelp/xca.qhc" "${D}/qthelp/xca.qch" in QTHELP_IDX
and use this instead.
- On linux also install the qthelp in an html subdirectory like WIN32
- Don't instanciate QHelpEngine if no help available.
89 lines
1.9 KiB
C++
89 lines
1.9 KiB
C++
/* vi: set sw=4 ts=4:
|
|
*
|
|
* Copyright (C) 2001 - 2012 Christian Hohnstaedt.
|
|
*
|
|
* All rights reserved.
|
|
*/
|
|
|
|
#include "Help.h"
|
|
#include "lib/func.h"
|
|
|
|
#include <QDebug>
|
|
#include <QDialog>
|
|
#include <QHelpEngine>
|
|
#include <QDialogButtonBox>
|
|
|
|
Help::Help() : QWidget(NULL), helpengine(nullptr)
|
|
{
|
|
setupUi(this);
|
|
setWindowTitle(XCA_TITLE);
|
|
textbox->setSearchPaths(QStringList(getDocDir()));
|
|
textbox->setOpenExternalLinks(true);
|
|
textbox->clearHistory();
|
|
if (!getDocDir().isEmpty())
|
|
helpengine = new QHelpEngineCore(getDocDir() + "/xca.qhc");
|
|
}
|
|
|
|
Help::~Help()
|
|
{
|
|
delete helpengine;
|
|
}
|
|
|
|
void Help::display(const QUrl &url)
|
|
{
|
|
textbox->setSource(QUrl(url.fileName()));
|
|
textbox->scrollToAnchor(url.fragment());
|
|
show();
|
|
raise();
|
|
}
|
|
|
|
void Help::content()
|
|
{
|
|
display(QUrl("qthelp://org.sphinx.xca/doc/index.html"));
|
|
}
|
|
|
|
QMap<QString, QUrl> Help::url_by_ctx(const QString &ctx) const
|
|
{
|
|
if (!helpengine)
|
|
return QMap<QString, QUrl>();
|
|
return helpengine->linksForIdentifier(QString("%1.%1").arg(ctx));
|
|
}
|
|
|
|
void Help::contexthelp(const QString &context)
|
|
{
|
|
QMap<QString, QUrl> helpctx = url_by_ctx(context);
|
|
|
|
if (helpctx.count())
|
|
display(helpctx.constBegin().value());
|
|
}
|
|
|
|
void Help::contexthelp()
|
|
{
|
|
QObject *o = sender();
|
|
if (!o)
|
|
return;
|
|
QString ctx = o->property("help_ctx").toString();
|
|
if (ctx.isEmpty())
|
|
return;
|
|
contexthelp(ctx);
|
|
}
|
|
|
|
void Help::register_ctxhelp_button(QDialog *dlg, const QString &help_ctx) const
|
|
{
|
|
QDialogButtonBox *buttonBox =
|
|
dlg->findChild<QDialogButtonBox*>("buttonBox");
|
|
|
|
if (!buttonBox || help_ctx.isEmpty())
|
|
return;
|
|
|
|
dlg->setWindowModality(Qt::WindowModal);
|
|
buttonBox->addButton(QDialogButtonBox::Help);
|
|
buttonBox->setProperty("help_ctx", QVariant(help_ctx));
|
|
connect(buttonBox, SIGNAL(helpRequested()), this, SLOT(contexthelp()));
|
|
|
|
if (helpengine && url_by_ctx(help_ctx).count() == 0) {
|
|
qWarning() << "Unknown help context: " << help_ctx;
|
|
buttonBox->button(QDialogButtonBox::Help)->setEnabled(false);
|
|
}
|
|
}
|