Commit 70ea81ca authored by Enrico Ros's avatar Enrico Ros

Added full screen 'Presentation' support. Only Replace and Dissolve pdf

effects are implemented for now. TODO: detect Transitions from the PDF
(maybe xpdf don't tell us).
Adding this (another DocumentObserver) is helping me to better focus the
'memory manager' concept. But still there are some clouds..

svn path=/branches/kpdf_experiments/kdegraphics/kpdf/; revision=371429
parent 58797ffe
......@@ -42,7 +42,7 @@ shellrc_DATA = kpdf_shell.rc
kde_module_LTLIBRARIES = libkpdfpart.la
# the Part's source, library search path, and link libraries
libkpdfpart_la_SOURCES = pageview.cpp pageviewutils.cpp thumbnaillist.cpp toc.cpp searchwidget.cpp document.cpp page.cpp link.cpp properties.ui propertiesdialog.cpp QOutputDev.cpp generator_pdf.cpp kpdf_dcop.skel kpdf_error.cpp kpdf_part.cpp
libkpdfpart_la_SOURCES = pageview.cpp pageviewutils.cpp thumbnaillist.cpp toc.cpp searchwidget.cpp document.cpp page.cpp link.cpp properties.ui propertiesdialog.cpp presentationwidget.cpp QOutputDev.cpp generator_pdf.cpp kpdf_dcop.skel kpdf_error.cpp kpdf_part.cpp
libkpdfpart_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
libkpdfpart_la_LIBADD = ../xpdf/libxpdf.la conf/libconf.la $(LIB_KPARTS) $(LIB_KFILE) $(LIB_KDEPRINT) $(LIB_KUTILS) -lm
......
......@@ -126,7 +126,18 @@ void KPDFDocument::closeDocument()
void KPDFDocument::addObserver( KPDFDocumentObserver * pObserver )
{
// keep the pointer to the observer in a map
d->observers[ pObserver->observerId() ] = pObserver;
// if the observer is added while a document is already opened, tell it
if ( !pages_vector.isEmpty() )
pObserver->pageSetup( pages_vector, true );
}
void KPDFDocument::removeObserver( KPDFDocumentObserver * pObserver )
{
// remove observer from the map. it won't receive notifications anymore
d->observers.remove( pObserver->observerId() );
}
void KPDFDocument::reparseConfig()
......@@ -393,7 +404,7 @@ void KPDFDocument::processLink( const KPDFLink * link )
case KPDFLink::Browse: {
const KPDFLinkBrowse * browse = static_cast< const KPDFLinkBrowse * >( link );
// get service for web browsing
// get service for web browsing TODO: check for "mailto:" links
KService::Ptr ptr = KServiceTypeProfile::preferredService("text/html", "Application");
KURL::List lst;
// append 'url' parameter to the service and run it
......
......@@ -43,10 +43,11 @@ class KPDFDocumentObserver
virtual void pageSetCurrent( int /*pageNumber*/, const QRect & /*viewport*/ = QRect() ) {};
};
#define PART_ID 1
#define PAGEVIEW_ID 2
#define THUMBNAILS_ID 3
#define TOC_ID 4
#define PRESENTATION_ID 1
#define PART_ID 2
#define PAGEVIEW_ID 3
#define THUMBNAILS_ID 4
#define TOC_ID 5
/**
* @short The Document. Heart of everything. Actions take place here.
......@@ -77,6 +78,7 @@ class KPDFDocument
// misc methods
void addObserver( KPDFDocumentObserver * pObserver );
void removeObserver( KPDFDocumentObserver * pObserver );
void reparseConfig();
// query methods (const ones)
......
......@@ -59,6 +59,7 @@
#include "toc.h"
#include "preferencesdialog.h"
#include "propertiesdialog.h"
#include "presentationwidget.h"
#include "settings.h"
typedef KParts::GenericFactory<KPDF::Part> KPDFPartFactory;
......@@ -177,6 +178,9 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
m_showProperties = new KAction(i18n("Properties"), "info", 0, this, SLOT(slotShowProperties()), ac, "properties");
m_showProperties->setEnabled( false );
m_showPresentation = new KAction( i18n("Presentation"), "kpresenter_kpr", 0, this, SLOT(slotShowPresentation()), ac, "presentation");
m_showPresentation->setEnabled( false );
// attach the actions of the 2 children widgets too
m_pageView->setupActions( ac );
......@@ -253,6 +257,7 @@ bool Part::openFile()
if ( ok && !m_watcher->contains(m_file)) m_watcher->addFile(m_file);
m_find->setEnabled( ok );
m_showProperties->setEnabled( ok );
m_showPresentation->setEnabled( ok );
return ok;
}
......@@ -600,6 +605,11 @@ void Part::slotShowProperties()
delete d;
}
void Part::slotShowPresentation()
{
new PresentationWidget( m_document );
}
void Part::slotPrint()
{
if (m_document->pages() == 0) return;
......
......@@ -94,6 +94,7 @@ protected slots:
void slotPrintPreview();
void slotShowMenu(const KPDFPage *page, const QPoint &point);
void slotShowProperties();
void slotShowPresentation();
// can be connected to widget elements
void updateActions();
void enableTOC(bool enable);
......@@ -135,6 +136,7 @@ private:
KAction *m_find;
KAction *m_findNext;
KAction *m_showProperties;
KAction *m_showPresentation;
KToggleAction* m_watchFile;
KToggleAction* m_showMenuBarAction;
KToggleAction* m_showFullScreenAction;
......
......@@ -12,6 +12,7 @@
<Action name="find_next"/>
</Menu>
<Menu name="view"><text>&amp;View</text>
<Action name="presentation"/>
<Separator/>
<Action name="zoom_out"/>
<Action name="zoom_in"/>
......
This diff is collapsed.
/***************************************************************************
* Copyright (C) 2004 by Enrico Ros <eros.kde@email.it> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef _KPDF_PRESENTATIONWIDGET_H_
#define _KPDF_PRESENTATIONWIDGET_H_
#include <qwidget.h>
#include <qpixmap.h>
#include <qstringlist.h>
#include <qvaluevector.h>
#include "document.h"
class PresentationFrame;
class KToolBar;
class QTimer;
/**
* @short A widget that shows pages as fullscreen slides (with transitions fx).
*
* This is a fullscreen widget that displays
*/
class PresentationWidget : public QWidget, public KPDFDocumentObserver
{
Q_OBJECT
public:
PresentationWidget( KPDFDocument * doc );
~PresentationWidget();
// define type of transitions used by presentation frames
enum TransitionType { NoTrans, BoxIn, BoxOut, Glitter, GlitterDir,
FuseDir, SplitDir, WipeDir };
enum TransitionDirection { Left, Top, Right, Bottom };
// inherited from KPDFDocumentObserver
uint observerId() const { return PRESENTATION_ID; }
void pageSetup( const QValueVector<KPDFPage*> & pages, bool documentChanged );
void notifyPixmapChanged( int pageNumber );
protected:
// widget events
void keyPressEvent( QKeyEvent * e );
void wheelEvent( QWheelEvent * e );
void mousePressEvent( QMouseEvent * e );
void mouseMoveEvent( QMouseEvent * e );
void paintEvent( QPaintEvent * e );
private:
void generatePage();
void generateIntroPage( QPainter & p );
void generateContentsPage( int page, QPainter & p );
void generateOverlay();
void initTransition( TransitionType type );
// cache stuff
int m_width;
int m_height;
QPixmap m_lastRenderedPixmap;
QPixmap m_lastRenderedOverlay;
QRect m_overlayGeometry;
// transition related
QTimer * m_transitionTimer;
QTimer * m_overlayHideTimer;
int m_transitionDelay;
int m_transitionMul;
QValueList< QRect > m_transitionRects;
// misc stuff
KPDFDocument * m_document;
QValueVector< PresentationFrame * > m_frames;
int m_frameIndex;
QStringList m_metaStrings;
KToolBar * m_topBar;
private slots:
void slotNextPage();
void slotPrevPage();
void slotHideOverlay();
void slotTransitionStep();
};
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment