2004-08-26 21:17:24 +00:00
/***************************************************************************
* Copyright ( C ) 2002 by Wilco Greven < greven @ kde . org > *
* Copyright ( C ) 2002 by Chris Cheney < ccheney @ cheney . cx > *
* Copyright ( C ) 2002 by Malcolm Hunter < malcolm . hunter @ gmx . co . uk > *
* Copyright ( C ) 2003 - 2004 by Christophe Devriese *
* < Christophe . Devriese @ student . kuleuven . ac . be > *
* Copyright ( C ) 2003 by Daniel Molkentin < molkentin @ kde . org > *
* Copyright ( C ) 2003 by Andy Goossens < andygoossens @ telenet . be > *
* Copyright ( C ) 2003 by Dirk Mueller < mueller @ kde . org > *
* Copyright ( C ) 2003 by Laurent Montel < montel @ kde . org > *
* Copyright ( C ) 2004 by Dominique Devriese < devriese @ kde . org > *
* Copyright ( C ) 2004 by Christoph Cullmann < crossfire @ babylon2k . de > *
* Copyright ( C ) 2004 by Henrique Pinto < stampede @ coltec . ufmg . br > *
* Copyright ( C ) 2004 by Waldo Bastian < bastian @ kde . org > *
* Copyright ( C ) 2004 by Albert Astals Cid < tsdgeos @ terra . es > *
2004-09-02 18:11:19 +00:00
* Copyright ( C ) 2004 by Antti Markus < antti . markus @ starman . ee > *
2004-08-26 21:17:24 +00:00
* *
* 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 . *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-01-02 14:55:14 +00:00
// qt/kde includes
2004-09-09 13:25:40 +00:00
# include <qsplitter.h>
2004-09-04 22:28:14 +00:00
# include <qpainter.h>
2004-09-09 13:25:40 +00:00
# include <qlayout.h>
# include <qlabel.h>
2004-09-16 21:27:34 +00:00
# include <qvbox.h>
2004-09-23 17:16:04 +00:00
# include <qtoolbox.h>
2004-09-17 17:58:42 +00:00
# include <qpushbutton.h>
2004-10-12 11:08:09 +00:00
# include <dcopobject.h>
2005-01-29 12:32:59 +00:00
# include <dcopclient.h>
# include <kapplication.h>
2005-03-24 19:50:28 +00:00
# include <klistviewsearchline.h>
2002-08-30 09:14:01 +00:00
# include <kaction.h>
2004-12-01 22:18:27 +00:00
# include <kdirwatch.h>
2002-08-30 09:14:01 +00:00
# include <kinstance.h>
2002-08-30 12:10:02 +00:00
# include <kprinter.h>
2002-08-30 09:14:01 +00:00
# include <kstdaction.h>
2004-10-10 13:33:01 +00:00
# include <kdeversion.h>
2002-08-30 09:14:01 +00:00
# include <kparts/genericfactory.h>
2003-09-15 14:26:37 +00:00
# include <kurldrag.h>
2004-08-28 17:59:17 +00:00
# include <kfiledialog.h>
2004-08-28 14:18:45 +00:00
# include <kmessagebox.h>
2004-09-09 13:25:40 +00:00
# include <kfinddialog.h>
# include <knuminput.h>
2004-09-17 17:58:42 +00:00
# include <kiconloader.h>
2004-09-16 21:27:34 +00:00
# include <kio/netaccess.h>
2004-12-04 23:23:18 +00:00
# include <kpopupmenu.h>
# include <kxmlguiclient.h>
# include <kxmlguifactory.h>
2005-03-05 15:59:15 +00:00
# include <ktrader.h>
2005-07-15 18:20:57 +00:00
# include <kprocess.h>
# include <kstandarddirs.h>
# include <ktempfile.h>
2002-08-30 09:14:01 +00:00
2005-01-02 14:55:14 +00:00
// local includes
2005-01-02 14:29:37 +00:00
# include "part.h"
# include "ui/pageview.h"
# include "ui/toc.h"
2005-03-24 19:50:28 +00:00
# include "ui/searchwidget.h"
# include "ui/thumbnaillist.h"
# include "ui/side_reviews.h"
2005-01-26 10:42:07 +00:00
# include "ui/minibar.h"
2005-04-16 00:25:26 +00:00
# include "ui/newstuff.h"
2005-01-02 14:29:37 +00:00
# include "ui/propertiesdialog.h"
# include "ui/presentationwidget.h"
# include "conf/preferencesdialog.h"
# include "conf/settings.h"
# include "core/document.h"
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
# include "core/generator.h"
2005-01-02 14:29:37 +00:00
# include "core/page.h"
2003-06-28 01:59:03 +00:00
2005-02-02 18:18:26 +00:00
// definition of searchID for this class
# define PART_SEARCH_ID 1
2002-08-30 09:14:01 +00:00
typedef KParts : : GenericFactory < KPDF : : Part > KPDFPartFactory ;
2003-09-12 12:36:20 +00:00
K_EXPORT_COMPONENT_FACTORY ( libkpdfpart , KPDFPartFactory )
2002-08-30 09:14:01 +00:00
using namespace KPDF ;
Part : : Part ( QWidget * parentWidget , const char * widgetName ,
QObject * parent , const char * name ,
const QStringList & /*args*/ )
2005-07-15 18:20:57 +00:00
: DCOPObject ( " kpdf " ) , KParts : : ReadOnlyPart ( parent , name ) , m_viewportDirty ( 0 ) ,
2005-06-24 16:42:44 +00:00
m_showMenuBarAction ( 0 ) , m_showFullScreenAction ( 0 ) , m_actionsSearched ( false ) ,
2005-07-15 18:20:57 +00:00
m_searchStarted ( false )
2002-08-30 09:14:01 +00:00
{
2005-01-23 12:00:16 +00:00
// load catalog for translation
KGlobal : : locale ( ) - > insertCatalogue ( " kpdf " ) ;
2004-09-08 12:41:14 +00:00
// create browser extension (for printing when embedded into browser)
2005-06-24 16:42:44 +00:00
m_bExtension = new BrowserExtension ( this ) ;
2002-09-02 21:56:00 +00:00
2004-09-08 12:41:14 +00:00
// we need an instance
setInstance ( KPDFPartFactory : : instance ( ) ) ;
2002-08-30 09:14:01 +00:00
2004-09-09 13:25:40 +00:00
// build the document
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
m_document = new KPDFDocument ( & m_loadedGenerators ) ;
2005-01-01 21:50:34 +00:00
connect ( m_document , SIGNAL ( linkFind ( ) ) , this , SLOT ( slotFind ( ) ) ) ;
connect ( m_document , SIGNAL ( linkGoToPage ( ) ) , this , SLOT ( slotGoToPage ( ) ) ) ;
2005-04-07 09:53:15 +00:00
connect ( m_document , SIGNAL ( linkPresentation ( ) ) , this , SLOT ( slotShowPresentation ( ) ) ) ;
connect ( m_document , SIGNAL ( linkEndPresentation ( ) ) , this , SLOT ( slotHidePresentation ( ) ) ) ;
2005-07-15 18:20:57 +00:00
connect ( m_document , SIGNAL ( openURL ( const KURL & ) ) , this , SLOT ( openURL ( const KURL & ) ) ) ;
// widgets: ^searchbar (toolbar containing label and SearchWidget)
// m_searchToolBar = new KToolBar( parentWidget, "searchBar" );
// m_searchToolBar->boxLayout()->setSpacing( KDialog::spacingHint() );
// QLabel * sLabel = new QLabel( i18n( "&Search:" ), m_searchToolBar, "kde toolbar widget" );
// m_searchWidget = new SearchWidget( m_searchToolBar, m_document );
// sLabel->setBuddy( m_searchWidget );
// m_searchToolBar->setStretchableWidget( m_searchWidget );
2004-09-09 13:25:40 +00:00
2004-09-23 17:16:04 +00:00
// widgets: [] splitter []
2004-09-11 15:59:32 +00:00
m_splitter = new QSplitter ( parentWidget , widgetName ) ;
m_splitter - > setOpaqueResize ( true ) ;
2005-04-07 12:47:24 +00:00
m_splitter - > setChildrenCollapsible ( false ) ;
2004-09-11 15:59:32 +00:00
setWidget ( m_splitter ) ;
2004-09-02 18:11:19 +00:00
2005-01-26 10:42:07 +00:00
// widgets: [left panel] | []
2005-02-12 14:34:12 +00:00
m_leftPanel = new QWidget ( m_splitter ) ;
m_leftPanel - > setMinimumWidth ( 90 ) ;
m_leftPanel - > setMaximumWidth ( 300 ) ;
QVBoxLayout * leftPanelLayout = new QVBoxLayout ( m_leftPanel ) ;
2005-01-26 10:42:07 +00:00
// widgets: [left toolbox/..] | []
2005-02-12 14:34:12 +00:00
m_toolBox = new QToolBox ( m_leftPanel ) ;
2005-01-26 10:42:07 +00:00
leftPanelLayout - > addWidget ( m_toolBox ) ;
2004-09-17 17:58:42 +00:00
2005-06-13 17:30:58 +00:00
int tbIndex ;
2005-01-03 15:51:05 +00:00
// [left toolbox: Table of Contents] | []
2005-03-24 19:50:28 +00:00
//QFrame * tocFrame = new QFrame( m_toolBox );
//QVBoxLayout * tocFrameLayout = new QVBoxLayout( tocFrame );
TOC * toc = new TOC ( m_toolBox /*tocFrame*/ , m_document ) ;
connect ( toc , SIGNAL ( hasTOC ( bool ) ) , this , SLOT ( enableTOC ( bool ) ) ) ;
//KListViewSearchLine * tocSearchLine = new KListViewSearchLine( tocFrame, toc );
//tocFrameLayout->addWidget( tocSearchLine );
//tocFrameLayout->addWidget( toc );
2005-06-13 17:30:58 +00:00
tbIndex = m_toolBox - > addItem ( toc /*tocFrame*/ , QIconSet ( SmallIcon ( " text_left " ) ) , i18n ( " Contents " ) ) ;
m_toolBox - > setItemToolTip ( tbIndex , i18n ( " Contents " ) ) ;
2004-09-28 13:53:47 +00:00
enableTOC ( false ) ;
2003-09-15 21:57:19 +00:00
2005-01-03 15:51:05 +00:00
// [left toolbox: Thumbnails and Bookmarks] | []
2004-09-23 21:49:00 +00:00
QVBox * thumbsBox = new ThumbnailsBox ( m_toolBox ) ;
2005-03-24 19:50:28 +00:00
thumbsBox - > setSpacing ( 4 ) ;
2005-01-03 15:51:05 +00:00
m_searchWidget = new SearchWidget ( thumbsBox , m_document ) ;
m_thumbnailList = new ThumbnailList ( thumbsBox , m_document ) ;
// ThumbnailController * m_tc = new ThumbnailController( thumbsBox, m_thumbnailList );
connect ( m_thumbnailList , SIGNAL ( urlDropped ( const KURL & ) ) , SLOT ( openURL ( const KURL & ) ) ) ;
2005-01-26 10:42:07 +00:00
connect ( m_thumbnailList , SIGNAL ( rightClick ( const KPDFPage * , const QPoint & ) ) , this , SLOT ( slotShowMenu ( const KPDFPage * , const QPoint & ) ) ) ;
2005-01-27 17:31:07 +00:00
// shrink the bottom controller toolbar (too hackish..)
2005-01-03 15:51:05 +00:00
thumbsBox - > setStretchFactor ( m_searchWidget , 100 ) ;
thumbsBox - > setStretchFactor ( m_thumbnailList , 100 ) ;
// thumbsBox->setStretchFactor( m_tc, 1 );
2005-06-13 17:30:58 +00:00
tbIndex = m_toolBox - > addItem ( thumbsBox , QIconSet ( SmallIcon ( " thumbnail " ) ) , i18n ( " Thumbnails " ) ) ;
m_toolBox - > setItemToolTip ( tbIndex , i18n ( " Thumbnails " ) ) ;
2004-09-23 21:49:00 +00:00
m_toolBox - > setCurrentItem ( thumbsBox ) ;
2004-09-16 21:27:34 +00:00
2005-03-24 19:50:28 +00:00
// [left toolbox: Reviews] | []
Reviews * reviewsWidget = new Reviews ( m_toolBox , m_document ) ;
m_toolBox - > addItem ( reviewsWidget , QIconSet ( SmallIcon ( " pencil " ) ) , i18n ( " Reviews " ) ) ;
2004-09-23 17:16:04 +00:00
2005-01-26 10:42:07 +00:00
// widgets: [../miniBarContainer] | []
2005-02-12 14:34:12 +00:00
QWidget * miniBarContainer = new QWidget ( m_leftPanel ) ;
2005-01-26 10:42:07 +00:00
leftPanelLayout - > addWidget ( miniBarContainer ) ;
QVBoxLayout * miniBarLayout = new QVBoxLayout ( miniBarContainer ) ;
// widgets: [../[spacer/..]] | []
QWidget * miniSpacer = new QWidget ( miniBarContainer ) ;
miniSpacer - > setFixedHeight ( 6 ) ;
miniBarLayout - > addWidget ( miniSpacer ) ;
// widgets: [../[../MiniBar]] | []
MiniBar * miniBar = new MiniBar ( miniBarContainer , m_document ) ;
miniBarLayout - > addWidget ( miniBar ) ;
2004-09-23 17:16:04 +00:00
// widgets: [] | [right 'pageView']
2005-03-24 19:50:28 +00:00
// QWidget * rightContainer = new QWidget( m_splitter );
// QVBoxLayout * rightLayout = new QVBoxLayout( rightContainer );
// KToolBar * rtb = new KToolBar( rightContainer, "mainToolBarSS" );
// rightLayout->addWidget( rtb );
2004-11-09 17:20:19 +00:00
m_pageView = new PageView ( m_splitter , m_document ) ;
2005-01-03 15:51:05 +00:00
m_pageView - > setFocus ( ) ; //usability setting
2004-09-23 17:16:04 +00:00
connect ( m_pageView , SIGNAL ( urlDropped ( const KURL & ) ) , SLOT ( openURL ( const KURL & ) ) ) ;
2005-01-03 15:51:05 +00:00
connect ( m_pageView , SIGNAL ( rightClick ( const KPDFPage * , const QPoint & ) ) , this , SLOT ( slotShowMenu ( const KPDFPage * , const QPoint & ) ) ) ;
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
connect ( m_document , SIGNAL ( error ( QString & , int ) ) , m_pageView , SLOT ( errorMessage ( QString & , int ) ) ) ;
connect ( m_document , SIGNAL ( warning ( QString & , int ) ) , m_pageView , SLOT ( warningMessage ( QString & , int ) ) ) ;
connect ( m_document , SIGNAL ( notice ( QString & , int ) ) , m_pageView , SLOT ( noticeMessage ( QString & , int ) ) ) ;
2005-03-24 19:50:28 +00:00
// rightLayout->addWidget( m_pageView );
2004-09-23 17:16:04 +00:00
// add document observers
2004-12-26 22:34:50 +00:00
m_document - > addObserver ( this ) ;
2004-11-09 17:20:19 +00:00
m_document - > addObserver ( m_thumbnailList ) ;
m_document - > addObserver ( m_pageView ) ;
2005-03-24 19:50:28 +00:00
m_document - > addObserver ( toc ) ;
2005-01-26 10:42:07 +00:00
m_document - > addObserver ( miniBar ) ;
2005-03-24 19:50:28 +00:00
m_document - > addObserver ( reviewsWidget ) ;
2004-09-08 12:41:14 +00:00
// ACTIONS
KActionCollection * ac = actionCollection ( ) ;
// Page Traversal actions
2004-09-13 17:30:00 +00:00
m_gotoPage = KStdAction : : gotoPage ( this , SLOT ( slotGoToPage ( ) ) , ac , " goto_page " ) ;
2004-09-16 21:04:49 +00:00
m_gotoPage - > setShortcut ( " CTRL+G " ) ;
2005-01-26 10:42:07 +00:00
// dirty way to activate gotopage when pressing miniBar's button
connect ( miniBar , SIGNAL ( gotoPage ( ) ) , m_gotoPage , SLOT ( activate ( ) ) ) ;
2004-09-08 12:41:14 +00:00
m_prevPage = KStdAction : : prior ( this , SLOT ( slotPreviousPage ( ) ) , ac , " previous_page " ) ;
m_prevPage - > setWhatsThis ( i18n ( " Moves to the previous page of the document " ) ) ;
2004-09-27 21:36:25 +00:00
m_prevPage - > setShortcut ( " Backspace " ) ;
2005-01-26 10:42:07 +00:00
// dirty way to activate prev page when pressing miniBar's button
connect ( miniBar , SIGNAL ( prevPage ( ) ) , m_prevPage , SLOT ( activate ( ) ) ) ;
2004-09-08 12:41:14 +00:00
m_nextPage = KStdAction : : next ( this , SLOT ( slotNextPage ( ) ) , ac , " next_page " ) ;
m_nextPage - > setWhatsThis ( i18n ( " Moves to the next page of the document " ) ) ;
2004-09-27 21:36:25 +00:00
m_nextPage - > setShortcut ( " Space " ) ;
2005-01-26 10:42:07 +00:00
// dirty way to activate next page when pressing miniBar's button
connect ( miniBar , SIGNAL ( nextPage ( ) ) , m_nextPage , SLOT ( activate ( ) ) ) ;
2004-09-08 12:41:14 +00:00
2004-09-13 17:30:00 +00:00
m_firstPage = KStdAction : : firstPage ( this , SLOT ( slotGotoFirst ( ) ) , ac , " first_page " ) ;
2004-09-08 12:41:14 +00:00
m_firstPage - > setWhatsThis ( i18n ( " Moves to the first page of the document " ) ) ;
2004-09-27 21:36:25 +00:00
m_lastPage = KStdAction : : lastPage ( this , SLOT ( slotGotoLast ( ) ) , ac , " last_page " ) ;
2004-09-08 12:41:14 +00:00
m_lastPage - > setWhatsThis ( i18n ( " Moves to the last page of the document " ) ) ;
2005-01-27 17:31:07 +00:00
m_historyBack = KStdAction : : back ( this , SLOT ( slotHistoryBack ( ) ) , ac , " history_back " ) ;
m_historyBack - > setWhatsThis ( i18n ( " Go to the place you were before " ) ) ;
m_historyNext = KStdAction : : forward ( this , SLOT ( slotHistoryNext ( ) ) , ac , " history_forward " ) ;
m_historyNext - > setWhatsThis ( i18n ( " Go to the place you were after " ) ) ;
2004-09-11 15:59:32 +00:00
// Find and other actions
m_find = KStdAction : : find ( this , SLOT ( slotFind ( ) ) , ac , " find " ) ;
2005-01-27 17:31:07 +00:00
m_find - > setEnabled ( false ) ;
2004-09-08 12:41:14 +00:00
2004-09-11 15:59:32 +00:00
m_findNext = KStdAction : : findNext ( this , SLOT ( slotFindNext ( ) ) , ac , " find_next " ) ;
2005-01-27 17:31:07 +00:00
m_findNext - > setEnabled ( false ) ;
2004-09-08 12:41:14 +00:00
2005-01-27 17:31:07 +00:00
m_saveAs = KStdAction : : saveAs ( this , SLOT ( slotSaveFileAs ( ) ) , ac , " save " ) ;
m_saveAs - > setEnabled ( false ) ;
2005-02-01 18:23:55 +00:00
KAction * prefs = KStdAction : : preferences ( this , SLOT ( slotPreferences ( ) ) , ac , " preferences " ) ;
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
prefs - > setText ( i18n ( " Configure oKular... " ) ) ; // TODO: use "Configure PDF Viewer..." when used as part (like in konq
QString constraint ( " ([X-KDE-Priority] > 0) and ( exist Library ) and ( [ X - KDE - oKularHasInternalSettings ] ) " ) ;
KTrader : : OfferList gens = KTrader : : self ( ) - > query ( " oKular/Generator " , constraint ) ;
if ( gens . count ( ) > 0 )
{
KAction * genPrefs = KStdAction : : preferences ( this , SLOT ( slotGeneratorPreferences ( ) ) , ac , " generator_prefs " ) ;
genPrefs - > setText ( i18n ( " Configure backends... " ) ) ;
}
2005-01-27 17:31:07 +00:00
m_printPreview = KStdAction : : printPreview ( this , SLOT ( slotPrintPreview ( ) ) , ac ) ;
m_printPreview - > setEnabled ( false ) ;
2004-12-10 16:04:45 +00:00
2005-06-13 17:54:20 +00:00
m_showLeftPanel = new KToggleAction ( i18n ( " Show &Navigation panel " ) , " show_side_panel " , 0 , this , SLOT ( slotShowLeftPanel ( ) ) , ac , " show_leftpanel " ) ;
2005-03-13 13:14:44 +00:00
m_showLeftPanel - > setShortcut ( " CTRL+L " ) ;
2005-06-13 17:54:20 +00:00
m_showLeftPanel - > setCheckedState ( i18n ( " Hide &Navigation Panel " ) ) ;
2005-03-13 13:14:44 +00:00
m_showLeftPanel - > setChecked ( Settings : : showLeftPanel ( ) ) ;
slotShowLeftPanel ( ) ;
2005-07-15 18:20:57 +00:00
QString app = KStandardDirs : : findExe ( " ps2pdf " ) ;
if ( ! app . isNull ( ) )
KAction * importPS = new KAction ( i18n ( " &Import Postscript as PDF... " ) , " psimport " , 0 , this , SLOT ( slotImportPSFile ( ) ) , ac , " import_ps " ) ;
2005-06-19 22:18:41 +00:00
KAction * ghns = new KAction ( i18n ( " &Get Books From Internet... " ) , " knewstuff " , 0 , this , SLOT ( slotGetNewStuff ( ) ) , ac , " get_new_stuff " ) ;
2005-04-16 00:25:26 +00:00
ghns - > setShortcut ( " G " ) ; // TEMP, REMOVE ME!
2005-01-11 17:35:07 +00:00
m_showProperties = new KAction ( i18n ( " &Properties " ) , " info " , 0 , this , SLOT ( slotShowProperties ( ) ) , ac , " properties " ) ;
2004-12-05 22:47:32 +00:00
m_showProperties - > setEnabled ( false ) ;
2004-09-08 12:41:14 +00:00
2005-01-21 23:09:00 +00:00
m_showPresentation = new KAction ( i18n ( " P&resentation " ) , " kpresenter_kpr " , " Ctrl+Shift+P " , this , SLOT ( slotShowPresentation ( ) ) , ac , " presentation " ) ;
2005-01-03 15:51:05 +00:00
m_showPresentation - > setEnabled ( false ) ;
2004-12-17 17:14:46 +00:00
2005-01-27 17:31:07 +00:00
// attach the actions of the children widgets too
m_pageView - > setupActions ( ac ) ;
2004-12-13 18:21:37 +00:00
2005-01-27 17:31:07 +00:00
// apply configuration (both internal settings and GUI configured items)
QValueList < int > splitterSizes = Settings : : splitterSizes ( ) ;
if ( ! splitterSizes . count ( ) )
{
// the first time use 1/10 for the panel and 9/10 for the pageView
splitterSizes . push_back ( 50 ) ;
splitterSizes . push_back ( 500 ) ;
}
m_splitter - > setSizes ( splitterSizes ) ;
2005-04-07 12:47:24 +00:00
// get notified about splitter size changes (HACK that will be removed
// by connecting to Qt4::QSplitter's sliderMoved())
m_pageView - > installEventFilter ( this ) ;
2005-06-24 16:39:57 +00:00
// document watcher and reloader
2004-12-01 22:18:27 +00:00
m_watcher = new KDirWatch ( this ) ;
connect ( m_watcher , SIGNAL ( dirty ( const QString & ) ) , this , SLOT ( slotFileDirty ( const QString & ) ) ) ;
m_dirtyHandler = new QTimer ( this ) ;
connect ( m_dirtyHandler , SIGNAL ( timeout ( ) ) , this , SLOT ( slotDoFileDirty ( ) ) ) ;
2005-03-12 15:39:04 +00:00
slotNewConfig ( ) ;
2005-01-29 12:32:59 +00:00
// [SPEECH] check for KTTSD presence and usability
2005-03-05 15:59:15 +00:00
KTrader : : OfferList offers = KTrader : : self ( ) - > query ( " DCOP/Text-to-Speech " , " Name == 'KTTSD' " ) ;
Settings : : setUseKTTSD ( ( offers . count ( ) > 0 ) ) ;
2005-01-29 12:32:59 +00:00
2004-09-08 12:41:14 +00:00
// set our XML-UI resource file
2005-01-02 14:29:37 +00:00
setXMLFile ( " part.rc " ) ;
2005-07-20 22:28:23 +00:00
//
2005-02-02 18:18:26 +00:00
updateViewActions ( ) ;
2003-09-15 21:57:19 +00:00
}
2004-09-08 12:41:14 +00:00
Part : : ~ Part ( )
2003-09-15 21:09:49 +00:00
{
2005-07-15 18:20:57 +00:00
// save internal settings
Settings : : setSplitterSizes ( m_splitter - > sizes ( ) ) ;
// write to disk config file
Settings : : writeConfig ( ) ;
2004-11-09 17:20:19 +00:00
delete m_document ;
2003-09-15 21:09:49 +00:00
}
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
void Part : : fillGenerators ( )
{
QString constraint ( " ([X-KDE-Priority] > 0) and ( exist Library ) and ( [ X - KDE - oKularHasInternalSettings ] ) " ) ;
KTrader : : OfferList offers = KTrader : : self ( ) - > query ( " oKular/Generator " , constraint ) ;
QString propName ;
int count = offers . count ( ) ;
if ( count > 0 )
{
for ( int i = 0 ; i < count ; i + + )
{
propName = offers [ i ] - > property ( " Name " ) . toString ( ) ;
// dont load already loaded generators
if ( ! m_loadedGenerators . take ( propName ) )
{
KLibLoader * loader = KLibLoader : : self ( ) ;
if ( ! loader )
{
kdWarning ( ) < < " Could not start library loader: ' " < < loader - > lastErrorMessage ( ) < < " '. " < < endl ;
return ;
}
KLibrary * lib = loader - > globalLibrary ( QFile : : encodeName ( offers [ i ] - > library ( ) ) ) ;
if ( ! lib )
{
kdWarning ( ) < < " Could not load ' " < < lib - > fileName ( ) < < " ' library. " < < endl ;
}
Generator * ( * create_plugin ) ( KPDFDocument * doc ) = ( Generator * ( * ) ( KPDFDocument * doc ) ) lib - > symbol ( " create_plugin " ) ;
// the generator should do anything with the document if we are only configuring
m_loadedGenerators . insert ( propName , create_plugin ( m_document ) ) ;
m_generatorsWithSettings < < propName ;
}
}
m_loadedGenerators . setAutoDelete ( true ) ;
}
}
void Part : : slotGeneratorPreferences ( )
{
fillGenerators ( ) ;
//Generator* gen= m_loadedGenerators[m_generatorsWithSettings[number]];
// an instance the dialog could be already created and could be cached,
// in which case you want to display the cached dialog
if ( KConfigDialog : : showDialog ( " generator_prefs " ) )
return ;
// we didn't find an instance of this dialog, so lets create it
KConfigDialog * dialog = new KConfigDialog ( m_pageView , " generator_prefs " , Settings : : self ( ) ) ;
QDictIterator < Generator > it ( m_loadedGenerators ) ;
for ( ; it . current ( ) ; + + it )
{
it . current ( ) - > addPages ( dialog ) ;
}
// (for now dont FIXME) keep us informed when the user changes settings
// connect( dialog, SIGNAL( settingsChanged() ), this, SLOT( slotNewConfig() ) );
dialog - > show ( ) ;
}
2005-02-01 18:23:55 +00:00
void Part : : notifyViewportChanged ( bool /*smoothMove*/ )
2004-11-09 17:20:19 +00:00
{
2005-01-09 23:37:07 +00:00
// update actions if the page is changed
static int lastPage = - 1 ;
int viewportPage = m_document - > viewport ( ) . pageNumber ;
if ( viewportPage ! = lastPage )
{
2005-02-02 18:18:26 +00:00
updateViewActions ( ) ;
2005-01-09 23:37:07 +00:00
lastPage = viewportPage ;
}
2004-11-09 17:20:19 +00:00
}
2004-10-12 11:08:09 +00:00
void Part : : goToPage ( uint i )
{
2004-11-09 17:20:19 +00:00
if ( i < = m_document - > pages ( ) )
2005-01-09 23:37:07 +00:00
m_document - > setViewportPage ( i - 1 ) ;
2004-10-12 11:08:09 +00:00
}
void Part : : openDocument ( KURL doc )
{
2005-06-13 17:39:58 +00:00
openURL ( doc ) ;
2004-10-12 11:08:09 +00:00
}
uint Part : : pages ( )
{
2005-06-13 17:39:58 +00:00
return m_document - > pages ( ) ;
}
uint Part : : currentPage ( )
{
return m_document - > pages ( ) ? m_document - > currentPage ( ) + 1 : 0 ;
}
KURL Part : : currentDocument ( )
{
return m_document - > currentDocument ( ) ;
2004-10-12 11:08:09 +00:00
}
2004-09-26 23:39:39 +00:00
//this don't go anywhere but is required by genericfactory.h
2004-09-09 13:25:40 +00:00
KAboutData * Part : : createAboutData ( )
2003-09-15 14:26:37 +00:00
{
2004-09-09 13:25:40 +00:00
// the non-i18n name here must be the same as the directory in
// which the part's rc file is installed ('partrcdir' in the
// Makefile)
KAboutData * aboutData = new KAboutData ( " kpdfpart " , I18N_NOOP ( " KPDF::Part " ) , " 0.1 " ) ;
aboutData - > addAuthor ( " Wilco Greven " , 0 , " greven@kde.org " ) ;
return aboutData ;
2003-09-15 14:26:37 +00:00
}
2005-07-15 18:20:57 +00:00
bool Part : : slotImportPSFile ( )
{
KURL url = KFileDialog : : getOpenURL ( QString : : null , " application/postscript " ) ;
KTempFile tf ( QString : : null , " .pdf " ) ;
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
2005-07-15 18:20:57 +00:00
if ( tf . status ( ) = = 0 & & url . isLocalFile ( ) )
{
tf . close ( ) ;
m_file = url . path ( ) ;
m_temporaryLocalFile = tf . name ( ) ;
QString app = KStandardDirs : : findExe ( " ps2pdf " ) ;
KProcess * p = new KProcess ;
* p < < app ;
* p < < m_file < < m_temporaryLocalFile ;
m_pageView - > displayMessage ( i18n ( " Importing PS file as PDF (this may take a while)... " ) ) ;
connect ( p , SIGNAL ( processExited ( KProcess * ) ) , this , SLOT ( psTransformEnded ( ) ) ) ;
connect ( p , SIGNAL ( processExited ( KProcess * ) ) , this , SLOT ( psTransformEnded ( ) ) ) ;
p - > start ( ) ;
return true ;
}
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
2005-07-15 18:20:57 +00:00
m_temporaryLocalFile = QString : : null ;
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
return false ;
2005-07-15 18:20:57 +00:00
}
2004-09-09 13:25:40 +00:00
bool Part : : openFile ( )
2003-09-15 09:35:55 +00:00
{
2005-02-04 22:35:44 +00:00
bool ok = m_document - > openDocument ( m_file , url ( ) ) ;
2005-06-24 16:45:25 +00:00
bool canSearch = m_document - > supportsSearching ( ) ;
2005-01-27 17:31:07 +00:00
// update one-time actions
2005-06-24 16:45:25 +00:00
m_find - > setEnabled ( ok & & canSearch ) ;
m_findNext - > setEnabled ( ok & & canSearch ) ;
2005-01-27 17:31:07 +00:00
m_saveAs - > setEnabled ( ok ) ;
m_printPreview - > setEnabled ( ok ) ;
2005-02-02 18:18:26 +00:00
m_showProperties - > setEnabled ( ok ) ;
m_showPresentation - > setEnabled ( ok ) ;
2005-01-27 17:31:07 +00:00
// update viewing actions
2005-02-02 18:18:26 +00:00
updateViewActions ( ) ;
2005-01-01 15:44:44 +00:00
2005-01-27 17:31:07 +00:00
if ( ! ok )
{
// if can't open document, update windows so they display blank contents
m_pageView - > updateContents ( ) ;
m_thumbnailList - > updateContents ( ) ;
return false ;
}
// set the file to the fileWatcher
if ( ! m_watcher - > contains ( m_file ) )
m_watcher - > addFile ( m_file ) ;
// if the 'StartFullScreen' flag is set, start presentation
if ( m_document - > getMetaData ( " StartFullScreen " ) = = " yes " )
2005-06-13 16:55:57 +00:00
{
KMessageBox : : information ( m_presentationWidget , i18n ( " The document is going to be launched on presentation mode because the file requested it. " ) , QString : : null , " autoPresentationWarning " ) ;
2005-01-01 15:44:44 +00:00
slotShowPresentation ( ) ;
2005-06-13 16:55:57 +00:00
}
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
/* if (m_document->getXMLFile() != QString::null)
setXMLFile ( m_document - > getXMLFile ( ) , true ) ; */
m_document - > setupGUI ( actionCollection ( ) , m_toolBox ) ;
2005-01-27 17:31:07 +00:00
return true ;
2003-09-15 09:35:55 +00:00
}
2004-09-18 16:41:23 +00:00
bool Part : : openURL ( const KURL & url )
{
2005-02-01 18:23:55 +00:00
// note: this can be the right place to check the file for gz or bz2 extension
// if it matches then: download it (if not local) extract to a temp file using
// KTar and proceed with the URL of the temporary file
2005-06-24 16:39:57 +00:00
// this calls in sequence the 'closeURL' and 'openFile' methods
bool openOk = KParts : : ReadOnlyPart : : openURL ( url ) ;
2005-07-15 18:20:57 +00:00
m_bExtension - > openURLNotify ( ) ;
m_bExtension - > setLocationBarURL ( url . prettyURL ( ) ) ;
2005-06-24 16:39:57 +00:00
if ( openOk )
{
2005-07-15 18:20:57 +00:00
m_viewportDirty = 0 ;
2005-06-24 16:39:57 +00:00
}
else
2005-01-27 17:31:07 +00:00
KMessageBox : : error ( widget ( ) , i18n ( " Could not open %1 " ) . arg ( url . prettyURL ( ) ) ) ;
2005-06-24 16:39:57 +00:00
return openOk ;
2004-09-18 16:41:23 +00:00
}
2005-02-02 18:18:26 +00:00
bool Part : : closeURL ( )
{
2005-07-15 18:20:57 +00:00
if ( ! m_temporaryLocalFile . isNull ( ) )
{
QFile : : remove ( m_temporaryLocalFile ) ;
m_temporaryLocalFile = QString : : null ;
}
2005-02-02 18:18:26 +00:00
m_find - > setEnabled ( false ) ;
m_findNext - > setEnabled ( false ) ;
m_saveAs - > setEnabled ( false ) ;
m_printPreview - > setEnabled ( false ) ;
m_showProperties - > setEnabled ( false ) ;
m_showPresentation - > setEnabled ( false ) ;
updateViewActions ( ) ;
m_searchStarted = false ;
if ( ! m_file . isEmpty ( ) ) m_watcher - > removeFile ( m_file ) ;
m_document - > closeDocument ( ) ;
2005-02-03 17:09:33 +00:00
m_searchWidget - > clearText ( ) ;
2005-02-02 18:18:26 +00:00
return KParts : : ReadOnlyPart : : closeURL ( ) ;
}
2005-04-07 12:47:24 +00:00
bool Part : : eventFilter ( QObject * watched , QEvent * e )
{
// if pageView has been resized, save splitter sizes
if ( watched = = m_pageView & & e - > type ( ) = = QEvent : : Resize )
Settings : : setSplitterSizes ( m_splitter - > sizes ( ) ) ;
// only intercept events, don't block them
return false ;
}
2005-03-12 15:39:04 +00:00
void Part : : slotShowLeftPanel ( )
2004-12-01 22:18:27 +00:00
{
2005-03-12 15:39:04 +00:00
bool showLeft = m_showLeftPanel - > isChecked ( ) ;
2005-03-13 13:14:44 +00:00
Settings : : setShowLeftPanel ( showLeft ) ;
// show/hide left panel
2005-03-12 15:39:04 +00:00
m_leftPanel - > setShown ( showLeft ) ;
// this needs to be hidden explicitly to disable thumbnails gen
m_thumbnailList - > setShown ( showLeft ) ;
2004-12-01 22:18:27 +00:00
}
2005-01-27 17:31:07 +00:00
void Part : : slotFileDirty ( const QString & fileName )
2004-12-01 22:18:27 +00:00
{
// The beauty of this is that each start cancels the previous one.
// This means that timeout() is only fired when there have
// no changes to the file for the last 750 milisecs.
2005-06-24 16:39:57 +00:00
// This ensures that we don't update on every other byte that gets
// written to the file.
2004-12-01 22:18:27 +00:00
if ( fileName = = m_file )
{
m_dirtyHandler - > start ( 750 , true ) ;
}
}
2005-01-27 17:31:07 +00:00
void Part : : slotDoFileDirty ( )
2004-12-01 22:18:27 +00:00
{
2005-06-24 16:39:57 +00:00
// do the following the first time the file is reloaded
2005-07-15 18:20:57 +00:00
if ( m_viewportDirty . pageNumber = = - 1 )
2005-06-24 16:39:57 +00:00
{
// store the current viewport
2005-07-15 18:20:57 +00:00
m_viewportDirty = DocumentViewport ( m_document - > viewport ( ) ) ;
2005-06-24 16:39:57 +00:00
// inform the user about the operation in progress
m_pageView - > displayMessage ( i18n ( " Reloading the document... " ) ) ;
}
// close and (try to) reopen the document
if ( KParts : : ReadOnlyPart : : openURL ( m_file ) )
{
// on successfull opening, restore the previous viewport
2005-07-15 18:20:57 +00:00
if ( m_viewportDirty . pageNumber > = ( int ) m_document - > pages ( ) )
m_viewportDirty . pageNumber = ( int ) m_document - > pages ( ) - 1 ;
m_document - > setViewport ( m_viewportDirty ) ;
m_viewportDirty . pageNumber = - 1 ;
2005-06-24 16:39:57 +00:00
}
else
{
// start watching the file again (since we dropped it on close)
m_watcher - > addFile ( m_file ) ;
m_dirtyHandler - > start ( 750 , true ) ;
}
2004-12-01 22:18:27 +00:00
}
2005-02-02 18:18:26 +00:00
void Part : : updateViewActions ( )
2003-09-14 21:49:26 +00:00
{
2005-02-02 18:18:26 +00:00
bool opened = m_document - > pages ( ) > 0 ;
if ( opened )
2004-11-09 17:20:19 +00:00
{
bool atBegin = m_document - > currentPage ( ) < 1 ;
bool atEnd = m_document - > currentPage ( ) > = ( m_document - > pages ( ) - 1 ) ;
m_gotoPage - > setEnabled ( m_document - > pages ( ) > 1 ) ;
m_firstPage - > setEnabled ( ! atBegin ) ;
m_prevPage - > setEnabled ( ! atBegin ) ;
m_lastPage - > setEnabled ( ! atEnd ) ;
m_nextPage - > setEnabled ( ! atEnd ) ;
2005-01-27 17:31:07 +00:00
m_historyBack - > setEnabled ( ! m_document - > historyAtBegin ( ) ) ;
m_historyNext - > setEnabled ( ! m_document - > historyAtEnd ( ) ) ;
2004-11-09 17:20:19 +00:00
}
else
{
m_gotoPage - > setEnabled ( false ) ;
m_firstPage - > setEnabled ( false ) ;
m_lastPage - > setEnabled ( false ) ;
m_prevPage - > setEnabled ( false ) ;
m_nextPage - > setEnabled ( false ) ;
2005-01-27 17:31:07 +00:00
m_historyBack - > setEnabled ( false ) ;
m_historyNext - > setEnabled ( false ) ;
2004-11-09 17:20:19 +00:00
}
2003-09-14 21:49:26 +00:00
}
2003-09-14 20:46:38 +00:00
2004-09-23 21:49:00 +00:00
void Part : : enableTOC ( bool enable )
{
m_toolBox - > setItemEnabled ( 0 , enable ) ;
}
2004-09-18 16:41:23 +00:00
//BEGIN go to page dialog
2004-09-09 13:25:40 +00:00
class KPDFGotoPageDialog : public KDialogBase
2003-09-14 20:46:38 +00:00
{
2004-09-09 13:25:40 +00:00
public :
KPDFGotoPageDialog ( QWidget * p , int current , int max ) : KDialogBase ( p , 0L , true , i18n ( " Go to Page " ) , Ok | Cancel , Ok ) {
QWidget * w = new QWidget ( this ) ;
setMainWidget ( w ) ;
2004-09-18 16:41:23 +00:00
2004-09-09 13:25:40 +00:00
QVBoxLayout * topLayout = new QVBoxLayout ( w , 0 , spacingHint ( ) ) ;
e1 = new KIntNumInput ( current , w ) ;
e1 - > setRange ( 1 , max ) ;
e1 - > setEditFocus ( true ) ;
2004-09-18 16:41:23 +00:00
2004-09-09 13:25:40 +00:00
QLabel * label = new QLabel ( e1 , i18n ( " &Page: " ) , w ) ;
topLayout - > addWidget ( label ) ;
topLayout - > addWidget ( e1 ) ;
topLayout - > addSpacing ( spacingHint ( ) ) ; // A little bit extra space
topLayout - > addStretch ( 10 ) ;
e1 - > setFocus ( ) ;
}
int getPage ( ) {
return e1 - > value ( ) ;
}
protected :
KIntNumInput * e1 ;
} ;
2004-09-18 16:41:23 +00:00
//END go to page dialog
2004-09-09 13:25:40 +00:00
void Part : : slotGoToPage ( )
{
2004-11-09 17:20:19 +00:00
KPDFGotoPageDialog pageDialog ( m_pageView , m_document - > currentPage ( ) + 1 , m_document - > pages ( ) ) ;
if ( pageDialog . exec ( ) = = QDialog : : Accepted )
2005-01-09 23:37:07 +00:00
m_document - > setViewportPage ( pageDialog . getPage ( ) - 1 ) ;
2002-08-30 09:14:01 +00:00
}
2004-09-09 13:25:40 +00:00
void Part : : slotPreviousPage ( )
2003-09-14 20:23:01 +00:00
{
2004-11-09 17:20:19 +00:00
if ( ! m_document - > currentPage ( ) < 1 )
2005-01-09 23:37:07 +00:00
m_document - > setViewportPage ( m_document - > currentPage ( ) - 1 ) ;
2003-09-14 20:23:01 +00:00
}
2004-09-09 13:25:40 +00:00
void Part : : slotNextPage ( )
2003-09-14 20:23:01 +00:00
{
2004-11-09 17:20:19 +00:00
if ( m_document - > currentPage ( ) < ( m_document - > pages ( ) - 1 ) )
2005-01-09 23:37:07 +00:00
m_document - > setViewportPage ( m_document - > currentPage ( ) + 1 ) ;
2004-09-09 13:25:40 +00:00
}
2004-09-11 15:59:32 +00:00
void Part : : slotGotoFirst ( )
2004-09-09 13:25:40 +00:00
{
2005-01-09 23:37:07 +00:00
m_document - > setViewportPage ( 0 ) ;
2003-09-14 20:23:01 +00:00
}
2004-09-11 15:59:32 +00:00
void Part : : slotGotoLast ( )
2003-09-14 14:54:16 +00:00
{
2005-01-09 23:37:07 +00:00
m_document - > setViewportPage ( m_document - > pages ( ) - 1 ) ;
2003-09-14 14:54:16 +00:00
}
2005-01-27 17:31:07 +00:00
void Part : : slotHistoryBack ( )
{
m_document - > setPrevViewport ( ) ;
}
void Part : : slotHistoryNext ( )
{
m_document - > setNextViewport ( ) ;
}
2004-09-09 13:25:40 +00:00
void Part : : slotFind ( )
2003-09-14 14:54:16 +00:00
{
2004-11-09 17:20:19 +00:00
KFindDialog dlg ( widget ( ) ) ;
dlg . setHasCursor ( false ) ;
2004-10-10 13:33:01 +00:00
# if KDE_IS_VERSION(3,3,90)
2004-11-09 17:20:19 +00:00
dlg . setSupportsBackwardsFind ( false ) ;
dlg . setSupportsWholeWordsFind ( false ) ;
dlg . setSupportsRegularExpressionFind ( false ) ;
2004-10-10 13:33:01 +00:00
# endif
2004-11-09 17:20:19 +00:00
if ( dlg . exec ( ) = = QDialog : : Accepted )
{
2005-02-02 18:18:26 +00:00
m_searchStarted = true ;
2005-02-03 17:09:33 +00:00
m_document - > resetSearch ( PART_SEARCH_ID ) ;
2005-02-02 18:18:26 +00:00
m_document - > searchText ( PART_SEARCH_ID , dlg . pattern ( ) , false , dlg . options ( ) & KFindDialog : : CaseSensitive ,
2005-02-03 17:09:33 +00:00
KPDFDocument : : NextMatch , true , qRgb ( 255 , 255 , 64 ) ) ;
2004-11-09 17:20:19 +00:00
}
2003-09-14 21:53:40 +00:00
}
2004-09-09 13:25:40 +00:00
void Part : : slotFindNext ( )
2003-09-14 21:53:40 +00:00
{
2005-02-02 18:18:26 +00:00
if ( m_searchStarted )
m_document - > continueSearch ( PART_SEARCH_ID ) ;
else
slotFind ( ) ;
2003-09-14 14:22:37 +00:00
}
2004-09-08 12:41:14 +00:00
void Part : : slotSaveFileAs ( )
2004-08-28 17:59:17 +00:00
{
2004-11-05 01:52:48 +00:00
KURL saveURL = KFileDialog : : getSaveURL ( url ( ) . isLocalFile ( ) ? url ( ) . url ( ) : url ( ) . fileName ( ) , QString : : null , widget ( ) ) ;
if ( saveURL . isValid ( ) & & ! saveURL . isEmpty ( ) )
{
2005-06-13 16:08:31 +00:00
if ( KIO : : NetAccess : : exists ( saveURL , false , widget ( ) ) )
{
if ( KMessageBox : : questionYesNo ( widget ( ) , i18n ( " A file named \" %1 \" already exists. Are you sure you want to overwrite it? " ) . arg ( saveURL . filename ( ) ) ) ! = KMessageBox : : Yes )
return ;
}
2004-11-05 01:52:48 +00:00
if ( ! KIO : : NetAccess : : file_copy ( url ( ) , saveURL , - 1 , true ) )
2005-06-13 16:08:31 +00:00
KMessageBox : : information ( widget ( ) , i18n ( " File could not be saved in '%1'. Try to save it to another location. " ) . arg ( saveURL . prettyURL ( ) ) ) ;
2004-11-05 01:52:48 +00:00
}
2004-04-15 18:36:43 +00:00
}
2005-04-16 00:25:26 +00:00
void Part : : slotGetNewStuff ( )
{
// show the modal dialog over pageview and execute it
NewStuffDialog * dialog = new NewStuffDialog ( m_pageView ) ;
dialog - > exec ( ) ;
delete dialog ;
}
2004-10-27 14:15:27 +00:00
void Part : : slotPreferences ( )
2002-08-30 09:14:01 +00:00
{
2004-10-27 14:15:27 +00:00
// an instance the dialog could be already created and could be cached,
// in which case you want to display the cached dialog
if ( PreferencesDialog : : showDialog ( " preferences " ) )
return ;
// we didn't find an instance of this dialog, so lets create it
2004-10-29 13:33:51 +00:00
PreferencesDialog * dialog = new PreferencesDialog ( m_pageView , Settings : : self ( ) ) ;
2004-10-27 14:15:27 +00:00
// keep us informed when the user changes settings
2004-10-29 13:33:51 +00:00
connect ( dialog , SIGNAL ( settingsChanged ( ) ) , this , SLOT ( slotNewConfig ( ) ) ) ;
2004-10-27 14:15:27 +00:00
dialog - > show ( ) ;
}
void Part : : slotNewConfig ( )
{
2004-10-29 13:33:51 +00:00
// Apply settings here. A good policy is to check wether the setting has
// changed before applying changes.
2005-03-12 15:39:04 +00:00
// Watch File
2005-06-13 12:06:45 +00:00
bool watchFile = Settings : : watchFile ( ) ;
2005-03-12 15:39:04 +00:00
if ( watchFile & & m_watcher - > isStopped ( ) )
m_watcher - > startScan ( ) ;
if ( ! watchFile & & ! m_watcher - > isStopped ( ) )
2004-10-29 13:33:51 +00:00
{
2005-03-12 15:39:04 +00:00
m_dirtyHandler - > stop ( ) ;
m_watcher - > stopScan ( ) ;
2004-10-29 13:33:51 +00:00
}
2005-03-12 15:39:04 +00:00
2004-10-29 13:33:51 +00:00
bool showSearch = Settings : : showSearchBar ( ) ;
if ( m_searchWidget - > isShown ( ) ! = showSearch )
m_searchWidget - > setShown ( showSearch ) ;
2004-11-05 18:14:20 +00:00
// Main View (pageView)
2004-10-29 13:33:51 +00:00
QScrollView : : ScrollBarMode scrollBarMode = Settings : : showScrollBars ( ) ?
QScrollView : : AlwaysOn : QScrollView : : AlwaysOff ;
if ( m_pageView - > hScrollBarMode ( ) ! = scrollBarMode )
{
m_pageView - > setHScrollBarMode ( scrollBarMode ) ;
m_pageView - > setVScrollBarMode ( scrollBarMode ) ;
}
2004-11-06 01:48:52 +00:00
2004-11-09 17:20:19 +00:00
// update document settings
m_document - > reparseConfig ( ) ;
2004-11-06 01:48:52 +00:00
// update Main View and ThumbnailList contents
// TODO do this only when changing Settings::renderMode()
2004-11-05 18:14:20 +00:00
m_pageView - > updateContents ( ) ;
2005-03-12 15:39:04 +00:00
if ( Settings : : showLeftPanel ( ) & & m_thumbnailList - > isShown ( ) )
2004-11-07 11:20:27 +00:00
m_thumbnailList - > updateWidgets ( ) ;
2004-10-09 08:10:56 +00:00
}
2002-08-30 09:14:01 +00:00
2004-10-09 08:10:56 +00:00
void Part : : slotPrintPreview ( )
2002-09-02 21:56:00 +00:00
{
2004-11-09 17:20:19 +00:00
if ( m_document - > pages ( ) = = 0 ) return ;
2002-09-02 21:56:00 +00:00
2004-10-09 08:10:56 +00:00
double width , height ;
int landscape , portrait ;
KPrinter printer ;
2004-11-03 21:37:21 +00:00
const KPDFPage * page ;
2004-09-18 16:41:23 +00:00
2004-11-09 17:20:19 +00:00
printer . setMinMax ( 1 , m_document - > pages ( ) ) ;
2004-10-09 08:10:56 +00:00
printer . setPreviewOnly ( true ) ;
printer . setMargins ( 0 , 0 , 0 , 0 ) ;
2004-09-18 16:41:23 +00:00
2004-11-03 21:37:21 +00:00
// if some pages are landscape and others are not the most common win as kprinter does
// not accept a per page setting
2004-10-09 08:10:56 +00:00
landscape = 0 ;
portrait = 0 ;
2004-11-09 17:20:19 +00:00
for ( uint i = 0 ; i < m_document - > pages ( ) ; i + + )
2004-10-09 08:10:56 +00:00
{
2004-11-09 17:20:19 +00:00
page = m_document - > page ( i ) ;
2004-11-03 21:37:21 +00:00
width = page - > width ( ) ;
height = page - > height ( ) ;
if ( page - > rotation ( ) = = 90 | | page - > rotation ( ) = = 270 ) qSwap ( width , height ) ;
if ( width > height ) landscape + + ;
else portrait + + ;
}
2004-10-09 08:10:56 +00:00
if ( landscape > portrait ) printer . setOption ( " orientation-requested " , " 4 " ) ;
2004-09-18 16:41:23 +00:00
2004-10-09 08:10:56 +00:00
doPrint ( printer ) ;
2002-09-02 21:56:00 +00:00
}
2004-12-04 23:23:18 +00:00
void Part : : slotShowMenu ( const KPDFPage * page , const QPoint & point )
{
2004-12-13 00:27:09 +00:00
bool reallyShow = false ;
if ( ! m_actionsSearched )
2004-12-04 23:23:18 +00:00
{
// the quest for options_show_menubar
KXMLGUIClient * client ;
KActionCollection * ac ;
KActionPtrList : : const_iterator it , end , begin ;
KActionPtrList actions ;
2005-03-05 15:59:15 +00:00
if ( factory ( ) )
2004-12-04 23:23:18 +00:00
{
2005-03-05 15:59:15 +00:00
QPtrList < KXMLGUIClient > clients ( factory ( ) - > clients ( ) ) ;
QPtrListIterator < KXMLGUIClient > clientsIt ( clients ) ;
for ( ; ( ! m_showMenuBarAction | | ! m_showFullScreenAction ) & & clientsIt . current ( ) ; + + clientsIt )
2004-12-13 00:27:09 +00:00
{
2005-03-05 15:59:15 +00:00
client = clientsIt . current ( ) ;
ac = client - > actionCollection ( ) ;
actions = ac - > actions ( ) ;
end = actions . end ( ) ;
begin = actions . begin ( ) ;
for ( it = begin ; it ! = end ; + + it )
{
if ( QString ( ( * it ) - > name ( ) ) = = " options_show_menubar " ) m_showMenuBarAction = ( KToggleAction * ) ( * it ) ;
if ( QString ( ( * it ) - > name ( ) ) = = " fullscreen " ) m_showFullScreenAction = ( KToggleAction * ) ( * it ) ;
}
2004-12-13 00:27:09 +00:00
}
2004-12-04 23:23:18 +00:00
}
2004-12-13 00:27:09 +00:00
m_actionsSearched = true ;
2004-12-04 23:23:18 +00:00
}
KPopupMenu * popup = new KPopupMenu ( widget ( ) , " rmb popup " ) ;
if ( page )
{
popup - > insertTitle ( i18n ( " Page %1 " ) . arg ( page - > number ( ) + 1 ) ) ;
2005-02-01 18:26:56 +00:00
if ( page - > hasBookmark ( ) )
2004-12-04 23:23:18 +00:00
popup - > insertItem ( SmallIcon ( " bookmark " ) , i18n ( " Remove Bookmark " ) , 1 ) ;
else
popup - > insertItem ( SmallIcon ( " bookmark_add " ) , i18n ( " Add Bookmark " ) , 1 ) ;
2005-01-10 13:43:44 +00:00
if ( m_pageView - > canFitPageWidth ( ) )
2005-07-15 18:20:57 +00:00
popup - > insertItem ( SmallIcon ( " viewmagfit " ) , i18n ( " Fit Width " ) , 2 ) ;
//popup->insertItem( SmallIcon("view_fit_width"), i18n("Zoom this"), 2 );
2004-12-10 16:04:45 +00:00
//popup->insertItem( SmallIcon("pencil"), i18n("Edit"), 3 );
//popup->setItemEnabled( 3, false );
2004-12-13 00:27:09 +00:00
reallyShow = true ;
2004-12-04 23:23:18 +00:00
}
/*
//Albert says: I have not ported this as i don't see it does anything
2005-02-09 17:45:16 +00:00
if ( d - > mouseOnRect ) // and rect->objectType() == ObjectRect::Image ...
2004-12-04 23:23:18 +00:00
{
2005-01-16 17:04:31 +00:00
m_popup - > insertItem ( SmallIcon ( " filesave " ) , i18n ( " Save Image... " ) , 4 ) ;
2004-12-04 23:23:18 +00:00
m_popup - > setItemEnabled ( 4 , false ) ;
} */
2004-12-13 00:27:09 +00:00
if ( ( m_showMenuBarAction & & ! m_showMenuBarAction - > isChecked ( ) ) | | ( m_showFullScreenAction & & m_showFullScreenAction - > isChecked ( ) ) )
2004-12-04 23:23:18 +00:00
{
popup - > insertTitle ( i18n ( " Tools " ) ) ;
2004-12-13 00:27:09 +00:00
if ( m_showMenuBarAction & & ! m_showMenuBarAction - > isChecked ( ) ) m_showMenuBarAction - > plug ( popup ) ;
if ( m_showFullScreenAction & & m_showFullScreenAction - > isChecked ( ) ) m_showFullScreenAction - > plug ( popup ) ;
reallyShow = true ;
2004-12-04 23:23:18 +00:00
}
2004-12-13 00:27:09 +00:00
if ( reallyShow )
2004-12-04 23:23:18 +00:00
{
2004-12-13 00:27:09 +00:00
switch ( popup - > exec ( point ) )
{
case 1 :
m_document - > toggleBookmark ( page - > number ( ) ) ;
break ;
2005-01-09 23:37:07 +00:00
case 2 :
m_pageView - > fitPageWidth ( page - > number ( ) ) ;
2004-12-13 00:27:09 +00:00
break ;
2005-01-27 17:31:07 +00:00
// case 3: // switch to edit mode
2004-12-13 00:27:09 +00:00
// break;
}
2004-12-04 23:23:18 +00:00
}
delete popup ;
}
2004-12-05 22:47:32 +00:00
void Part : : slotShowProperties ( )
{
2005-01-02 22:37:52 +00:00
PropertiesDialog * d = new PropertiesDialog ( widget ( ) , m_document ) ;
2004-12-05 22:47:32 +00:00
d - > exec ( ) ;
delete d ;
}
2004-12-17 17:14:46 +00:00
void Part : : slotShowPresentation ( )
{
2005-06-13 16:55:57 +00:00
if ( ! m_presentationWidget )
m_presentationWidget = new PresentationWidget ( widget ( ) , m_document ) ;
2004-12-17 17:14:46 +00:00
}
2005-04-07 09:53:15 +00:00
void Part : : slotHidePresentation ( )
{
if ( m_presentationWidget )
delete ( PresentationWidget * ) m_presentationWidget ;
}
2004-10-09 08:10:56 +00:00
void Part : : slotPrint ( )
2004-01-02 17:46:06 +00:00
{
2004-11-09 17:20:19 +00:00
if ( m_document - > pages ( ) = = 0 ) return ;
2004-11-03 21:37:21 +00:00
double width , height ;
int landscape , portrait ;
KPrinter printer ;
const KPDFPage * page ;
printer . setPageSelection ( KPrinter : : ApplicationSide ) ;
2004-11-09 17:20:19 +00:00
printer . setMinMax ( 1 , m_document - > pages ( ) ) ;
printer . setCurrentPage ( m_document - > currentPage ( ) + 1 ) ;
2004-11-03 21:37:21 +00:00
printer . setMargins ( 0 , 0 , 0 , 0 ) ;
// if some pages are landscape and others are not the most common win as kprinter does
// not accept a per page setting
landscape = 0 ;
portrait = 0 ;
2004-11-09 17:20:19 +00:00
for ( uint i = 0 ; i < m_document - > pages ( ) ; i + + )
2004-11-03 21:37:21 +00:00
{
2004-11-09 17:20:19 +00:00
page = m_document - > page ( i ) ;
2004-11-03 21:37:21 +00:00
width = page - > width ( ) ;
height = page - > height ( ) ;
if ( page - > rotation ( ) = = 90 | | page - > rotation ( ) = = 270 ) qSwap ( width , height ) ;
if ( width > height ) landscape + + ;
else portrait + + ;
}
if ( landscape > portrait ) printer . setOrientation ( KPrinter : : Landscape ) ;
- Page/Link: tooltips for links backported
- Page: rotation does not switch height and width
- Document/Part/Generator:
1. Add API for attaching stuff to the interface: ActionCollection and the Navigation Panel
also add possibility to merge an XML .rc file with menu layout. Relevant functions are:
QString Generator::getXMLFile(), returns a QString with your .rc file name.
void Generator::setupGUI (KActionCollection* , QToolbox* ), add your components to the user interface
2. Supporting backend settings:
If during startup, backends which provide a configuration ([X-KDE-oKularHasInternalSettings]
set to true) are found, a menu item: configure backends is created, clicking on it results in
loading all the generators that have settings, but not those that dont. the Generator::addPages(KConfigDialog *dlg)
function should be overloaded by a generator and dlg->addPage should be used to add pages.
If a user opens a file that needs an already loaded generator, the already loaded one is used instead of loading another.
3. Error/Warning/Notice sending support, to send a notice/error/warning, add a relevant notice/error/warning(QString& txt ,int duration)
to the generator class, and sending a message to the user is as simple as emitting a signal!
4. Intercepting of events generated by the PageView is done by Generator::handleEvent(QEvent*), subclass it, do a switch on QEvent::type(), handle your
event and return true if pageview is to proceed with its handling or false if not.
5. Support configuring the KPrinter on the generator side, use Generator::canConfigurePrinter(), return true there, and you get a nonconfigured KPrinter in your
Generator::print()
6. PixmapRequest handling update:
a.) Generator::canGeneratePixmap is now Generator::canGeneratePixmap(bool async)
b.) Document::sendGeneratorRequests is a slot now
c.) Old way of sending pixmaps (Document::requestPixmaps(QValueList<PixmapRequest*> checking if we can generate pixmap if not, waiting for receiving)
is replaced with: requestPixmaps only queues the pixmap all checking if w can generate is done in sendGeneratorReqest, the sendGeneratorRequest is
run in three places:
1. in requestPixmaps when we receive a request
2. in requestDone if pixmapStack is not empty
3. sendGeneratorRequest, apart from removing invalid requests, takes the current request and if generator canGeratePixmap(request->async)
it removes the pixmap from stack and sends to generator if not, QTimer::singleshots to itself after 20ms, it ends when stack has no valid pixmap request
7. Added a commented out zoom field to PixmapGenerator, mightcome in handy sometime
- TextPage: add instructions that handle simplyfing the RegularAreaRect, no more double painted borders in selection rectangles, this rocks.
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=445196
2005-08-10 16:14:39 +00:00
if ( m_document - > canConfigurePrinter ( ) )
doPrint ( printer ) ;
else if ( printer . setup ( widget ( ) ) ) doPrint ( printer ) ;
2004-01-02 17:46:06 +00:00
}
2004-11-03 21:37:21 +00:00
void Part : : doPrint ( KPrinter & printer )
2004-01-02 17:46:06 +00:00
{
2005-03-05 15:59:15 +00:00
if ( ! m_document - > isAllowed ( KPDFDocument : : AllowPrint ) )
2004-11-03 21:37:21 +00:00
{
KMessageBox : : error ( widget ( ) , i18n ( " Printing this document is not allowed. " ) ) ;
return ;
}
2004-11-09 17:20:19 +00:00
if ( ! m_document - > print ( printer ) )
2004-11-03 21:37:21 +00:00
{
KMessageBox : : error ( widget ( ) , i18n ( " Could not print the document. Please report to bugs.kde.org " ) ) ;
}
2004-01-02 17:46:06 +00:00
}
2004-11-01 21:56:08 +00:00
void Part : : restoreDocument ( const KURL & url , int page )
{
if ( openURL ( url ) ) goToPage ( page ) ;
}
void Part : : saveDocumentRestoreInfo ( KConfig * config )
{
config - > writePathEntry ( " URL " , url ( ) . url ( ) ) ;
2004-11-09 17:20:19 +00:00
if ( m_document - > pages ( ) > 0 ) config - > writeEntry ( " Page " , m_document - > currentPage ( ) + 1 ) ;
2004-11-01 21:56:08 +00:00
}
2005-07-15 18:20:57 +00:00
void Part : : psTransformEnded ( )
{
m_file = m_temporaryLocalFile ;
openFile ( ) ;
}
2004-09-18 16:41:23 +00:00
/*
2004-09-08 12:41:14 +00:00
* BrowserExtension class
*/
BrowserExtension : : BrowserExtension ( Part * parent )
: KParts : : BrowserExtension ( parent , " KPDF::BrowserExtension " )
2004-08-26 23:25:52 +00:00
{
2004-09-08 12:41:14 +00:00
emit enableAction ( " print " , true ) ;
setURLDropHandlingEnabled ( true ) ;
}
2004-08-29 11:24:11 +00:00
2004-09-08 12:41:14 +00:00
void BrowserExtension : : print ( )
{
static_cast < Part * > ( parent ( ) ) - > slotPrint ( ) ;
2004-08-26 23:25:52 +00:00
}
2005-01-02 14:29:37 +00:00
# include "part.moc"