Hi! Few days ago I've created a patch for Okular. It improves the presentation-mode. It's an implementation of the following brainstorm-idea: http://forum.kde.org/viewtopic.php?f=83&t=63415 I hope it will be integrated into Okular.
Thanks! The User
Index: CMakeLists.txt =================================================================== --- CMakeLists.txt (Revision 1005676) +++ CMakeLists.txt (Arbeitskopie) @@ -11,7 +11,7 @@ if( WIN32 ) find_package( Expat ) endif( WIN32 ) -find_package( LibKNotificationItem-1 REQUIRED ) +#find_package( LibKNotificationItem-1 REQUIRED ) #require by libs/libkdcraw, gwenview, and okular find_package(JPEG REQUIRED) Index: okular/ui/presentationwidget.h =================================================================== --- okular/ui/presentationwidget.h (Revision 1005676) +++ okular/ui/presentationwidget.h (Arbeitskopie) @@ -25,6 +25,8 @@ class AnnotatorEngine; struct PresentationFrame; class PresentationSearchBar; +class QSpinBox; +class KIcon; namespace Okular { class Action; @@ -120,9 +122,13 @@ QStringList m_metaStrings; QToolBar * m_topBar; QLineEdit *m_pagesEdit; + QSpinBox *m_speedBox; PresentationSearchBar *m_searchBar; KActionCollection * m_ac; KSelectAction * m_screenSelect; + QAction *m_playPauseAction; + KIcon *m_playIcon; + KIcon *m_pauseIcon; bool m_isSetup; bool m_blockNotifications; bool m_inBlackScreenMode; @@ -141,6 +147,8 @@ void screenResized( int ); void chooseScreen( QAction * ); void toggleBlackScreenMode( bool ); + void changeSpeed( int ); + void playPause(); }; #endif Index: okular/ui/presentationwidget.cpp =================================================================== --- okular/ui/presentationwidget.cpp (Revision 1005676) +++ okular/ui/presentationwidget.cpp (Arbeitskopie) @@ -28,6 +28,7 @@ #include <qvalidator.h> #include <qapplication.h> #include <qdesktopwidget.h> +#include <qspinbox.h> #include <kcursor.h> #include <krandom.h> #include <qtoolbar.h> @@ -40,6 +41,7 @@ #include <kselectaction.h> #include <kshortcut.h> #include <kdialog.h> +#include <kicon.h> // system includes #include <stdlib.h> @@ -128,9 +130,10 @@ PresentationWidget::PresentationWidget( QWidget * parent, Okular::Document * doc, KActionCollection * collection ) : QWidget( 0 /* must be null, to have an independent widget */, Qt::FramelessWindowHint ), m_pressedLink( 0 ), m_handCursor( false ), m_drawingEngine( 0 ), m_screenSaverCookie( -1 ), - m_parentWidget( parent ), - m_document( doc ), m_frameIndex( -1 ), m_topBar( 0 ), m_pagesEdit( 0 ), m_searchBar( 0 ), - m_screenSelect( 0 ), m_isSetup( false ), m_blockNotifications( false ), m_inBlackScreenMode( false ) + m_parentWidget( parent ), m_document( doc ), m_frameIndex( -1 ), m_topBar( 0 ), m_pagesEdit( 0 ), + m_speedBox( 0 ), m_searchBar( 0 ), m_screenSelect( 0 ), m_playPauseAction( 0 ), + m_playIcon( new KIcon( "media-playback-start" ) ), m_pauseIcon( new KIcon( "media-playback-pause" ) ), + m_isSetup( false ), m_blockNotifications( false ), m_inBlackScreenMode( false ) { Q_UNUSED( parent ) setAttribute( Qt::WA_DeleteOnClose ); @@ -156,6 +159,17 @@ QSizePolicy sp = m_pagesEdit->sizePolicy(); sp.setHorizontalPolicy( QSizePolicy::Minimum ); m_pagesEdit->setSizePolicy( sp ); + m_speedBox = new QSpinBox( m_topBar ); + if(Okular::Settings::slidesAdvance()) + m_playPauseAction = new QAction( *m_pauseIcon, i18n( "Pause" ), m_topBar ); + else + { + m_playPauseAction = new QAction( *m_playIcon, i18n( "Continue" ), m_topBar ); + m_playPauseAction->setDisabled(true); + } + sp = m_speedBox->sizePolicy(); + sp.setHorizontalPolicy( QSizePolicy::Minimum ); + m_speedBox->setSizePolicy(sp); QFontMetrics fm( m_pagesEdit->font() ); QStyleOptionFrame option; option.initFrom( m_pagesEdit ); @@ -177,6 +191,9 @@ connect( eraseDrawingAct, SIGNAL( triggered() ), SLOT( clearDrawings() ) ); m_topBar->addAction( eraseDrawingAct ); addAction( eraseDrawingAct ); + m_topBar->addSeparator(); + m_topBar->addWidget(m_speedBox); + m_topBar->addAction(m_playPauseAction); QDesktopWidget *desktop = QApplication::desktop(); if ( desktop->numScreens() > 1 ) { @@ -216,7 +233,12 @@ m_nextPageTimer = new QTimer( this ); m_nextPageTimer->setSingleShot( true ); connect( m_nextPageTimer, SIGNAL( timeout() ), this, SLOT( slotNextPage() ) ); - + m_speedBox->setSuffix( i18n( "s" ) ); + m_speedBox->setValue(Okular::Settings::slidesAdvanceTime()); + m_speedBox->setMinimum(0); + connect( m_speedBox, SIGNAL( valueChanged( int ) ), this, SLOT( changeSpeed( int ) ) ); + connect( m_playPauseAction, SIGNAL( triggered() ), this, SLOT( playPause() ) ); + // handle cursor appearance as specified in configuration if ( Okular::Settings::slidesCursor() == Okular::Settings::EnumSlidesCursor::HiddenDelay ) { @@ -261,7 +283,8 @@ drawingAct->toggle(); m_document->removePageAnnotations( m_document->viewport().pageNumber, m_currentPageDrawings ); delete m_drawingEngine; - + delete m_pauseIcon; + delete m_playIcon; // delete frames QVector< PresentationFrame * >::iterator fIt = m_frames.begin(), fEnd = m_frames.end(); for ( ; fIt != fEnd; ++fIt ) @@ -432,6 +455,11 @@ else close(); break; + case Qt::Key_Enter: + case Qt::Key_P: + if( Okular::Settings::slidesAdvance() ) + playPause(); + break; } } @@ -1169,6 +1197,9 @@ changePage( m_frameIndex + 1 ); // auto advance to the next page if set startAutoChangeTimer(); + + // if you wouldn't call update pages would sometimes be skipped (because they are never drawn) + update(); } else { @@ -1919,5 +1950,31 @@ m_transitionTimer->start( 0 ); } +void PresentationWidget::changeSpeed( int seconds ) +{ + Okular::Settings::setSlidesAdvanceTime( seconds ); + m_nextPageTimer->stop(); + m_playPauseAction->setDisabled( seconds == 0 ); + m_playPauseAction->setIcon( *m_playIcon ); + m_playPauseAction->setText( i18n( "Continue" ) ); +} +void PresentationWidget::playPause() +{ + if(m_nextPageTimer->isActive()) + { + m_nextPageTimer->stop(); + m_playPauseAction->setIcon( *m_playIcon ); + m_playPauseAction->setText( i18n( "Continue" ) ); + } + else + { + // When you press continue, you usually want to see the next page + slotNextPage(); + startAutoChangeTimer(); + m_playPauseAction->setIcon( *m_pauseIcon ); + m_playPauseAction->setText( i18n( "Pause" ) ); + } +} + #include "presentationwidget.moc"
_______________________________________________ Okular-devel mailing list Okular-devel@kde.org https://mail.kde.org/mailman/listinfo/okular-devel