From b4dd2080bee32e3feaf652893eb73d95957e6feb Mon Sep 17 00:00:00 2001 From: kh1 Date: Wed, 22 Sep 2010 15:01:33 +0200 Subject: Implement opening find toolbar after '/' as requested by hjk. --- src/plugins/help/centralwidget.cpp | 1 + src/plugins/help/centralwidget.h | 1 + src/plugins/help/helpplugin.cpp | 11 +++++++++++ src/plugins/help/helpplugin.h | 2 ++ src/plugins/help/helpviewer.h | 1 + src/plugins/help/helpviewer_qtb.cpp | 7 +++++++ src/plugins/help/helpviewer_qwv.cpp | 8 ++++++++ 7 files changed, 31 insertions(+) diff --git a/src/plugins/help/centralwidget.cpp b/src/plugins/help/centralwidget.cpp index c7900b457a..34e234e1f9 100644 --- a/src/plugins/help/centralwidget.cpp +++ b/src/plugins/help/centralwidget.cpp @@ -369,6 +369,7 @@ void CentralWidget::connectSignals(HelpViewer *page) connect(page, SIGNAL(forwardAvailable(bool)), this, SIGNAL(forwardAvailable(bool))); connect(page, SIGNAL(backwardAvailable(bool)), this, SIGNAL(backwardAvailable(bool))); connect(page, SIGNAL(printRequested()), this, SLOT(print())); + connect(page, SIGNAL(openFindToolBar()), this, SIGNAL(openFindToolBar())); } bool CentralWidget::eventFilter(QObject *object, QEvent *e) diff --git a/src/plugins/help/centralwidget.h b/src/plugins/help/centralwidget.h index f3928e43ab..e2b11c9b12 100644 --- a/src/plugins/help/centralwidget.h +++ b/src/plugins/help/centralwidget.h @@ -97,6 +97,7 @@ protected: void focusInEvent(QFocusEvent *event); signals: + void openFindToolBar(); void currentViewerChanged(); void sourceChanged(const QUrl &url); void forwardAvailable(bool available); diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp index ca218cc68e..81e93170f1 100644 --- a/src/plugins/help/helpplugin.cpp +++ b/src/plugins/help/helpplugin.cpp @@ -62,6 +62,7 @@ #include #include #include +#include #include #include #include @@ -180,6 +181,8 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error) m_centralWidget = new Help::Internal::CentralWidget(); connect(m_centralWidget, SIGNAL(sourceChanged(QUrl)), this, SLOT(updateSideBarSource(QUrl))); + connect(m_centralWidget, SIGNAL(openFindToolBar()), this, + SLOT(openFindToolBar())); // Add Home, Previous and Next actions (used in the toolbar) QAction *action = new QAction(QIcon(QLatin1String(IMAGEPATH "home.png")), @@ -568,6 +571,8 @@ void HelpPlugin::createRightPaneContextViewer() rightPaneLayout->addWidget(rightPaneStyledBar); m_helpViewerForSideBar = new HelpViewer(qreal(0.0), rightPaneSideBar); + connect(m_helpViewerForSideBar, SIGNAL(openFindToolBar()), this, + SLOT(openFindToolBar())); #if !defined(QT_NO_WEBKIT) m_helpViewerForSideBar->pageAction(QWebPage::OpenLinkInNewWindow)->setVisible(false); #endif @@ -1119,6 +1124,12 @@ void HelpPlugin::slotOpenActionUrl(QAction *action) #endif } +void HelpPlugin::openFindToolBar() +{ + if (Find::FindPlugin::instance()) + Find::FindPlugin::instance()->openFindToolBar(Find::FindPlugin::FindForward); +} + void HelpPlugin::doSetupIfNeeded() { m_helpManager->setupGuiHelpEngine(); diff --git a/src/plugins/help/helpplugin.h b/src/plugins/help/helpplugin.h index 3cb96a6c9c..8330b96f7f 100644 --- a/src/plugins/help/helpplugin.h +++ b/src/plugins/help/helpplugin.h @@ -110,6 +110,8 @@ private slots: void slotAboutToShowNextMenu(); void slotOpenActionUrl(QAction *action); + void openFindToolBar(); + private: void setupUi(); void resetFilter(); diff --git a/src/plugins/help/helpviewer.h b/src/plugins/help/helpviewer.h index 43e1bfea0d..2f7405667b 100644 --- a/src/plugins/help/helpviewer.h +++ b/src/plugins/help/helpviewer.h @@ -105,6 +105,7 @@ public slots: signals: void titleChanged(); void printRequested(); + void openFindToolBar(); #if !defined(QT_NO_WEBKIT) void sourceChanged(const QUrl &); diff --git a/src/plugins/help/helpviewer_qtb.cpp b/src/plugins/help/helpviewer_qtb.cpp index 2717712692..7cef9c543c 100644 --- a/src/plugins/help/helpviewer_qtb.cpp +++ b/src/plugins/help/helpviewer_qtb.cpp @@ -320,6 +320,13 @@ bool HelpViewer::eventFilter(QObject *obj, QEvent *event) { if (event->type() == QEvent::FontChange && !d->forceFont) return true; + + if (event->type() == QEvent::KeyPress) { + if (QKeyEvent *keyEvent = static_cast (event)) { + if (keyEvent->key() == Qt::Key_Slash) + emit openFindToolBar(); + } + } return QTextBrowser::eventFilter(obj, event); } diff --git a/src/plugins/help/helpviewer_qwv.cpp b/src/plugins/help/helpviewer_qwv.cpp index 8f8968815f..993afb09a1 100644 --- a/src/plugins/help/helpviewer_qwv.cpp +++ b/src/plugins/help/helpviewer_qwv.cpp @@ -232,6 +232,8 @@ HelpViewer::HelpViewer(qreal zoom, QWidget *parent) : QWebView(parent) { setAcceptDrops(false); + installEventFilter(this); + settings()->setAttribute(QWebSettings::JavaEnabled, false); settings()->setAttribute(QWebSettings::PluginsEnabled, false); @@ -439,6 +441,12 @@ void HelpViewer::setLoadFinished(bool ok) bool HelpViewer::eventFilter(QObject *obj, QEvent *event) { + if (event->type() == QEvent::KeyPress) { + if (QKeyEvent *keyEvent = static_cast (event)) { + if (keyEvent->key() == Qt::Key_Slash) + emit openFindToolBar(); + } + } return QWebView::eventFilter(obj, event); } -- cgit v1.2.1