本文整理汇总了C++中HelpViewer类的典型用法代码示例。如果您正苦于以下问题:C++ HelpViewer类的具体用法?C++ HelpViewer怎么用?C++ HelpViewer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HelpViewer类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showEntry
void Preferences::showEntry(QWidget* child)
{
if (!widget_to_item_.has(child))
{
widget_stack->setCurrentIndex(0);
return;
}
// enable or disable help button
HelpViewer* hv = HelpViewer::getInstance(0);
if (hv != 0) buttonBox->button(QDialogButtonBox::Help)->setEnabled(hv->hasHelpFor(child));
// set the listview entry
QTreeWidgetItem* item = widget_to_item_[child];
entries_listview->setCurrentItem(item);
entries_listview->setItemSelected(item, true);
if (item->parent() != 0) entries_listview->setItemExpanded(item->parent(), true);
// is the child a direct child of the stacked widget?
if (widget_stack->indexOf(child) != -1)
{
// show the child
widget_stack->setCurrentWidget(child);
widget_stack->currentWidget()->show();
return;
}
if (!item_to_entry_.has(item->parent()))
{
BALLVIEW_DEBUG
return;
}
示例2:
CentralWidget::~CentralWidget()
{
TRACE_OBJ
#ifndef QT_NO_PRINTER
delete printer;
#endif
QStringList zoomFactors;
QStringList currentPages;
bool searchAttached = m_searchWidget->isAttached();
int i = searchAttached ? 1 : 0;
for (; i < tabWidget->count(); ++i) {
HelpViewer *viewer = qobject_cast<HelpViewer*>(tabWidget->widget(i));
if (viewer && viewer->source().isValid()) {
currentPages << viewer->source().toString();
zoomFactors << QString::number(viewer->scale());
}
}
HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
helpEngine.setLastTabPage(tabWidget->currentIndex());
helpEngine.setLastShownPages(currentPages);
helpEngine.setSearchWasAttached(searchAttached);
helpEngine.setLastZoomFactors(zoomFactors);
}
示例3: beginInsertRows
void OpenPagesModel::addPage(const QUrl &url, qreal zoom)
{
beginInsertRows(QModelIndex(), rowCount(), rowCount());
HelpViewer *page = new HelpViewer(zoom);
connect(page, SIGNAL(titleChanged()), this, SLOT(handleTitleChanged()));
m_pages << page;
endInsertRows();
page->setSource(url);
}
示例4: QtWebKitHelpViewer
HelpViewer *HelpPlugin::createHelpViewer(qreal zoom)
{
// check for backends
typedef std::function<HelpViewer *()> ViewerFactory;
typedef QPair<QByteArray, ViewerFactory> ViewerFactoryItem; // id -> factory
QVector<ViewerFactoryItem> factories;
#ifndef QT_NO_WEBKIT
factories.append(qMakePair(QByteArray("qtwebkit"), []() { return new QtWebKitHelpViewer(); }));
#endif
#ifdef QTC_WEBENGINE_HELPVIEWER
factories.append(qMakePair(QByteArray("qtwebengine"), []() { return new WebEngineHelpViewer(); }));
#endif
factories.append(qMakePair(QByteArray("textbrowser"), []() { return new TextBrowserHelpViewer(); }));
#ifdef QTC_MAC_NATIVE_HELPVIEWER
// default setting
#ifdef QTC_MAC_NATIVE_HELPVIEWER_DEFAULT
factories.prepend(qMakePair(QByteArray("native"), []() { return new MacWebKitHelpViewer(); }));
#else
factories.append(qMakePair(QByteArray("native"), []() { return new MacWebKitHelpViewer(); }));
#endif
#endif
HelpViewer *viewer = nullptr;
// check requested backend
const QByteArray backend = qgetenv("QTC_HELPVIEWER_BACKEND");
if (!backend.isEmpty()) {
const int pos = Utils::indexOf(factories, [backend](const ViewerFactoryItem &item) {
return backend == item.first;
});
if (pos == -1) {
qWarning("Help viewer backend \"%s\" not found, using default.", backend.constData());
} else {
viewer = factories.at(pos).second();
}
}
if (!viewer)
viewer = factories.first().second();
QTC_ASSERT(viewer, return nullptr);
// initialize font
viewer->setViewerFont(LocalHelpManager::fallbackFont());
connect(LocalHelpManager::instance(), &LocalHelpManager::fallbackFontChanged,
viewer, &HelpViewer::setViewerFont);
// initialize zoom
viewer->setScale(zoom);
// add find support
Aggregation::Aggregate *agg = new Aggregation::Aggregate();
agg->add(viewer);
agg->add(new HelpViewerFindSupport(viewer));
return viewer;
}
示例5: Q_ASSERT
void OpenPagesModel::removePage(int index)
{
Q_ASSERT(index >= 0 && index < rowCount());
beginRemoveRows(QModelIndex(), index, index);
HelpViewer *page = m_pages.at(index);
m_pages.removeAt(index);
endRemoveRows();
page->deleteLater();
}
示例6: MacWebKitHelpViewer
HelpViewer *HelpPlugin::createHelpViewer(qreal zoom)
{
// check for backends
typedef std::function<HelpViewer *()> ViewerFactory;
QHash<QString, ViewerFactory> factories; // id -> factory
#ifdef QTC_MAC_NATIVE_HELPVIEWER
factories.insert(QLatin1String("native"), []() { return new MacWebKitHelpViewer(); });
#endif
#ifndef QT_NO_WEBKIT
factories.insert(QLatin1String("qtwebkit"), []() { return new QtWebKitHelpViewer(); });
#endif
factories.insert(QLatin1String("textbrowser"), []() { return new TextBrowserHelpViewer(); });
ViewerFactory factory;
// check requested backend
const QString backend = QLatin1String(qgetenv("QTC_HELPVIEWER_BACKEND"));
if (!backend.isEmpty()) {
factory = factories.value(backend);
if (!factory)
qWarning("Help viewer backend \"%s\" not found, using default.", qPrintable(backend));
}
// default setting
#ifdef QTC_MAC_NATIVE_HELPVIEWER_DEFAULT
if (!factory)
factory = factories.value(QLatin1String("native"));
#endif
if (!factory)
factory = factories.value(QLatin1String("qtwebkit"));
if (!factory)
factory = factories.value(QLatin1String("textbrowser"));
QTC_ASSERT(factory, return 0);
HelpViewer *viewer = factory();
// initialize font
viewer->setViewerFont(LocalHelpManager::fallbackFont());
connect(LocalHelpManager::instance(), &LocalHelpManager::fallbackFontChanged,
viewer, &HelpViewer::setViewerFont);
// initialize zoom
viewer->setScale(zoom);
// add find support
Aggregation::Aggregate *agg = new Aggregation::Aggregate();
agg->add(viewer);
agg->add(new HelpViewerFindSupport(viewer));
return viewer;
}
示例7: engine
CentralWidget::~CentralWidget()
{
QDir dir;
QString currentPages;
QHelpEngineCore engine(collectionFile, 0);
if (engine.setupData()) {
for (int i = 0; i < tabWidget->count(); ++i) {
HelpViewer *viewer = qobject_cast<HelpViewer*>(tabWidget->widget(i));
if (viewer && viewer->source().isValid())
currentPages.append(viewer->source().toString()).append(QLatin1Char('|'));
}
engine.setCustomValue(QLatin1String("LastTabPage"), lastTabPage);
engine.setCustomValue(QLatin1String("LastShownPages"), currentPages);
}
}
示例8: currentHelpViewer
void CentralWidget::setSource(const QUrl &url)
{
HelpViewer* viewer = currentHelpViewer();
HelpViewer* lastViewer = qobject_cast<HelpViewer*>(tabWidget->widget(lastTabPage));
if (!viewer && !lastViewer) {
viewer = new HelpViewer(helpEngine, this);
viewer->installEventFilter(this);
lastTabPage = tabWidget->addTab(viewer, QString());
tabWidget->setCurrentIndex(lastTabPage);
connectSignals();
qApp->processEvents();
} else
viewer = lastViewer;
viewer->setSource(url);
currentPageChanged(lastTabPage);
viewer->setFocus(Qt::OtherFocusReason);
tabWidget->setCurrentIndex(lastTabPage);
tabWidget->setTabText(lastTabPage, quoteTabTitle(viewer->documentTitle()));
}
示例9: setCurrentPage
void GeneralSettingsPage::setCurrentPage()
{
HelpViewer *viewer = CentralWidget::instance()->currentHelpViewer();
if (viewer)
m_ui->homePageLineEdit->setText(viewer->source().toString());
}
示例10: currentHelpViewer
void CentralWidget::resetZoom()
{
HelpViewer* viewer = currentHelpViewer();
if (viewer)
viewer->resetScale();
}
示例11: MacWebKitHelpViewer
HelpViewer *HelpPlugin::createHelpViewer(qreal zoom)
{
// check for backends
typedef std::function<HelpViewer *()> ViewerFactory;
QHash<QString, ViewerFactory> factories; // id -> factory
#ifdef QTC_MAC_NATIVE_HELPVIEWER
factories.insert(QLatin1String("native"), []() { return new MacWebKitHelpViewer(); });
#endif
#ifndef QT_NO_WEBKIT
factories.insert(QLatin1String("qtwebkit"), []() { return new QtWebKitHelpViewer(); });
#endif
factories.insert(QLatin1String("textbrowser"), []() { return new TextBrowserHelpViewer(); });
ViewerFactory factory;
// TODO: Visual Studio < 2013 has a bug in std::function's operator bool, which in this case
// leads to succeeding boolean checks on factory which should not succeed.
// So we may not check against "if (!factory)"
bool factoryFound = false;
// check requested backend
const QString backend = QLatin1String(qgetenv("QTC_HELPVIEWER_BACKEND"));
if (!backend.isEmpty()) {
if (!factories.contains(backend)) {
qWarning("Help viewer backend \"%s\" not found, using default.", qPrintable(backend));
} else {
factory = factories.value(backend);
factoryFound = true;
}
}
// default setting
#ifdef QTC_MAC_NATIVE_HELPVIEWER_DEFAULT
if (!factoryFound && factories.contains(QLatin1String("native"))) {
factory = factories.value(QLatin1String("native"));
factoryFound = true;
}
#endif
if (!factoryFound && factories.contains(QLatin1String("qtwebkit"))) {
factory = factories.value(QLatin1String("qtwebkit"));
factoryFound = true;
}
if (!factoryFound && factories.contains(QLatin1String("textbrowser"))) {
factory = factories.value(QLatin1String("textbrowser"));
factoryFound = true;
}
QTC_ASSERT(factoryFound, return 0);
HelpViewer *viewer = factory();
// initialize font
QVariant fontSetting = LocalHelpManager::engineFontSettings();
if (fontSetting.isValid())
viewer->setViewerFont(fontSetting.value<QFont>());
// initialize zoom
viewer->setScale(zoom);
// add find support
Aggregation::Aggregate *agg = new Aggregation::Aggregate();
agg->add(viewer);
agg->add(new HelpViewerFindSupport(viewer));
return viewer;
}