[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Re: Patch for KPresenter (Auto Presentation wait time)
From:       Toshitaka Fujioka <toshitaka () kde ! gr ! jp>
Date:       2001-08-02 9:52:18
[Download RAW message or body]

On Tuesday 31 July 2001 22:17, David Faure wrote:
> On Tuesday 31 July 2001 11:07, Toshitaka Fujioka wrote:
> > I think that very good idea!!
> > I remade a patch. Please review.
>
> I think the QTimer * is dangerous.

dangerous ?

> How do you make sure you're not creating it multiple times ?
> At least if you want to keep it "built on demand", add a check to see
> if it's not != 0 already.
> Or just use a QTimer member variable (no pointer), that would be simpler.

Ohh, I see.

> Also, why change the interval to a huge number, e.g. one day ? You can stop
> the timer, instead.

I see. I attached a patch. Please review.

Thank you.
-- 
Toshitaka Fujioka
http://www.kde.org                The K Desktop Environment Project
                                                    fujioka@kde.org
http://www.kde.gr.jp               Japan KDE User's Group
                                                    toshitaka@kde.gr.jp

-- We offer the best Desktop Environment to you.  (This is my goal. ;-)) --   
  


["koffice-kpresenter-autoPresentationWaitTime-20010802.diff" (text/x-diff)]

Index: kpresenter_view.cc
===================================================================
RCS file: /home/kde/koffice/kpresenter/kpresenter_view.cc,v
retrieving revision 1.373
diff -u -3 -d -p -r1.373 kpresenter_view.cc
--- kpresenter_view.cc	2001/08/01 16:17:11	1.373
+++ kpresenter_view.cc	2001/08/02 09:43:03
@@ -1084,10 +1084,12 @@ void KPresenterView::startScreenPres( in
 	actionScreenStart->setEnabled( false );
 	actionScreenViewPage->setEnabled( false );
 
-	if ( !kPresenterDoc()->spManualSwitch() ) {
+	if ( !kPresenterDoc()->spManualSwitch() && pgNum == -1 ) {
 	    continuePres = true;
 	    exitPres = false;
-	    doAutomaticScreenPres();
+            page->repaint( false );
+            automaticScreenPresSpeed = 0L;
+            autoScreenPresStartTimer();
 	}
     }
 }
