コード例 #1
0
ファイル: preferences.C プロジェクト: HeyJJ/ball
		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
0
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
0
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
0
ファイル: helpplugin.cpp プロジェクト: C-sjia/qt-creator
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
0
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
0
ファイル: helpplugin.cpp プロジェクト: Distrotech/qtcreator
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
0
ファイル: centralwidget.cpp プロジェクト: halsten/beaverdbg
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
0
ファイル: centralwidget.cpp プロジェクト: halsten/beaverdbg
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
0
void GeneralSettingsPage::setCurrentPage()
{
    HelpViewer *viewer = CentralWidget::instance()->currentHelpViewer();
    if (viewer)
        m_ui->homePageLineEdit->setText(viewer->source().toString());
}
コード例 #10
0
ファイル: centralwidget.cpp プロジェクト: gidlbn/dlbn_02
void CentralWidget::resetZoom()
{
    HelpViewer* viewer = currentHelpViewer();
    if (viewer)
        viewer->resetScale();
}
コード例 #11
0
ファイル: centralwidget.cpp プロジェクト: gidlbn/dlbn_02
void CentralWidget::zoomOut()
{
    HelpViewer* viewer = currentHelpViewer();
    if (viewer)
        viewer->scaleDown();
}
コード例 #12
0
ファイル: centralwidget.cpp プロジェクト: gidlbn/dlbn_02
void CentralWidget::zoomIn()
{
    HelpViewer* viewer = currentHelpViewer();
    if (viewer)
        viewer->scaleUp();
}
コード例 #13
0
ファイル: centralwidget.cpp プロジェクト: halsten/beaverdbg
void CentralWidget::newTab()
{
    HelpViewer* viewer = currentHelpViewer();
    if (viewer)
        setSourceInNewTab(viewer->source());
}
コード例 #14
0
ファイル: helpplugin.cpp プロジェクト: AtlantisCD9/Qt
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;
}