Hi Okular-Developers! Do you remember my previous patch? Now I have removed some mistakes and I hope it works perfectly for everybody.
Jonathan > Hi! > I've integrated some new ideas into the presentation mode > -When there weren't any page-durations in the document, everything was fine with the user-configuration. But whene there are durations defined by the document, the behaviour is strange for the user (min(pageduration, userduration)) > -For that case the patch displays a checkbox, when you activate it, the user preference will be prefered, when you deactivate it, the page-duration will be used (if possible) > -There are still the enhancements from my previous patch > I hope everything is okay! ;) >Jonathan
Index: CMakeLists.txt =================================================================== --- CMakeLists.txt (revision 1026016) +++ CMakeLists.txt (working copy) @@ -1,6 +1,6 @@ project(kdegraphics) -set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules ) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/modules ) # search packages used by KDE find_package(KDE4 REQUIRED) Index: okular/ui/presentationwidget.h =================================================================== --- okular/ui/presentationwidget.h (revision 1026016) +++ okular/ui/presentationwidget.h (working copy) @@ -14,6 +14,7 @@ #include <qpixmap.h> #include <qstringlist.h> #include <qwidget.h> +#include <kicon.h> #include "core/observer.h" #include "core/pagetransition.h" @@ -25,6 +26,8 @@ class AnnotatorEngine; struct PresentationFrame; class PresentationSearchBar; +class QCheckBox; +class QSpinBox; namespace Okular { class Action; @@ -120,12 +123,18 @@ QStringList m_metaStrings; QToolBar * m_topBar; QLineEdit *m_pagesEdit; + QCheckBox *m_overWriteCheckBox; + 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; + bool m_nextPageTimerIsActive; private slots: void slotNextPage(); @@ -141,6 +150,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 1026016) +++ okular/ui/presentationwidget.cpp (working copy) @@ -27,7 +27,9 @@ #include <qtooltip.h> #include <qvalidator.h> #include <qapplication.h> +#include <qcheckbox.h> #include <qdesktopwidget.h> +#include <qspinbox.h> #include <kcursor.h> #include <krandom.h> #include <qtoolbar.h> @@ -40,6 +42,7 @@ #include <kselectaction.h> #include <kshortcut.h> #include <kdialog.h> +#include <kicon.h> // system includes #include <stdlib.h> @@ -128,9 +131,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_overWriteCheckBox( 0 ), m_speedBox( 0 ), m_searchBar( 0 ), m_screenSelect( 0 ), + m_playPauseAction( 0 ), m_playIcon( "media-playback-start" ), m_pauseIcon( "media-playback-pause" ), + m_isSetup( false ), m_blockNotifications( false ), m_inBlackScreenMode( false ), m_nextPageTimerIsActive(false) { Q_UNUSED( parent ) setAttribute( Qt::WA_DeleteOnClose ); @@ -156,6 +160,20 @@ QSizePolicy sp = m_pagesEdit->sizePolicy(); sp.setHorizontalPolicy( QSizePolicy::Minimum ); m_pagesEdit->setSizePolicy( sp ); + m_overWriteCheckBox = new QCheckBox( m_topBar ); + m_overWriteCheckBox->setToolTip( i18n( "Activate to ignore file-specific page-durations" ) ); + m_overWriteCheckBox->setVisible( false ); + 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 +195,10 @@ connect( eraseDrawingAct, SIGNAL( triggered() ), SLOT( clearDrawings() ) ); m_topBar->addAction( eraseDrawingAct ); addAction( eraseDrawingAct ); + m_topBar->addSeparator(); + m_topBar->addWidget( m_overWriteCheckBox ); + m_topBar->addWidget( m_speedBox ); + m_topBar->addAction( m_playPauseAction ); QDesktopWidget *desktop = QApplication::desktop(); if ( desktop->numScreens() > 1 ) { @@ -216,7 +238,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::slidesAdvance() ? Okular::Settings::slidesAdvanceTime() : 0 ); + 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 +288,6 @@ drawingAct->toggle(); m_document->removePageAnnotations( m_document->viewport().pageNumber, m_currentPageDrawings ); delete m_drawingEngine; - // delete frames QVector< PresentationFrame * >::iterator fIt = m_frames.begin(), fEnd = m_frames.end(); for ( ; fIt != fEnd; ++fIt ) @@ -287,8 +313,11 @@ // create the new frames QVector< Okular::Page * >::const_iterator setIt = pageSet.begin(), setEnd = pageSet.end(); float screenRatio = (float)m_height / (float)m_width; + bool hasFrameTimes = false; for ( ; setIt != setEnd; ++setIt ) { + if ( (*setIt)->duration() >= 0. ) + hasFrameTimes = true; PresentationFrame * frame = new PresentationFrame(); frame->page = *setIt; const QLinkedList< Okular::Annotation * > annotations = (*setIt)->annotations(); @@ -308,7 +337,8 @@ // add the frame to the vector m_frames.push_back( frame ); } - + // against confusion + m_overWriteCheckBox->setVisible ( hasFrameTimes ); // get metadata from the document m_metaStrings.clear(); const Okular::DocumentInfo * info = m_document->documentInfo(); @@ -432,6 +462,11 @@ else close(); break; + case Qt::Key_Enter: + case Qt::Key_P: + //if( Okular::Settings::slidesAdvance() ) + playPause(); + break; } } @@ -1075,14 +1110,25 @@ void PresentationWidget::startAutoChangeTimer() { - double pageDuration = m_frameIndex >= 0 && m_frameIndex < (int)m_frames.count() ? m_frames[ m_frameIndex ]->page->duration() : -1; - if ( Okular::Settings::slidesAdvance() || pageDuration >= 0.0 ) + if ( m_frameIndex < 0 || m_frameIndex >= m_frames.count() ) { - double secs = pageDuration < 0.0 - ? Okular::Settings::slidesAdvanceTime() - : qMin<double>( pageDuration, Okular::Settings::slidesAdvanceTime() ); - m_nextPageTimer->start( (int)( secs * 1000 ) ); + m_nextPageTimerIsActive = false; + return; } + double pageDuration = m_frames[ m_frameIndex ]->page->duration(); + bool hasUserDuration = Okular::Settings::slidesAdvance(); + qDebug() << "Page: " << pageDuration << " User: " << hasUserDuration; + if ( pageDuration >= 0 && !( hasUserDuration && m_overWriteCheckBox->isChecked() ) ) + { + m_nextPageTimerIsActive = true; + m_nextPageTimer->start( (int)( pageDuration * 1000 ) ); + } + else if ( hasUserDuration ) + { + m_nextPageTimerIsActive = true; + m_nextPageTimer->start( (int)( Okular::Settings::slidesAdvanceTime() * 1000 ) ); + } + m_nextPageTimerIsActive = false; } void PresentationWidget::recalcGeometry() @@ -1169,6 +1215,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 { @@ -1195,6 +1244,8 @@ // auto advance to the next page if set startAutoChangeTimer(); + + update(); } else { @@ -1919,5 +1970,34 @@ m_transitionTimer->start( 0 ); } +void PresentationWidget::changeSpeed( int seconds ) +{ + Okular::Settings::setSlidesAdvanceTime( seconds ); + Okular::Settings::setSlidesAdvance( seconds != 0 ); + m_nextPageTimer->stop(); + m_playPauseAction->setDisabled( seconds == 0 ); + m_playPauseAction->setIcon( m_playIcon ); + m_playPauseAction->setText( i18n( "Continue" ) ); +} +void PresentationWidget::playPause() +{ + if(m_nextPageTimerIsActive) + { + m_nextPageTimerIsActive = false; + qDebug() << "Stop"; + m_nextPageTimer->stop(); + m_playPauseAction->setIcon( m_playIcon ); + m_playPauseAction->setText( i18n( "Continue" ) ); + } + else + { + qDebug() << "Continue"; + // When you press continue, you usually want to see the next page + slotNextPage(); + 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