This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Automatic scrolling for E-books

24

Votes
26
2
Tags: okular okular okular
(comma "," separated)
tvpaker
Registered Member
Posts
44
Karma
0
Hello,
I\'ve read this idea:

viewtopic.php?f=83&t=40161&p=58496&hilit=okular+scrolling#p58496

and i think it should be a function in Okular that would enable you to read e-books but not as complicated as in the link above. What I mean is simple function of automatic scrolling in which you could configure speed and e.g to make pause scrolling by pressing space.
This function is not only useful in reading e-book but viewing pictures, quick reading tables, presentations and so on.
What do you think, do you like this function?
User avatar
Giacomo
Registered Member
Posts
142
Karma
1
OS
If I understand rightly your idea...you can auto-scroll pages by using the Shift + Arrow keys: Shift + Up to scroll up, Shift + Down to scroll down. Keeping Shift and pushing more and more the Arrow keys you can also modify the speed.


UserBase, il wiki degli utenti KDE
tvpaker
Registered Member
Posts
44
Karma
0
I meant something fully automatic with out necessity of pressing Shift button. It would be much easier for e-books readers and e.g. people making keynotes to have such a function in Okular. The comfort of reading is much better when you would sat on a chair, drank fizzy drinks and didn't bother pressing Shift button. You are only concentrated on reading. I think that Keynote's presenters would also rather to be focus on presenting keynote, talking to people than pressing the button.
User avatar
Giacomo
Registered Member
Posts
142
Karma
1
OS
So, from a simple user experience point of view, a toolbar-shortcut for auto-scroll? Or with "Automatic" do you think "I open it and it starts to scroll" ?


UserBase, il wiki degli utenti KDE
tvpaker
Registered Member
Posts
44
Karma
0
Yes, this is exactly what I mean.
The User
KDE Developer
Posts
647
Karma
0
OS
There'll always be 5 seconds difference at minimum. In this time I prefer pressing shift+arrow. Some pages have a lot of pictures, other pages have test-only. Maybe you have to read source-code or formulas - this is maybe slower - or you have to read tables - this is maybe faster. So the pauses will be even bigger.

But for slide-shows it would be nice.

PS:
You could also create a simple script. You specify the time, the application and the DBus-command. Maybe 25 lines of code.
tvpaker
Registered Member
Posts
44
Karma
0
Sorry but I am a just simple user. I know how it sounds but I am interested in KDE because of it functionality and beaty and want to develop it by simple ideas. I have never seen the code of any programs ;) . It's magic for me ;D
The User
KDE Developer
Posts
647
Karma
0
OS
Hehe, okay.
There's a technology called DBus. When you open "qdbusviewer" you will see an overview of applications containing some actions. And you can invoke those actions (like next-page) from other applications or scripts. Recognizing keypresses is very simple, waiting few seconds is very simple and repetition is also very simple.

PS:
I had nothing todo and I wanted to learn something about DBus and Ruby. So I've implemented it.
http://kde-apps.org/content/show.php?content=109394
(writing descriptions and searching the kde-apps-password tokk more time than writing the script :D)

Please mark this thread as [Done].
pinotree
KDE Developer
Posts
222
Karma
7
OS
Please note that you can configure a delay for going to the next page while in presentation mode (which is half of what the script does).


Pino Toscano
The User
KDE Developer
Posts
647
Karma
0
OS
The menu in presentation mode would have enough space for a delay configuration.

PS:
I could create a SVN-patch with play/pause-buttons and a delay-spinbox. Is it okay?

(and please don't move it to Done before the discussion is over ;))

PPS:
With this Okular-Patch you can change the speed directly from presentation-mode, you have a pause-button (or you may want to use p or Enter) and a bug is fixed:

Code: Select all
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"


Could you apply it to the SVN-tree? ;)
tvpaker
Registered Member
Posts
44
Karma
0
PPS:
With this Okular-Patch you can change the speed directly from presentation-mode, you have a pause-button (or you may want to use p or Enter) and a bug is fixed:

I think that a pause-button is better
The User
KDE Developer
Posts
647
Karma
0
OS
The patch modifies the presentation mode:
In the toolbar you can modify the speed and you've a pause-button. Alternatively you can use p or Enter.
tvpaker
Registered Member
Posts
44
Karma
0
Oh sorry. I didn't understand.
The User
KDE Developer
Posts
647
Karma
0
OS
Here you can see it without compilation:
Image
tvpaker
Registered Member
Posts
44
Karma
0
Very nice. Can't wait to see it included in next Okular update.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]