Version: (using KDE KDE 3.0.3) Installed from: SuSE RPMs OS: Linux KDE HelpCentre correctly scrolls through a page when the space bar is used. Since all (?) help pages seem to have a "Next" link, could hitting the space bar when at the bottom of a page follow the "Next" link?
Probably not possible with just the space bar, but we ought to be able to add some kind of keybinding to the links, which I hope would be satisfactory for you. I've changed the summary a little to make it easier to find if duplicate reports come up.
I find the idea quite nice and perhaps it's even easier to do than the key navigation as this requires an implemented feature in khtml.
Seems accesskeys are already created, and header links as well, but accesskey support is not available in khtml yet (45788 is the wishlist item) In either case, this will have to wait for 3.2.
Subject: kdebase/khelpcenter CVS commit by raabe: - Pressing Space again at the bottom of the page will follow the Next link, pressing Shift+Space at the top of the page will follow the Previous link. CCMAIL:48259-done@bugs.kde.org M +47 -0 view.cpp 1.13 M +8 -0 view.h 1.11 --- kdebase/khelpcenter/view.cpp #1.12:1.13 @@ -4,4 +4,7 @@ #include <klocale.h> #include <kdebug.h> +#include <khtmlview.h> +#include <dom/html_document.h> +#include <dom/html_misc.h> @@ -31,4 +34,6 @@ View::View( QWidget *parentWidget, const } } + + view()->installEventFilter( this ); } @@ -190,4 +195,46 @@ void View::slotDecFontSizes() { setZoomFactor( zoomFactor() - m_zoomStepping ); +} + +bool View::eventFilter( QObject *o, QEvent *e ) +{ + if ( e->type() != QEvent::KeyPress ) + return false; + + QKeyEvent *ke = static_cast<QKeyEvent *>( e ); + if ( ke->state() & Qt::ShiftButton && ke->key() == Key_Space ) { + const QScrollBar * const scrollBar = view()->verticalScrollBar(); + if ( scrollBar->value() == scrollBar->minValue() ) { + const DOM::HTMLCollection links = htmlDocument().links(); + const DOM::Node prevLinkNode = links.item( 0 ); + openURL( urlFromLinkNode( prevLinkNode ) ); + return true; + } + } else if ( ke->key() == Key_Space ) { + const QScrollBar * const scrollBar = view()->verticalScrollBar(); + if ( scrollBar->value() == scrollBar->maxValue() ) { + const DOM::HTMLCollection links = htmlDocument().links(); + const DOM::Node nextLinkNode = links.item( links.length() - 2 ); + openURL( urlFromLinkNode( nextLinkNode ) ); + return true; + } + } + return false; +} + +KURL View::urlFromLinkNode( const DOM::Node &n ) const +{ + if ( n.nodeType() != DOM::Node::ELEMENT_NODE ) + return KURL(); + + DOM::Element elem = static_cast<DOM::Element>( n ); + + QString link = baseURL().path(); + link.truncate( link.findRev( '/' ) + 1 ); + link += "/" + elem.getAttribute( "href" ).string(); + + KURL url = baseURL(); + url.setPath( link ); + return url; } --- kdebase/khelpcenter/view.h #1.10:1.11 @@ -7,4 +7,8 @@ #include "navigator.h" +namespace DOM { + class Node; +} + namespace KHC { @@ -42,4 +46,7 @@ class View : public KHTMLPart void searchResultCacheAvailable(); + protected: + bool eventFilter( QObject *o, QEvent *e ); + private slots: void setTitle( const QString &title ); @@ -47,4 +54,5 @@ class View : public KHTMLPart private: void showAboutPage(); + KURL urlFromLinkNode( const DOM::Node &n ) const; int mState;