@@ -1153,6 +1155,8 @@ void KPresenterView::screenFirst()
 void KPresenterView::screenPrev()
 {
     if ( presStarted ) {
+        if ( !kPresenterDoc()->spManualSwitch() )
+            autoScreenPresStartTimer();
 	if ( page->pPrev( true ) ) {
             QRect pgRect = kPresenterDoc()->getPageRect( 0, 0, 0, page->presFakt(), \
false );  yOffset = ( page->presPage() - 1 ) * pgRect.height();
@@ -1174,6 +1178,8 @@ void KPresenterView::screenPrev()
 void KPresenterView::screenNext()
 {
     if ( presStarted ) {
+        if ( !kPresenterDoc()->spManualSwitch() )
+            autoScreenPresStartTimer();
 	if ( page->pNext( true ) ) {
             QRect pgRect = kPresenterDoc()->getPageRect( 0, 0, 0, page->presFakt(), \
false );  yOffset = ( page->presPage() - 1 ) * pgRect.height();
@@ -2832,17 +2838,27 @@ void KPresenterView::keyPressEvent( QKey
 /*====================== do automatic screenpresentation ========*/
 void KPresenterView::doAutomaticScreenPres()
 {
-    page->repaint( false );
-
-    while ( continuePres && !exitPres )
-	screenNext();
-
-    if ( !exitPres && kPresenterDoc()->spInfinitLoop() ) {
-	screenStop();
-	screenStart();
+    if ( exitPres ) { // A user pushed Escape key or clicked "Exit presentation" \
menu. +        delete automaticScreenPresSpeed;
+        automaticScreenPresSpeed = 0L;
+        return;
     }
+    else if ( !continuePres && kPresenterDoc()->spInfinitLoop() ) {
+        continuePres = true;
+        page->gotoPage( 1 ); // return to first page.
 
-    screenStop();
+        delete automaticScreenPresSpeed;
+        automaticScreenPresSpeed = 0L;
+        autoScreenPresStartTimer();
+    }
+    else if ( !continuePres ) {
+        screenStop();
+        delete automaticScreenPresSpeed;
+        automaticScreenPresSpeed = 0L;
+        return;
+    }
+    else
+        screenNext();
 }
 
 void KPresenterView::updateReadWrite( bool readwrite )
@@ -3427,6 +3443,30 @@ void KPresenterView::brushColorChanged( 
 {
     actionBrushColor->setEnabled( true );
     actionBrushColor->setCurrentColor(_brush.style ()==Qt::NoBrush ? Qt::white : \
_brush.color() ); +}
+
+void KPresenterView::autoScreenPresStartTimer()
+{
+    if ( automaticScreenPresSpeed != 0L ) {
+        delete automaticScreenPresSpeed;
+        automaticScreenPresSpeed = 0L;
+    }
+    automaticScreenPresSpeed = new QTimer( this );
+    connect( automaticScreenPresSpeed, SIGNAL( timeout() ), SLOT( \
doAutomaticScreenPres() ) ); +    automaticScreenPresTime.start();
+    automaticScreenPresWaitTime = 0;
+    automaticScreenPresSpeed->start( kPresenterDoc()->getPresSpeed()*1000, true );
+}
+
+void KPresenterView::autoScreenPresIntervalTimer()
+{
+    automaticScreenPresTime.restart();
+    automaticScreenPresSpeed->changeInterval( kPresenterDoc()->getPresSpeed()*1000 - \
automaticScreenPresWaitTime ); +}
+void KPresenterView::autoScreenPresStopTimer()
+{
+    automaticScreenPresSpeed->stop();
+    automaticScreenPresWaitTime += automaticScreenPresTime.elapsed();
 }
 
 #include <kpresenter_view.moc>
Index: kpresenter_view.h
===================================================================
RCS file: /home/kde/koffice/kpresenter/kpresenter_view.h,v
retrieving revision 1.133
diff -u -3 -d -p -r1.133 kpresenter_view.h
--- kpresenter_view.h	2001/07/20 13:48:25	1.133
+++ kpresenter_view.h	2001/08/02 09:43:04
@@ -43,6 +43,7 @@ class ConfPieDia;
 class ConfRectDia;
 class QToolButton;
 class SideBar;
+class QTimer;
 
 class KAction;
 class KToggleAction;
@@ -334,6 +335,10 @@ public:
     void penColorChanged( const QPen & _pen );
     void brushColorChanged( const QBrush & _brush );
 
+    void autoScreenPresStartTimer();
+    void autoScreenPresIntervalTimer();
+    void autoScreenPresStopTimer();
+
 protected slots:
     // dialog slots
     void backOk( bool );
@@ -385,6 +390,8 @@ protected slots:
 
     void search();
 
+    void doAutomaticScreenPres();
+
 protected:
 
 // ********* functions ***********
@@ -408,7 +415,6 @@ protected:
     void setupRulers();
 
     void startScreenPres( int pgNum = -1 );
-    void doAutomaticScreenPres();
 
     virtual void updateReadWrite( bool readwrite );
 
@@ -596,6 +602,11 @@ protected:
     SideBar *sidebar;
     QSplitter *splitter;
     PageBase *pageBase;
+
+private:
+    QTimer *automaticScreenPresSpeed;
+    QTime automaticScreenPresTime;
+    int automaticScreenPresWaitTime;
 
 };
 
Index: page.cc
===================================================================
RCS file: /home/kde/koffice/kpresenter/page.cc,v
retrieving revision 1.232
diff -u -3 -d -p -r1.232 page.cc
--- page.cc	2001/07/20 13:48:25	1.232
+++ page.cc	2001/08/02 09:43:21
@@ -437,6 +437,9 @@ void Page::mousePressEvent( QMouseEvent 
         } else if ( e->button() == MidButton )
             view->screenPrev();
         else if ( e->button() == RightButton ) {
+            if ( !drawMode && !spManualSwitch() )
+                view->autoScreenPresStopTimer();
+
             setCursor( arrowCursor );
             QPoint pnt = QCursor::pos();
             presMenu->popup( pnt );
@@ -1091,6 +1094,8 @@ void Page::keyPressEvent( QKeyEvent *e )
 	case Key_Escape: case Key_Q: case Key_X:
 	    view->screenStop(); break;
 	case Key_G:
+            if ( !spManualSwitch() )
+                view->autoScreenPresStopTimer();
 	    slotGotoPage(); break;
 	default: break;
 	}
@@ -3503,6 +3508,9 @@ void Page::slotGotoPage()
     int pg = currPresPage;
     pg = KPGotoPage::gotoPage( view->kPresenterDoc(), _presFakt, slideList, pg, this \
);  gotoPage( pg );
+
+    if ( !spManualSwitch() )
+        view->autoScreenPresStartTimer();
 }
 
 /*================================================================*/
@@ -3725,6 +3733,9 @@ void Page::switchingMode()
     presMenu->setItemChecked( PM_DM, false );
     presMenu->setItemChecked( PM_SM, true );
     drawMode = false; setCursor( blankCursor );
+
+    if ( !spManualSwitch() )
+        view->autoScreenPresIntervalTimer();
 }
 
 /*================================================================*/


_______________________________________________
Koffice-devel mailing list
Koffice-devel@master.kde.org
http://master.kde.org/mailman/listinfo/koffice-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic