Hi!
I've integrated some new ideas into the presentation mode:
-Whene 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: generators/CMakeLists.txt
===================================================================
--- generators/CMakeLists.txt (revision 1018567)
+++ generators/CMakeLists.txt (working copy)
@@ -31,9 +31,9 @@
# let's enable the generators properly configured
-if(POPPLER_FOUND AND HAVE_POPPLER_0_8)
+#if(POPPLER_FOUND AND HAVE_POPPLER_0_8)
add_subdirectory(poppler)
-endif(POPPLER_FOUND AND HAVE_POPPLER_0_8)
+#endif(POPPLER_FOUND AND HAVE_POPPLER_0_8)
if(LIBSPECTRE_FOUND)
add_subdirectory(spectre)
Index: ui/presentationwidget.h
===================================================================
--- ui/presentationwidget.h (revision 1018567)
+++ 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,9 +123,14 @@
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;
@@ -141,6 +149,8 @@
void screenResized( int );
void chooseScreen( QAction * );
void toggleBlackScreenMode( bool );
+ void changeSpeed( int );
+ void playPause();
};
#endif
Index: ui/presentationwidget.cpp
===================================================================
--- ui/presentationwidget.cpp (revision 1018567)
+++ 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 )
{
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::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 +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,14 @@
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 )
- {
- double secs = pageDuration < 0.0
- ? Okular::Settings::slidesAdvanceTime()
- : qMin<double>( pageDuration, Okular::Settings::slidesAdvanceTime() );
- m_nextPageTimer->start( (int)( secs * 1000 ) );
- }
+ if ( m_frameIndex < 0 || m_frameIndex >= m_frames.count() )
+ return;
+ double pageDuration = m_frames[ m_frameIndex ]->page->duration();
+ bool hasUserDuration = Okular::Settings::slidesAdvance();
+ if ( pageDuration >= 0 && !( hasUserDuration && m_overWriteCheckBox->isChecked() ) )
+ m_nextPageTimer->start( (int)( pageDuration * 1000 ) );
+ else if ( hasUserDuration )
+ m_nextPageTimer->start( (int)( Okular::Settings::slidesAdvanceTime() * 1000 ) );
}
void PresentationWidget::recalcGeometry()
@@ -1169,6 +1204,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 +1957,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
[email protected]
https://mail.kde.org/mailman/listinfo/okular-devel