2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#include "centralwidget.h"
|
2010-03-30 17:44:28 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "helpviewer.h"
|
2010-11-16 14:15:23 +01:00
|
|
|
#include "localhelpmanager.h"
|
2013-09-02 14:04:12 +02:00
|
|
|
|
|
|
|
|
#include <topicchooser.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QEvent>
|
|
|
|
|
#include <QTimer>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QKeyEvent>
|
|
|
|
|
#include <QLayout>
|
|
|
|
|
#include <QPageSetupDialog>
|
|
|
|
|
#include <QPrinter>
|
|
|
|
|
#include <QPrintDialog>
|
|
|
|
|
#include <QPrintPreviewDialog>
|
|
|
|
|
#include <QStackedWidget>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QHelpEngine>
|
|
|
|
|
#include <QHelpSearchEngine>
|
2009-01-28 16:04:09 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
using namespace Help::Internal;
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
CentralWidget *gStaticCentralWidget = 0;
|
|
|
|
|
|
|
|
|
|
// -- CentralWidget
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-03-23 18:11:43 +01:00
|
|
|
CentralWidget::CentralWidget(QWidget *parent)
|
2008-12-02 12:01:29 +01:00
|
|
|
: QWidget(parent)
|
|
|
|
|
, printer(0)
|
2010-03-30 17:44:28 +02:00
|
|
|
, m_stackedWidget(0)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
Q_ASSERT(!gStaticCentralWidget);
|
|
|
|
|
gStaticCentralWidget = this;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
QVBoxLayout *vboxLayout = new QVBoxLayout(this);
|
|
|
|
|
vboxLayout->setMargin(0);
|
2010-03-30 17:44:28 +02:00
|
|
|
m_stackedWidget = new QStackedWidget(this);
|
|
|
|
|
vboxLayout->addWidget(m_stackedWidget);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CentralWidget::~CentralWidget()
|
|
|
|
|
{
|
2009-06-25 15:20:38 +02:00
|
|
|
#ifndef QT_NO_PRINTER
|
|
|
|
|
delete printer;
|
|
|
|
|
#endif
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
QString zoomFactors;
|
2009-06-25 15:20:38 +02:00
|
|
|
QString currentPages;
|
2010-03-30 17:44:28 +02:00
|
|
|
for (int i = 0; i < m_stackedWidget->count(); ++i) {
|
|
|
|
|
const HelpViewer * const viewer = viewerAt(i);
|
|
|
|
|
const QUrl &source = viewer->source();
|
|
|
|
|
if (source.isValid()) {
|
|
|
|
|
currentPages += source.toString() + QLatin1Char('|');
|
|
|
|
|
zoomFactors += QString::number(viewer->scale()) + QLatin1Char('|');
|
2009-06-25 16:03:02 +02:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2010-03-23 16:56:59 +01:00
|
|
|
|
2010-06-11 13:11:37 +02:00
|
|
|
QHelpEngineCore *engine = &LocalHelpManager::helpEngine();
|
2010-03-23 16:56:59 +01:00
|
|
|
engine->setCustomValue(QLatin1String("LastShownPages"), currentPages);
|
2010-03-30 17:44:28 +02:00
|
|
|
engine->setCustomValue(QLatin1String("LastShownPagesZoom"), zoomFactors);
|
|
|
|
|
engine->setCustomValue(QLatin1String("LastTabPage"), currentIndex());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CentralWidget *CentralWidget::instance()
|
|
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
Q_ASSERT(gStaticCentralWidget);
|
|
|
|
|
return gStaticCentralWidget;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
bool CentralWidget::isForwardAvailable() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
const HelpViewer* viewer = currentHelpViewer();
|
2008-12-02 12:01:29 +01:00
|
|
|
if (viewer)
|
2010-03-30 17:44:28 +02:00
|
|
|
return viewer->isForwardAvailable();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
return false;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
bool CentralWidget::isBackwardAvailable() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
const HelpViewer* viewer = currentHelpViewer();
|
2008-12-02 12:01:29 +01:00
|
|
|
if (viewer)
|
2010-03-30 17:44:28 +02:00
|
|
|
return viewer->isBackwardAvailable();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
return false;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
HelpViewer* CentralWidget::viewerAt(int index) const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
return qobject_cast<HelpViewer*> (m_stackedWidget->widget(index));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
HelpViewer* CentralWidget::currentHelpViewer() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
return qobject_cast<HelpViewer*> (m_stackedWidget->currentWidget());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
void CentralWidget::addPage(HelpViewer *page, bool fromSearch)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
page->installEventFilter(this);
|
|
|
|
|
page->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
connectSignals(page);
|
|
|
|
|
m_stackedWidget->addWidget(page);
|
|
|
|
|
if (fromSearch) {
|
2014-05-02 16:54:28 +02:00
|
|
|
connect(currentHelpViewer(), SIGNAL(loadFinished()), this,
|
2010-03-30 17:44:28 +02:00
|
|
|
SLOT(highlightSearchTerms()));
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
void CentralWidget::removePage(int index)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
m_stackedWidget->removeWidget(m_stackedWidget->widget(index));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
int CentralWidget::currentIndex() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
return m_stackedWidget->currentIndex();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
void CentralWidget::setCurrentPage(HelpViewer *page)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
m_stackedWidget->setCurrentWidget(page);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2014-01-13 16:17:34 +01:00
|
|
|
bool CentralWidget::find(const QString &txt, Core::FindFlags flags,
|
2011-01-14 11:19:57 +01:00
|
|
|
bool incremental, bool *wrapped)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2011-01-14 11:19:57 +01:00
|
|
|
return currentHelpViewer()->findText(txt, flags, incremental, false, wrapped);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
// -- public slots
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
void CentralWidget::copy()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
if (HelpViewer* viewer = currentHelpViewer())
|
|
|
|
|
viewer->copy();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
void CentralWidget::home()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
if (HelpViewer* viewer = currentHelpViewer())
|
|
|
|
|
viewer->home();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
void CentralWidget::zoomIn()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
HelpViewer* viewer = currentHelpViewer();
|
2008-12-02 12:01:29 +01:00
|
|
|
if (viewer)
|
2010-03-30 17:44:28 +02:00
|
|
|
viewer->scaleUp();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
void CentralWidget::zoomOut()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
HelpViewer* viewer = currentHelpViewer();
|
|
|
|
|
if (viewer)
|
2010-03-30 17:44:28 +02:00
|
|
|
viewer->scaleDown();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
void CentralWidget::resetZoom()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
HelpViewer* viewer = currentHelpViewer();
|
2008-12-02 12:01:29 +01:00
|
|
|
if (viewer)
|
2010-03-30 17:44:28 +02:00
|
|
|
viewer->resetScale();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CentralWidget::forward()
|
|
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
if (HelpViewer* viewer = currentHelpViewer())
|
2008-12-02 12:01:29 +01:00
|
|
|
viewer->forward();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CentralWidget::backward()
|
|
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
if (HelpViewer* viewer = currentHelpViewer())
|
2008-12-02 12:01:29 +01:00
|
|
|
viewer->backward();
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
void CentralWidget::print()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
#ifndef QT_NO_PRINTER
|
|
|
|
|
if (HelpViewer* viewer = currentHelpViewer()) {
|
|
|
|
|
initPrinter();
|
|
|
|
|
|
2010-06-01 13:13:59 +02:00
|
|
|
QPrintDialog dlg(printer, this);
|
|
|
|
|
dlg.setWindowTitle(tr("Print Document"));
|
2010-03-30 17:44:28 +02:00
|
|
|
if (!viewer->selectedText().isEmpty())
|
2010-06-01 13:13:59 +02:00
|
|
|
dlg.addEnabledOption(QAbstractPrintDialog::PrintSelection);
|
|
|
|
|
dlg.addEnabledOption(QAbstractPrintDialog::PrintPageRange);
|
|
|
|
|
dlg.addEnabledOption(QAbstractPrintDialog::PrintCollateCopies);
|
|
|
|
|
|
|
|
|
|
if (dlg.exec() == QDialog::Accepted)
|
2010-03-30 17:44:28 +02:00
|
|
|
viewer->print(printer);
|
|
|
|
|
}
|
2009-06-25 16:03:02 +02:00
|
|
|
#endif
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
void CentralWidget::pageSetup()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
#ifndef QT_NO_PRINTER
|
|
|
|
|
initPrinter();
|
|
|
|
|
QPageSetupDialog dlg(printer);
|
|
|
|
|
dlg.exec();
|
2008-12-02 12:01:29 +01:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
void CentralWidget::printPreview()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
#ifndef QT_NO_PRINTER
|
|
|
|
|
initPrinter();
|
|
|
|
|
QPrintPreviewDialog preview(printer, this);
|
|
|
|
|
connect(&preview, SIGNAL(paintRequested(QPrinter*)),
|
|
|
|
|
SLOT(printPreview(QPrinter*)));
|
|
|
|
|
preview.exec();
|
|
|
|
|
#endif
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
void CentralWidget::setSource(const QUrl &url)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
if (HelpViewer* viewer = currentHelpViewer()) {
|
|
|
|
|
viewer->setSource(url);
|
|
|
|
|
viewer->setFocus(Qt::OtherFocusReason);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
void CentralWidget::setSourceFromSearch(const QUrl &url)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-07-27 14:35:00 +02:00
|
|
|
if (HelpViewer* viewer = currentHelpViewer()) {
|
2014-05-02 16:54:28 +02:00
|
|
|
connect(viewer, SIGNAL(loadFinished()), this,
|
2010-03-30 17:44:28 +02:00
|
|
|
SLOT(highlightSearchTerms()));
|
|
|
|
|
viewer->setSource(url);
|
|
|
|
|
viewer->setFocus(Qt::OtherFocusReason);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
void CentralWidget::showTopicChooser(const QMap<QString, QUrl> &links,
|
|
|
|
|
const QString &keyword)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
TopicChooser tc(this, keyword, links);
|
|
|
|
|
if (tc.exec() == QDialog::Accepted)
|
|
|
|
|
setSource(tc.link());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
// -- protected
|
2010-01-29 21:33:57 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void CentralWidget::focusInEvent(QFocusEvent * /* event */)
|
|
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
// If we have a current help viewer then this is the 'focus proxy',
|
|
|
|
|
// otherwise it's the central widget. This is needed, so an embedding
|
|
|
|
|
// program can just set the focus to the central widget and it does
|
|
|
|
|
// The Right Thing(TM)
|
|
|
|
|
QObject *receiver = m_stackedWidget;
|
|
|
|
|
if (HelpViewer *viewer = currentHelpViewer())
|
|
|
|
|
receiver = viewer;
|
2009-06-04 13:12:20 +02:00
|
|
|
QTimer::singleShot(1, receiver, SLOT(setFocus()));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
// -- private slots
|
|
|
|
|
|
|
|
|
|
void CentralWidget::highlightSearchTerms()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
if (HelpViewer *viewer = currentHelpViewer()) {
|
2012-11-28 20:28:42 +02:00
|
|
|
QHelpSearchEngine *searchEngine =
|
2010-06-11 13:11:37 +02:00
|
|
|
LocalHelpManager::helpEngine().searchEngine();
|
2010-03-30 17:44:28 +02:00
|
|
|
QList<QHelpSearchQuery> queryList = searchEngine->query();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
QStringList terms;
|
|
|
|
|
foreach (const QHelpSearchQuery &query, queryList) {
|
|
|
|
|
switch (query.fieldName) {
|
|
|
|
|
default: break;
|
|
|
|
|
case QHelpSearchQuery::ALL: {
|
|
|
|
|
case QHelpSearchQuery::PHRASE:
|
|
|
|
|
case QHelpSearchQuery::DEFAULT:
|
|
|
|
|
case QHelpSearchQuery::ATLEAST:
|
|
|
|
|
foreach (QString term, query.wordList)
|
2011-04-19 15:42:14 +02:00
|
|
|
terms.append(term.remove(QLatin1Char('"')));
|
2009-06-25 15:20:38 +02:00
|
|
|
}
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2010-03-30 17:44:28 +02:00
|
|
|
|
|
|
|
|
foreach (const QString& term, terms)
|
|
|
|
|
viewer->findText(term, 0, false, true);
|
2014-05-02 16:54:28 +02:00
|
|
|
disconnect(viewer, SIGNAL(loadFinished()), this,
|
2010-03-30 17:44:28 +02:00
|
|
|
SLOT(highlightSearchTerms()));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
void CentralWidget::printPreview(QPrinter *p)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
#ifndef QT_NO_PRINTER
|
|
|
|
|
HelpViewer *viewer = currentHelpViewer();
|
|
|
|
|
if (viewer)
|
|
|
|
|
viewer->print(p);
|
2008-12-02 12:01:29 +01:00
|
|
|
#else
|
2010-03-30 17:44:28 +02:00
|
|
|
Q_UNUSED(p)
|
2008-12-02 12:01:29 +01:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
void CentralWidget::handleSourceChanged(const QUrl &url)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
if (sender() == currentHelpViewer())
|
|
|
|
|
emit sourceChanged(url);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
// -- private
|
|
|
|
|
|
|
|
|
|
void CentralWidget::initPrinter()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
#ifndef QT_NO_PRINTER
|
|
|
|
|
if (!printer)
|
|
|
|
|
printer = new QPrinter(QPrinter::HighResolution);
|
|
|
|
|
#endif
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
void CentralWidget::connectSignals(HelpViewer *page)
|
2010-01-18 15:18:23 +01:00
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
connect(page, SIGNAL(sourceChanged(QUrl)), this, SLOT(handleSourceChanged(QUrl)));
|
|
|
|
|
connect(page, SIGNAL(forwardAvailable(bool)), this, SIGNAL(forwardAvailable(bool)));
|
|
|
|
|
connect(page, SIGNAL(backwardAvailable(bool)), this, SIGNAL(backwardAvailable(bool)));
|
2010-06-01 13:13:59 +02:00
|
|
|
connect(page, SIGNAL(printRequested()), this, SLOT(print()));
|
2010-01-18 15:18:23 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-30 17:44:28 +02:00
|
|
|
bool CentralWidget::eventFilter(QObject *object, QEvent *e)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-30 17:44:28 +02:00
|
|
|
if (e->type() != QEvent::KeyPress)
|
|
|
|
|
return QWidget::eventFilter(object, e);
|
|
|
|
|
|
|
|
|
|
HelpViewer *viewer = currentHelpViewer();
|
|
|
|
|
QKeyEvent *keyEvent = static_cast<QKeyEvent*> (e);
|
|
|
|
|
if (viewer == object && keyEvent->key() == Qt::Key_Backspace) {
|
|
|
|
|
if (viewer->isBackwardAvailable()) {
|
|
|
|
|
// this helps in case there is an html <input> field
|
|
|
|
|
if (!viewer->hasFocus())
|
|
|
|
|
viewer->backward();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return QWidget::eventFilter(object, e);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|