mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-25 02:45:38 +00:00
Page up and Page down buttons now work while focus is in the search bar
or in the page number line edit in the minibar. CCBUG: 270524 CCBUG: 274887
This commit is contained in:
parent
69ba0a3878
commit
0213afca46
3
part.cpp
3
part.cpp
|
@ -382,6 +382,9 @@ m_cliPresentation(false), m_embedMode(detectEmbedMode(parentWidget, parent, args
|
|||
bottomBarLayout->addWidget( m_pageSizeLabel );
|
||||
rightLayout->addWidget( m_bottomBar );
|
||||
|
||||
connect( m_findBar, SIGNAL( forwardKeyPressEvent( QKeyEvent* )), m_pageView, SLOT( externalKeyPressEvent( QKeyEvent* ) ));
|
||||
connect( m_miniBar, SIGNAL( forwardKeyPressEvent( QKeyEvent* )), m_pageView, SLOT( externalKeyPressEvent( QKeyEvent* ) ));
|
||||
|
||||
connect( m_reviewsWidget, SIGNAL( setAnnotationWindow( Okular::Annotation* ) ),
|
||||
m_pageView, SLOT( setAnnotationWindow( Okular::Annotation* ) ) );
|
||||
connect( m_reviewsWidget, SIGNAL( removeAnnotationWindow( Okular::Annotation* ) ),
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <qlayout.h>
|
||||
#include <qmenu.h>
|
||||
#include <qtoolbutton.h>
|
||||
#include <qevent.h>
|
||||
#include <kicon.h>
|
||||
#include <klocale.h>
|
||||
#include <kpushbutton.h>
|
||||
|
@ -47,6 +48,7 @@ FindBar::FindBar( Okular::Document * document, QWidget * parent )
|
|||
m_search->lineEdit()->setSearchColor( qRgb( 255, 255, 64 ) );
|
||||
m_search->lineEdit()->setSearchMoveViewport( true );
|
||||
m_search->lineEdit()->setToolTip( i18n( "Text to search for" ) );
|
||||
m_search->installEventFilter( this );
|
||||
label->setBuddy( m_search );
|
||||
lay->addWidget( m_search );
|
||||
|
||||
|
@ -88,6 +90,22 @@ FindBar::~FindBar()
|
|||
{
|
||||
}
|
||||
|
||||
bool FindBar::eventFilter( QObject *target, QEvent *event ) {
|
||||
if ( target == m_search )
|
||||
{
|
||||
if ( event->type() == QEvent::KeyPress )
|
||||
{
|
||||
QKeyEvent *keyEvent = static_cast<QKeyEvent *>( event );
|
||||
if ( keyEvent->key() == Qt::Key_PageUp || keyEvent->key() == Qt::Key_PageDown )
|
||||
{
|
||||
emit forwardKeyPressEvent( keyEvent );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QString FindBar::text() const
|
||||
{
|
||||
return m_search->lineEdit()->text();
|
||||
|
|
|
@ -34,6 +34,9 @@ class FindBar
|
|||
void focusAndSetCursor();
|
||||
bool maybeHide();
|
||||
|
||||
signals:
|
||||
void forwardKeyPressEvent( QKeyEvent* );
|
||||
|
||||
public slots:
|
||||
void findNext();
|
||||
void findPrev();
|
||||
|
@ -47,6 +50,7 @@ class FindBar
|
|||
SearchLineWidget * m_search;
|
||||
QAction * m_caseSensitiveAct;
|
||||
QAction * m_fromCurrentPageAct;
|
||||
bool eventFilter( QObject *target, QEvent *event );
|
||||
bool m_active;
|
||||
};
|
||||
|
||||
|
|
|
@ -81,6 +81,7 @@ MiniBar::MiniBar( QWidget * parent, Okular::Document * document )
|
|||
// bottom: left lineEdit (current page box)
|
||||
m_pagesEdit = new PagesEdit( this );
|
||||
horLayout->addWidget( m_pagesEdit );
|
||||
m_pagesEdit->installEventFilter( this );
|
||||
// bottom: central 'of' label
|
||||
horLayout->addSpacing(5);
|
||||
horLayout->addWidget( new QLabel( i18nc( "Layouted like: '5 [pages] of 10'", "of" ), this ) );
|
||||
|
@ -118,6 +119,23 @@ MiniBar::~MiniBar()
|
|||
m_document->removeObserver( this );
|
||||
}
|
||||
|
||||
bool MiniBar::eventFilter( QObject *target, QEvent *event )
|
||||
{
|
||||
if ( target == m_pagesEdit )
|
||||
{
|
||||
if ( event->type() == QEvent::KeyPress )
|
||||
{
|
||||
QKeyEvent *keyEvent = static_cast<QKeyEvent *>( event );
|
||||
if ( keyEvent->key() == Qt::Key_PageUp || keyEvent->key() == Qt::Key_PageDown )
|
||||
{
|
||||
emit forwardKeyPressEvent( keyEvent );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void MiniBar::notifySetup( const QVector< Okular::Page * > & pageVector, int setupFlags )
|
||||
{
|
||||
// only process data when document changes
|
||||
|
|
|
@ -40,6 +40,7 @@ class MiniBar : public QWidget, public Okular::DocumentObserver
|
|||
void gotoPage();
|
||||
void prevPage();
|
||||
void nextPage();
|
||||
void forwardKeyPressEvent( QKeyEvent *e );
|
||||
|
||||
public slots:
|
||||
void slotChangePage();
|
||||
|
@ -48,6 +49,7 @@ class MiniBar : public QWidget, public Okular::DocumentObserver
|
|||
|
||||
private:
|
||||
void resizeForPage( int pages );
|
||||
bool eventFilter( QObject *target, QEvent *event );
|
||||
|
||||
Okular::Document * m_document;
|
||||
PagesEdit * m_pagesEdit;
|
||||
|
|
|
@ -3696,6 +3696,12 @@ void PageView::slotAction( Okular::Action *action )
|
|||
{
|
||||
d->document->processAction( action );
|
||||
}
|
||||
|
||||
void PageView::externalKeyPressEvent( QKeyEvent *e )
|
||||
{
|
||||
keyPressEvent( e );
|
||||
}
|
||||
|
||||
//END private SLOTS
|
||||
|
||||
#include "pageview.moc"
|
||||
|
|
|
@ -229,6 +229,7 @@ Q_OBJECT
|
|||
void slotSpeakCurrentPage();
|
||||
void slotStopSpeaks();
|
||||
void slotAction( Okular::Action *action );
|
||||
void externalKeyPressEvent( QKeyEvent *e );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue