• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegraphics API Reference
  • KDE Home
  • Contact Us
 

okular

  • sources
  • kde-4.14
  • kdegraphics
  • okular
part.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2002 by Wilco Greven <greven@kde.org> *
3  * Copyright (C) 2002 by Chris Cheney <ccheney@cheney.cx> *
4  * Copyright (C) 2002 by Malcolm Hunter <malcolm.hunter@gmx.co.uk> *
5  * Copyright (C) 2003-2004 by Christophe Devriese *
6  * <Christophe.Devriese@student.kuleuven.ac.be> *
7  * Copyright (C) 2003 by Daniel Molkentin <molkentin@kde.org> *
8  * Copyright (C) 2003 by Andy Goossens <andygoossens@telenet.be> *
9  * Copyright (C) 2003 by Dirk Mueller <mueller@kde.org> *
10  * Copyright (C) 2003 by Laurent Montel <montel@kde.org> *
11  * Copyright (C) 2004 by Dominique Devriese <devriese@kde.org> *
12  * Copyright (C) 2004 by Christoph Cullmann <crossfire@babylon2k.de> *
13  * Copyright (C) 2004 by Henrique Pinto <stampede@coltec.ufmg.br> *
14  * Copyright (C) 2004 by Waldo Bastian <bastian@kde.org> *
15  * Copyright (C) 2004-2008 by Albert Astals Cid <aacid@kde.org> *
16  * Copyright (C) 2004 by Antti Markus <antti.markus@starman.ee> *
17  * *
18  * This program is free software; you can redistribute it and/or modify *
19  * it under the terms of the GNU General Public License as published by *
20  * the Free Software Foundation; either version 2 of the License, or *
21  * (at your option) any later version. *
22  ***************************************************************************/
23 
24 #include "part.h"
25 
26 // qt/kde includes
27 #include <qapplication.h>
28 #include <qfile.h>
29 #include <qlayout.h>
30 #include <qlabel.h>
31 #include <qtimer.h>
32 #include <QtGui/QPrinter>
33 #include <QtGui/QPrintDialog>
34 #include <QScrollBar>
35 
36 #include <kvbox.h>
37 #include <kaboutapplicationdialog.h>
38 #include <kaction.h>
39 #include <kactioncollection.h>
40 #include <kdirwatch.h>
41 #include <kstandardaction.h>
42 #include <kpluginfactory.h>
43 #include <kfiledialog.h>
44 #include <kinputdialog.h>
45 #include <kmessagebox.h>
46 #include <knuminput.h>
47 #include <kio/netaccess.h>
48 #include <kmenu.h>
49 #include <kxmlguiclient.h>
50 #include <kxmlguifactory.h>
51 #include <kservicetypetrader.h>
52 #include <kstandarddirs.h>
53 #include <kstandardshortcut.h>
54 #include <ktemporaryfile.h>
55 #include <ktoggleaction.h>
56 #include <ktogglefullscreenaction.h>
57 #include <kio/job.h>
58 #include <kicon.h>
59 #include <kfilterdev.h>
60 #include <kfilterbase.h>
61 #if 0
62 #include <knewstuff2/engine.h>
63 #endif
64 #include <kdeprintdialog.h>
65 #include <kprintpreview.h>
66 #include <kbookmarkmenu.h>
67 #include <kpassworddialog.h>
68 #include <kwallet.h>
69 
70 // local includes
71 #include "aboutdata.h"
72 #include "extensions.h"
73 #include "ui/pageview.h"
74 #include "ui/toc.h"
75 #include "ui/searchwidget.h"
76 #include "ui/thumbnaillist.h"
77 #include "ui/side_reviews.h"
78 #include "ui/minibar.h"
79 #include "ui/embeddedfilesdialog.h"
80 #include "ui/propertiesdialog.h"
81 #include "ui/presentationwidget.h"
82 #include "ui/pagesizelabel.h"
83 #include "ui/bookmarklist.h"
84 #include "ui/findbar.h"
85 #include "ui/sidebar.h"
86 #include "ui/fileprinterpreview.h"
87 #include "ui/guiutils.h"
88 #include "conf/preferencesdialog.h"
89 #include "settings.h"
90 #include "core/action.h"
91 #include "core/annotations.h"
92 #include "core/bookmarkmanager.h"
93 #include "core/document.h"
94 #include "core/generator.h"
95 #include "core/page.h"
96 #include "core/fileprinter.h"
97 
98 #include <cstdio>
99 #include <memory>
100 
101 class FileKeeper
102 {
103  public:
104  FileKeeper()
105  : m_handle( NULL )
106  {
107  }
108 
109  ~FileKeeper()
110  {
111  }
112 
113  void open( const QString & path )
114  {
115  if ( !m_handle )
116  m_handle = std::fopen( QFile::encodeName( path ), "r" );
117  }
118 
119  void close()
120  {
121  if ( m_handle )
122  {
123  int ret = std::fclose( m_handle );
124  Q_UNUSED( ret )
125  m_handle = NULL;
126  }
127  }
128 
129  KTemporaryFile* copyToTemporary() const
130  {
131  if ( !m_handle )
132  return 0;
133 
134  KTemporaryFile * retFile = new KTemporaryFile;
135  retFile->open();
136 
137  std::rewind( m_handle );
138  int c = -1;
139  do
140  {
141  c = std::fgetc( m_handle );
142  if ( c == EOF )
143  break;
144  if ( !retFile->putChar( (char)c ) )
145  break;
146  } while ( !feof( m_handle ) );
147 
148  retFile->flush();
149 
150  return retFile;
151  }
152 
153  private:
154  std::FILE * m_handle;
155 };
156 
157 Okular::PartFactory::PartFactory()
158 : KPluginFactory(okularAboutData( "okular", I18N_NOOP( "Okular" ) ))
159 {
160 }
161 
162 Okular::PartFactory::~PartFactory()
163 {
164 }
165 
166 QObject *Okular::PartFactory::create(const char *iface, QWidget *parentWidget, QObject *parent, const QVariantList &args, const QString &keyword)
167 {
168  Q_UNUSED ( keyword );
169 
170  Okular::Part *object = new Okular::Part( parentWidget, parent, args, componentData() );
171  object->setReadWrite( QLatin1String(iface) == QLatin1String("KParts::ReadWritePart") );
172  return object;
173 }
174 
175 K_EXPORT_PLUGIN( Okular::PartFactory() )
176 
177 static QAction* actionForExportFormat( const Okular::ExportFormat& format, QObject *parent = 0 )
178 {
179  QAction *act = new QAction( format.description(), parent );
180  if ( !format.icon().isNull() )
181  {
182  act->setIcon( format.icon() );
183  }
184  return act;
185 }
186 
187 static QString compressedMimeFor( const QString& mime_to_check )
188 {
189  // The compressedMimeMap is here in case you have a very old shared mime database
190  // that doesn't have inheritance info for things like gzeps, etc
191  // Otherwise the "is()" calls below are just good enough
192  static QHash< QString, QString > compressedMimeMap;
193  static bool supportBzip = false;
194  static bool supportXz = false;
195  const QString app_gzip( QString::fromLatin1( "application/x-gzip" ) );
196  const QString app_bzip( QString::fromLatin1( "application/x-bzip" ) );
197  const QString app_xz( QString::fromLatin1( "application/x-xz" ) );
198  if ( compressedMimeMap.isEmpty() )
199  {
200  std::auto_ptr< KFilterBase > f;
201  compressedMimeMap[ QString::fromLatin1( "image/x-gzeps" ) ] = app_gzip;
202  // check we can read bzip2-compressed files
203  f.reset( KFilterBase::findFilterByMimeType( app_bzip ) );
204  if ( f.get() )
205  {
206  supportBzip = true;
207  compressedMimeMap[ QString::fromLatin1( "application/x-bzpdf" ) ] = app_bzip;
208  compressedMimeMap[ QString::fromLatin1( "application/x-bzpostscript" ) ] = app_bzip;
209  compressedMimeMap[ QString::fromLatin1( "application/x-bzdvi" ) ] = app_bzip;
210  compressedMimeMap[ QString::fromLatin1( "image/x-bzeps" ) ] = app_bzip;
211  }
212  // check we can read XZ-compressed files
213  f.reset( KFilterBase::findFilterByMimeType( app_xz ) );
214  if ( f.get() )
215  {
216  supportXz = true;
217  }
218  }
219  QHash< QString, QString >::const_iterator it = compressedMimeMap.constFind( mime_to_check );
220  if ( it != compressedMimeMap.constEnd() )
221  return it.value();
222 
223  KMimeType::Ptr mime = KMimeType::mimeType( mime_to_check );
224  if ( mime )
225  {
226  if ( mime->is( app_gzip ) )
227  return app_gzip;
228  else if ( supportBzip && mime->is( app_bzip ) )
229  return app_bzip;
230  else if ( supportXz && mime->is( app_xz ) )
231  return app_xz;
232  }
233 
234  return QString();
235 }
236 
237 static Okular::EmbedMode detectEmbedMode( QWidget *parentWidget, QObject *parent, const QVariantList &args )
238 {
239  Q_UNUSED( parentWidget );
240 
241  if ( parent
242  && ( parent->objectName() == QLatin1String( "okular::Shell" )
243  || parent->objectName() == QLatin1String( "okular/okular__Shell" ) ) )
244  return Okular::NativeShellMode;
245 
246  if ( parent
247  && ( QByteArray( "KHTMLPart" ) == parent->metaObject()->className() ) )
248  return Okular::KHTMLPartMode;
249 
250  Q_FOREACH ( const QVariant &arg, args )
251  {
252  if ( arg.type() == QVariant::String )
253  {
254  if ( arg.toString() == QLatin1String( "Print/Preview" ) )
255  {
256  return Okular::PrintPreviewMode;
257  }
258  else if ( arg.toString() == QLatin1String( "ViewerWidget" ) )
259  {
260  return Okular::ViewerWidgetMode;
261  }
262  }
263  }
264 
265  return Okular::UnknownEmbedMode;
266 }
267 
268 static QString detectConfigFileName( const QVariantList &args )
269 {
270  Q_FOREACH ( const QVariant &arg, args )
271  {
272  if ( arg.type() == QVariant::String )
273  {
274  QString argString = arg.toString();
275  int separatorIndex = argString.indexOf( "=" );
276  if ( separatorIndex >= 0 && argString.left( separatorIndex ) == QLatin1String( "ConfigFileName" ) )
277  {
278  return argString.mid( separatorIndex + 1 );
279  }
280  }
281  }
282 
283  return QString();
284 }
285 
286 #undef OKULAR_KEEP_FILE_OPEN
287 
288 #ifdef OKULAR_KEEP_FILE_OPEN
289 static bool keepFileOpen()
290 {
291  static bool keep_file_open = !qgetenv("OKULAR_NO_KEEP_FILE_OPEN").toInt();
292  return keep_file_open;
293 }
294 #endif
295 
296 int Okular::Part::numberOfParts = 0;
297 
298 namespace Okular
299 {
300 
301 Part::Part(QWidget *parentWidget,
302 QObject *parent,
303 const QVariantList &args,
304 KComponentData componentData )
305 : KParts::ReadWritePart(parent),
306 m_tempfile( 0 ), m_fileWasRemoved( false ), m_showMenuBarAction( 0 ), m_showFullScreenAction( 0 ), m_actionsSearched( false ),
307 m_cliPresentation(false), m_cliPrint(false), m_embedMode(detectEmbedMode(parentWidget, parent, args)), m_generatorGuiClient(0), m_keeper( 0 )
308 {
309  // first, we check if a config file name has been specified
310  QString configFileName = detectConfigFileName( args );
311  if ( configFileName.isEmpty() )
312  {
313  configFileName = KStandardDirs::locateLocal( "config", "okularpartrc" );
314  // first necessary step: copy the configuration from kpdf, if available
315  if ( !QFile::exists( configFileName ) )
316  {
317  QString oldkpdfconffile = KStandardDirs::locateLocal( "config", "kpdfpartrc" );
318  if ( QFile::exists( oldkpdfconffile ) )
319  QFile::copy( oldkpdfconffile, configFileName );
320  }
321  }
322  Okular::Settings::instance( configFileName );
323 
324  numberOfParts++;
325  if (numberOfParts == 1) {
326  QDBusConnection::sessionBus().registerObject("/okular", this, QDBusConnection::ExportScriptableSlots);
327  } else {
328  QDBusConnection::sessionBus().registerObject(QString("/okular%1").arg(numberOfParts), this, QDBusConnection::ExportScriptableSlots);
329  }
330 
331  // connect the started signal to tell the job the mimetypes we like,
332  // and get some more information from it
333  connect(this, SIGNAL(started(KIO::Job*)), this, SLOT(slotJobStarted(KIO::Job*)));
334 
335  // connect the completed signal so we can put the window caption when loading remote files
336  connect(this, SIGNAL(completed()), this, SLOT(setWindowTitleFromDocument()));
337  connect(this, SIGNAL(canceled(QString)), this, SLOT(loadCancelled(QString)));
338 
339  // create browser extension (for printing when embedded into browser)
340  m_bExtension = new BrowserExtension(this);
341  // create live connect extension (for integrating with browser scripting)
342  new OkularLiveConnectExtension( this );
343 
344  // we need an instance
345  setComponentData( componentData );
346 
347  GuiUtils::addIconLoader( iconLoader() );
348 
349  m_sidebar = new Sidebar( parentWidget );
350  setWidget( m_sidebar );
351  connect( m_sidebar, SIGNAL(urlsDropped(KUrl::List)), SLOT(handleDroppedUrls(KUrl::List)) );
352 
353  // build the document
354  m_document = new Okular::Document(widget());
355  connect( m_document, SIGNAL(linkFind()), this, SLOT(slotFind()) );
356  connect( m_document, SIGNAL(linkGoToPage()), this, SLOT(slotGoToPage()) );
357  connect( m_document, SIGNAL(linkPresentation()), this, SLOT(slotShowPresentation()) );
358  connect( m_document, SIGNAL(linkEndPresentation()), this, SLOT(slotHidePresentation()) );
359  connect( m_document, SIGNAL(openUrl(KUrl)), this, SLOT(openUrlFromDocument(KUrl)) );
360  connect( m_document->bookmarkManager(), SIGNAL(openUrl(KUrl)), this, SLOT(openUrlFromBookmarks(KUrl)) );
361  connect( m_document, SIGNAL(close()), this, SLOT(close()) );
362 
363  if ( parent && parent->metaObject()->indexOfSlot( QMetaObject::normalizedSignature( "slotQuit()" ) ) != -1 )
364  connect( m_document, SIGNAL(quit()), parent, SLOT(slotQuit()) );
365  else
366  connect( m_document, SIGNAL(quit()), this, SLOT(cannotQuit()) );
367  // widgets: ^searchbar (toolbar containing label and SearchWidget)
368  // m_searchToolBar = new KToolBar( parentWidget, "searchBar" );
369  // m_searchToolBar->boxLayout()->setSpacing( KDialog::spacingHint() );
370  // QLabel * sLabel = new QLabel( i18n( "&Search:" ), m_searchToolBar, "kde toolbar widget" );
371  // m_searchWidget = new SearchWidget( m_searchToolBar, m_document );
372  // sLabel->setBuddy( m_searchWidget );
373  // m_searchToolBar->setStretchableWidget( m_searchWidget );
374 
375  int tbIndex;
376  // [left toolbox: Table of Contents] | []
377  m_toc = new TOC( 0, m_document );
378  connect( m_toc, SIGNAL(hasTOC(bool)), this, SLOT(enableTOC(bool)) );
379  tbIndex = m_sidebar->addItem( m_toc, KIcon(QApplication::isLeftToRight() ? "format-justify-left" : "format-justify-right"), i18n("Contents") );
380  enableTOC( false );
381 
382  // [left toolbox: Thumbnails and Bookmarks] | []
383  KVBox * thumbsBox = new ThumbnailsBox( 0 );
384  thumbsBox->setSpacing( 6 );
385  m_searchWidget = new SearchWidget( thumbsBox, m_document );
386  m_thumbnailList = new ThumbnailList( thumbsBox, m_document );
387  // ThumbnailController * m_tc = new ThumbnailController( thumbsBox, m_thumbnailList );
388  connect( m_thumbnailList, SIGNAL(rightClick(const Okular::Page*,QPoint)), this, SLOT(slotShowMenu(const Okular::Page*,QPoint)) );
389  tbIndex = m_sidebar->addItem( thumbsBox, KIcon( "view-preview" ), i18n("Thumbnails") );
390  m_sidebar->setCurrentIndex( tbIndex );
391 
392  // [left toolbox: Reviews] | []
393  m_reviewsWidget = new Reviews( 0, m_document );
394  m_sidebar->addItem( m_reviewsWidget, KIcon("draw-freehand"), i18n("Reviews") );
395  m_sidebar->setItemEnabled( 2, false );
396 
397  // [left toolbox: Bookmarks] | []
398  m_bookmarkList = new BookmarkList( m_document, 0 );
399  m_sidebar->addItem( m_bookmarkList, KIcon("bookmarks"), i18n("Bookmarks") );
400  m_sidebar->setItemEnabled( 3, false );
401 
402  // widgets: [../miniBarContainer] | []
403 #ifdef OKULAR_ENABLE_MINIBAR
404  QWidget * miniBarContainer = new QWidget( 0 );
405  m_sidebar->setBottomWidget( miniBarContainer );
406  QVBoxLayout * miniBarLayout = new QVBoxLayout( miniBarContainer );
407  miniBarLayout->setMargin( 0 );
408  // widgets: [../[spacer/..]] | []
409  miniBarLayout->addItem( new QSpacerItem( 6, 6, QSizePolicy::Fixed, QSizePolicy::Fixed ) );
410  // widgets: [../[../MiniBar]] | []
411  QFrame * bevelContainer = new QFrame( miniBarContainer );
412  bevelContainer->setFrameStyle( QFrame::StyledPanel | QFrame::Sunken );
413  QVBoxLayout * bevelContainerLayout = new QVBoxLayout( bevelContainer );
414  bevelContainerLayout->setMargin( 4 );
415  m_progressWidget = new ProgressWidget( bevelContainer, m_document );
416  bevelContainerLayout->addWidget( m_progressWidget );
417  miniBarLayout->addWidget( bevelContainer );
418  miniBarLayout->addItem( new QSpacerItem( 6, 6, QSizePolicy::Fixed, QSizePolicy::Fixed ) );
419 #endif
420 
421  // widgets: [] | [right 'pageView']
422  QWidget * rightContainer = new QWidget( 0 );
423  m_sidebar->setMainWidget( rightContainer );
424  QVBoxLayout * rightLayout = new QVBoxLayout( rightContainer );
425  rightLayout->setMargin( 0 );
426  rightLayout->setSpacing( 0 );
427  // KToolBar * rtb = new KToolBar( rightContainer, "mainToolBarSS" );
428  // rightLayout->addWidget( rtb );
429  m_topMessage = new KMessageWidget( rightContainer );
430  m_topMessage->setVisible( false );
431  m_topMessage->setWordWrap( true );
432  m_topMessage->setMessageType( KMessageWidget::Information );
433  m_topMessage->setText( i18n( "This document has embedded files. <a href=\"okular:/embeddedfiles\">Click here to see them</a> or go to File -> Embedded Files." ) );
434  m_topMessage->setIcon( KIcon( "mail-attachment" ) );
435  connect( m_topMessage, SIGNAL(linkActivated(QString)), this, SLOT(slotShowEmbeddedFiles()) );
436  rightLayout->addWidget( m_topMessage );
437  m_formsMessage = new KMessageWidget( rightContainer );
438  m_formsMessage->setVisible( false );
439  m_formsMessage->setWordWrap( true );
440  m_formsMessage->setMessageType( KMessageWidget::Information );
441  rightLayout->addWidget( m_formsMessage );
442  m_infoMessage = new KMessageWidget( rightContainer );
443  m_infoMessage->setVisible( false );
444  m_infoMessage->setWordWrap( true );
445  m_infoMessage->setMessageType( KMessageWidget::Information );
446  rightLayout->addWidget( m_infoMessage );
447  m_infoTimer = new QTimer();
448  m_infoTimer->setSingleShot( true );
449  connect( m_infoTimer, SIGNAL(timeout()), m_infoMessage, SLOT(animatedHide()) );
450  m_pageView = new PageView( rightContainer, m_document );
451  QMetaObject::invokeMethod( m_pageView, "setFocus", Qt::QueuedConnection ); //usability setting
452 // m_splitter->setFocusProxy(m_pageView);
453  connect( m_pageView, SIGNAL(rightClick(const Okular::Page*,QPoint)), this, SLOT(slotShowMenu(const Okular::Page*,QPoint)) );
454  connect( m_document, SIGNAL(error(QString,int)), this, SLOT(errorMessage(QString,int)) );
455  connect( m_document, SIGNAL(warning(QString,int)), this, SLOT(warningMessage(QString,int)) );
456  connect( m_document, SIGNAL(notice(QString,int)), this, SLOT(noticeMessage(QString,int)) );
457  connect( m_document, SIGNAL(sourceReferenceActivated(const QString&,int,int,bool*)), this, SLOT(slotHandleActivatedSourceReference(const QString&,int,int,bool*)) );
458  rightLayout->addWidget( m_pageView );
459  m_findBar = new FindBar( m_document, rightContainer );
460  rightLayout->addWidget( m_findBar );
461  m_bottomBar = new QWidget( rightContainer );
462  QHBoxLayout * bottomBarLayout = new QHBoxLayout( m_bottomBar );
463  m_pageSizeLabel = new PageSizeLabel( m_bottomBar, m_document );
464  bottomBarLayout->setMargin( 0 );
465  bottomBarLayout->setSpacing( 0 );
466  bottomBarLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
467  m_miniBarLogic = new MiniBarLogic( this, m_document );
468  m_miniBar = new MiniBar( m_bottomBar, m_miniBarLogic );
469  bottomBarLayout->addWidget( m_miniBar );
470  bottomBarLayout->addWidget( m_pageSizeLabel );
471  rightLayout->addWidget( m_bottomBar );
472 
473  m_pageNumberTool = new MiniBar( 0, m_miniBarLogic );
474 
475  connect( m_findBar, SIGNAL(forwardKeyPressEvent(QKeyEvent*)), m_pageView, SLOT(externalKeyPressEvent(QKeyEvent*)));
476  connect( m_findBar, SIGNAL(onCloseButtonPressed()), m_pageView, SLOT(setFocus()));
477  connect( m_miniBar, SIGNAL(forwardKeyPressEvent(QKeyEvent*)), m_pageView, SLOT(externalKeyPressEvent(QKeyEvent*)));
478  connect( m_pageView, SIGNAL(escPressed()), m_findBar, SLOT(resetSearch()) );
479  connect( m_pageNumberTool, SIGNAL(forwardKeyPressEvent(QKeyEvent*)), m_pageView, SLOT(externalKeyPressEvent(QKeyEvent*)));
480 
481  connect( m_reviewsWidget, SIGNAL(openAnnotationWindow(Okular::Annotation*,int)),
482  m_pageView, SLOT(openAnnotationWindow(Okular::Annotation*,int)) );
483 
484  // add document observers
485  m_document->addObserver( this );
486  m_document->addObserver( m_thumbnailList );
487  m_document->addObserver( m_pageView );
488  m_document->registerView( m_pageView );
489  m_document->addObserver( m_toc );
490  m_document->addObserver( m_miniBarLogic );
491 #ifdef OKULAR_ENABLE_MINIBAR
492  m_document->addObserver( m_progressWidget );
493 #endif
494  m_document->addObserver( m_reviewsWidget );
495  m_document->addObserver( m_pageSizeLabel );
496  m_document->addObserver( m_bookmarkList );
497 
498  connect( m_document->bookmarkManager(), SIGNAL(saved()),
499  this, SLOT(slotRebuildBookmarkMenu()) );
500 
501  setupViewerActions();
502 
503  if ( m_embedMode != ViewerWidgetMode )
504  {
505  setupActions();
506  }
507  else
508  {
509  setViewerShortcuts();
510  }
511 
512  // document watcher and reloader
513  m_watcher = new KDirWatch( this );
514  connect( m_watcher, SIGNAL(dirty(QString)), this, SLOT(slotFileDirty(QString)) );
515  m_dirtyHandler = new QTimer( this );
516  m_dirtyHandler->setSingleShot( true );
517  connect( m_dirtyHandler, SIGNAL(timeout()),this, SLOT(slotDoFileDirty()) );
518 
519  slotNewConfig();
520 
521  // keep us informed when the user changes settings
522  connect( Okular::Settings::self(), SIGNAL(configChanged()), this, SLOT(slotNewConfig()) );
523 
524  // [SPEECH] check for KTTSD presence and usability
525  const KService::Ptr kttsd = KService::serviceByDesktopName("kttsd");
526  Okular::Settings::setUseKTTSD( kttsd );
527  Okular::Settings::self()->writeConfig();
528 
529  rebuildBookmarkMenu( false );
530 
531  if ( m_embedMode == ViewerWidgetMode ) {
532  // set the XML-UI resource file for the viewer mode
533  setXMLFile("part-viewermode.rc");
534  }
535  else
536  {
537  // set our main XML-UI resource file
538  setXMLFile("part.rc");
539  }
540 
541  m_pageView->setupBaseActions( actionCollection() );
542 
543  m_sidebar->setSidebarVisibility( false );
544  if ( m_embedMode != PrintPreviewMode )
545  {
546  // now set up actions that are required for all remaining modes
547  m_pageView->setupViewerActions( actionCollection() );
548  // and if we are not in viewer mode, we want the full GUI
549  if ( m_embedMode != ViewerWidgetMode )
550  {
551  unsetDummyMode();
552  }
553  }
554 
555  // ensure history actions are in the correct state
556  updateViewActions();
557 
558  // also update the state of the actions in the page view
559  m_pageView->updateActionState( false, false, false );
560 
561  if ( m_embedMode == NativeShellMode )
562  m_sidebar->setAutoFillBackground( false );
563 
564 #ifdef OKULAR_KEEP_FILE_OPEN
565  m_keeper = new FileKeeper();
566 #endif
567 }
568 
569 void Part::setupViewerActions()
570 {
571  // ACTIONS
572  KActionCollection * ac = actionCollection();
573 
574  // Page Traversal actions
575  m_gotoPage = KStandardAction::gotoPage( this, SLOT(slotGoToPage()), ac );
576  m_gotoPage->setShortcut( QKeySequence(Qt::CTRL + Qt::Key_G) );
577  // dirty way to activate gotopage when pressing miniBar's button
578  connect( m_miniBar, SIGNAL(gotoPage()), m_gotoPage, SLOT(trigger()) );
579  connect( m_pageNumberTool, SIGNAL(gotoPage()), m_gotoPage, SLOT(trigger()) );
580 
581  m_prevPage = KStandardAction::prior(this, SLOT(slotPreviousPage()), ac);
582  m_prevPage->setIconText( i18nc( "Previous page", "Previous" ) );
583  m_prevPage->setToolTip( i18n( "Go back to the Previous Page" ) );
584  m_prevPage->setWhatsThis( i18n( "Moves to the previous page of the document" ) );
585  m_prevPage->setShortcut( 0 );
586  // dirty way to activate prev page when pressing miniBar's button
587  connect( m_miniBar, SIGNAL(prevPage()), m_prevPage, SLOT(trigger()) );
588  connect( m_pageNumberTool, SIGNAL(prevPage()), m_prevPage, SLOT(trigger()) );
589 #ifdef OKULAR_ENABLE_MINIBAR
590  connect( m_progressWidget, SIGNAL(prevPage()), m_prevPage, SLOT(trigger()) );
591 #endif
592 
593  m_nextPage = KStandardAction::next(this, SLOT(slotNextPage()), ac );
594  m_nextPage->setIconText( i18nc( "Next page", "Next" ) );
595  m_nextPage->setToolTip( i18n( "Advance to the Next Page" ) );
596  m_nextPage->setWhatsThis( i18n( "Moves to the next page of the document" ) );
597  m_nextPage->setShortcut( 0 );
598  // dirty way to activate next page when pressing miniBar's button
599  connect( m_miniBar, SIGNAL(nextPage()), m_nextPage, SLOT(trigger()) );
600  connect( m_pageNumberTool, SIGNAL(nextPage()), m_nextPage, SLOT(trigger()) );
601 #ifdef OKULAR_ENABLE_MINIBAR
602  connect( m_progressWidget, SIGNAL(nextPage()), m_nextPage, SLOT(trigger()) );
603 #endif
604 
605  m_beginningOfDocument = KStandardAction::firstPage( this, SLOT(slotGotoFirst()), ac );
606  ac->addAction("first_page", m_beginningOfDocument);
607  m_beginningOfDocument->setText(i18n( "Beginning of the document"));
608  m_beginningOfDocument->setWhatsThis( i18n( "Moves to the beginning of the document" ) );
609 
610  m_endOfDocument = KStandardAction::lastPage( this, SLOT(slotGotoLast()), ac );
611  ac->addAction("last_page",m_endOfDocument);
612  m_endOfDocument->setText(i18n( "End of the document"));
613  m_endOfDocument->setWhatsThis( i18n( "Moves to the end of the document" ) );
614 
615  // we do not want back and next in history in the dummy mode
616  m_historyBack = 0;
617  m_historyNext = 0;
618 
619  m_addBookmark = KStandardAction::addBookmark( this, SLOT(slotAddBookmark()), ac );
620  m_addBookmarkText = m_addBookmark->text();
621  m_addBookmarkIcon = m_addBookmark->icon();
622 
623  m_renameBookmark = ac->addAction("rename_bookmark");
624  m_renameBookmark->setText(i18n( "Rename Bookmark" ));
625  m_renameBookmark->setIcon(KIcon( "edit-rename" ));
626  m_renameBookmark->setWhatsThis( i18n( "Rename the current bookmark" ) );
627  connect( m_renameBookmark, SIGNAL(triggered()), this, SLOT(slotRenameCurrentViewportBookmark()) );
628 
629  m_prevBookmark = ac->addAction("previous_bookmark");
630  m_prevBookmark->setText(i18n( "Previous Bookmark" ));
631  m_prevBookmark->setIcon(KIcon( "go-up-search" ));
632  m_prevBookmark->setWhatsThis( i18n( "Go to the previous bookmark" ) );
633  connect( m_prevBookmark, SIGNAL(triggered()), this, SLOT(slotPreviousBookmark()) );
634 
635  m_nextBookmark = ac->addAction("next_bookmark");
636  m_nextBookmark->setText(i18n( "Next Bookmark" ));
637  m_nextBookmark->setIcon(KIcon( "go-down-search" ));
638  m_nextBookmark->setWhatsThis( i18n( "Go to the next bookmark" ) );
639  connect( m_nextBookmark, SIGNAL(triggered()), this, SLOT(slotNextBookmark()) );
640 
641  m_copy = 0;
642 
643  m_selectAll = 0;
644 
645  // Find and other actions
646  m_find = KStandardAction::find( this, SLOT(slotShowFindBar()), ac );
647  QList<QKeySequence> s = m_find->shortcuts();
648  s.append( QKeySequence( Qt::Key_Slash ) );
649  m_find->setShortcuts( s );
650  m_find->setEnabled( false );
651 
652  m_findNext = KStandardAction::findNext( this, SLOT(slotFindNext()), ac);
653  m_findNext->setEnabled( false );
654 
655  m_findPrev = KStandardAction::findPrev( this, SLOT(slotFindPrev()), ac );
656  m_findPrev->setEnabled( false );
657 
658  m_saveCopyAs = 0;
659  m_saveAs = 0;
660 
661  QAction * prefs = KStandardAction::preferences( this, SLOT(slotPreferences()), ac);
662  if ( m_embedMode == NativeShellMode )
663  {
664  prefs->setText( i18n( "Configure Okular..." ) );
665  }
666  else
667  {
668  // TODO: improve this message
669  prefs->setText( i18n( "Configure Viewer..." ) );
670  }
671 
672  KAction * genPrefs = new KAction( ac );
673  ac->addAction("options_configure_generators", genPrefs);
674  if ( m_embedMode == ViewerWidgetMode )
675  {
676  genPrefs->setText( i18n( "Configure Viewer Backends..." ) );
677  }
678  else
679  {
680  genPrefs->setText( i18n( "Configure Backends..." ) );
681  }
682  genPrefs->setIcon( KIcon( "configure" ) );
683  genPrefs->setEnabled( m_document->configurableGenerators() > 0 );
684  connect( genPrefs, SIGNAL(triggered(bool)), this, SLOT(slotGeneratorPreferences()) );
685 
686  m_printPreview = KStandardAction::printPreview( this, SLOT(slotPrintPreview()), ac );
687  m_printPreview->setEnabled( false );
688 
689  m_showLeftPanel = 0;
690  m_showBottomBar = 0;
691 
692  m_showProperties = ac->addAction("properties");
693  m_showProperties->setText(i18n("&Properties"));
694  m_showProperties->setIcon(KIcon("document-properties"));
695  connect(m_showProperties, SIGNAL(triggered()), this, SLOT(slotShowProperties()));
696  m_showProperties->setEnabled( false );
697 
698  m_showEmbeddedFiles = 0;
699  m_showPresentation = 0;
700 
701  m_exportAs = 0;
702  m_exportAsMenu = 0;
703  m_exportAsText = 0;
704  m_exportAsDocArchive = 0;
705 
706  m_aboutBackend = ac->addAction("help_about_backend");
707  m_aboutBackend->setText(i18n("About Backend"));
708  m_aboutBackend->setEnabled( false );
709  connect(m_aboutBackend, SIGNAL(triggered()), this, SLOT(slotAboutBackend()));
710 
711  KAction *reload = ac->add<KAction>( "file_reload" );
712  reload->setText( i18n( "Reloa&d" ) );
713  reload->setIcon( KIcon( "view-refresh" ) );
714  reload->setWhatsThis( i18n( "Reload the current document from disk." ) );
715  connect( reload, SIGNAL(triggered()), this, SLOT(slotReload()) );
716  reload->setShortcut( KStandardShortcut::reload() );
717  m_reload = reload;
718 
719  m_closeFindBar = ac->addAction( "close_find_bar", this, SLOT(slotHideFindBar()) );
720  m_closeFindBar->setText( i18n("Close &Find Bar") );
721  m_closeFindBar->setShortcut( QKeySequence(Qt::Key_Escape) );
722  m_closeFindBar->setEnabled( false );
723 
724  KAction *pageno = new KAction( i18n( "Page Number" ), ac );
725  pageno->setDefaultWidget( m_pageNumberTool );
726  ac->addAction( "page_number", pageno );
727 }
728 
729 void Part::setViewerShortcuts()
730 {
731  KActionCollection * ac = actionCollection();
732 
733  m_gotoPage->setShortcut( QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_G) );
734  m_find->setShortcuts( QList<QKeySequence>() );
735 
736  m_findNext->setShortcut( QKeySequence() );
737  m_findPrev->setShortcut( QKeySequence() );
738 
739  m_addBookmark->setShortcut( QKeySequence( Qt::CTRL + Qt::ALT + Qt::Key_B ) );
740 
741  m_beginningOfDocument->setShortcut( QKeySequence( Qt::CTRL + Qt::ALT + Qt::Key_Home ) );
742  m_endOfDocument->setShortcut( QKeySequence( Qt::CTRL + Qt::ALT + Qt::Key_End ) );
743 
744  KAction *action = static_cast<KAction*>( ac->action( "file_reload" ) );
745  if( action ) action->setShortcuts( QList<QKeySequence>() << QKeySequence( Qt::ALT + Qt::Key_F5 ) );
746 }
747 
748 void Part::setupActions()
749 {
750  KActionCollection * ac = actionCollection();
751 
752  m_copy = KStandardAction::create( KStandardAction::Copy, m_pageView, SLOT(copyTextSelection()), ac );
753 
754  m_selectAll = KStandardAction::selectAll( m_pageView, SLOT(selectAll()), ac );
755 
756  m_saveCopyAs = KStandardAction::saveAs( this, SLOT(slotSaveCopyAs()), ac );
757  m_saveCopyAs->setText( i18n( "Save &Copy As..." ) );
758  m_saveCopyAs->setShortcut( KShortcut() );
759  ac->addAction( "file_save_copy", m_saveCopyAs );
760  m_saveCopyAs->setEnabled( false );
761 
762  m_saveAs = KStandardAction::saveAs( this, SLOT(slotSaveFileAs()), ac );
763  m_saveAs->setEnabled( false );
764 
765  m_showLeftPanel = ac->add<KToggleAction>("show_leftpanel");
766  m_showLeftPanel->setText(i18n( "Show &Navigation Panel"));
767  m_showLeftPanel->setIcon(KIcon( "view-sidetree" ));
768  connect( m_showLeftPanel, SIGNAL(toggled(bool)), this, SLOT(slotShowLeftPanel()) );
769  m_showLeftPanel->setShortcut( Qt::Key_F7 );
770  m_showLeftPanel->setChecked( Okular::Settings::showLeftPanel() );
771  slotShowLeftPanel();
772 
773  m_showBottomBar = ac->add<KToggleAction>("show_bottombar");
774  m_showBottomBar->setText(i18n( "Show &Page Bar"));
775  connect( m_showBottomBar, SIGNAL(toggled(bool)), this, SLOT(slotShowBottomBar()) );
776  m_showBottomBar->setChecked( Okular::Settings::showBottomBar() );
777  slotShowBottomBar();
778 
779  m_showEmbeddedFiles = ac->addAction("embedded_files");
780  m_showEmbeddedFiles->setText(i18n("&Embedded Files"));
781  m_showEmbeddedFiles->setIcon( KIcon( "mail-attachment" ) );
782  connect(m_showEmbeddedFiles, SIGNAL(triggered()), this, SLOT(slotShowEmbeddedFiles()));
783  m_showEmbeddedFiles->setEnabled( false );
784 
785  m_exportAs = ac->addAction("file_export_as");
786  m_exportAs->setText(i18n("E&xport As"));
787  m_exportAs->setIcon( KIcon( "document-export" ) );
788  m_exportAsMenu = new QMenu();
789  connect(m_exportAsMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotExportAs(QAction*)));
790  m_exportAs->setMenu( m_exportAsMenu );
791  m_exportAsText = actionForExportFormat( Okular::ExportFormat::standardFormat( Okular::ExportFormat::PlainText ), m_exportAsMenu );
792  m_exportAsMenu->addAction( m_exportAsText );
793  m_exportAs->setEnabled( false );
794  m_exportAsText->setEnabled( false );
795  m_exportAsDocArchive = actionForExportFormat( Okular::ExportFormat(
796  i18nc( "A document format, Okular-specific", "Document Archive" ),
797  KMimeType::mimeType( "application/vnd.kde.okular-archive" ) ), m_exportAsMenu );
798  m_exportAsMenu->addAction( m_exportAsDocArchive );
799  m_exportAsDocArchive->setEnabled( false );
800 
801  m_showPresentation = ac->addAction("presentation");
802  m_showPresentation->setText(i18n("P&resentation"));
803  m_showPresentation->setIcon( KIcon( "view-presentation" ) );
804  connect(m_showPresentation, SIGNAL(triggered()), this, SLOT(slotShowPresentation()));
805  m_showPresentation->setShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_P ) );
806  m_showPresentation->setEnabled( false );
807 
808  QAction * importPS = ac->addAction("import_ps");
809  importPS->setText(i18n("&Import PostScript as PDF..."));
810  importPS->setIcon(KIcon("document-import"));
811  connect(importPS, SIGNAL(triggered()), this, SLOT(slotImportPSFile()));
812 #if 0
813  QAction * ghns = ac->addAction("get_new_stuff");
814  ghns->setText(i18n("&Get Books From Internet..."));
815  ghns->setIcon(KIcon("get-hot-new-stuff"));
816  connect(ghns, SIGNAL(triggered()), this, SLOT(slotGetNewStuff()));
817  // TEMP, REMOVE ME!
818  ghns->setShortcut( Qt::Key_G );
819 #endif
820 
821  KToggleAction *blackscreenAction = new KToggleAction( i18n( "Switch Blackscreen Mode" ), ac );
822  ac->addAction( "switch_blackscreen_mode", blackscreenAction );
823  blackscreenAction->setShortcut( QKeySequence( Qt::Key_B ) );
824  blackscreenAction->setIcon( KIcon( "view-presentation" ) );
825  blackscreenAction->setEnabled( false );
826 
827  KToggleAction *drawingAction = new KToggleAction( i18n( "Toggle Drawing Mode" ), ac );
828  ac->addAction( "presentation_drawing_mode", drawingAction );
829  drawingAction->setIcon( KIcon( "draw-freehand" ) );
830  drawingAction->setEnabled( false );
831 
832  KAction *eraseDrawingAction = new KAction( i18n( "Erase Drawings" ), ac );
833  ac->addAction( "presentation_erase_drawings", eraseDrawingAction );
834  eraseDrawingAction->setIcon( KIcon( "draw-eraser" ) );
835  eraseDrawingAction->setEnabled( false );
836 
837  KAction *configureAnnotations = new KAction( i18n( "Configure Annotations..." ), ac );
838  ac->addAction( "options_configure_annotations", configureAnnotations );
839  configureAnnotations->setIcon( KIcon( "configure" ) );
840  connect(configureAnnotations, SIGNAL(triggered()), this, SLOT(slotAnnotationPreferences()));
841 
842  KAction *playPauseAction = new KAction( i18n( "Play/Pause Presentation" ), ac );
843  ac->addAction( "presentation_play_pause", playPauseAction );
844  playPauseAction->setEnabled( false );
845 }
846 
847 Part::~Part()
848 {
849  GuiUtils::removeIconLoader( iconLoader() );
850  m_document->removeObserver( this );
851 
852  if ( m_document->isOpened() )
853  Part::closeUrl( false );
854 
855  delete m_toc;
856  delete m_pageView;
857  delete m_thumbnailList;
858  delete m_miniBar;
859  delete m_pageNumberTool;
860  delete m_miniBarLogic;
861  delete m_bottomBar;
862 #ifdef OKULAR_ENABLE_MINIBAR
863  delete m_progressWidget;
864 #endif
865  delete m_pageSizeLabel;
866  delete m_reviewsWidget;
867  delete m_bookmarkList;
868  delete m_infoTimer;
869 
870  delete m_document;
871 
872  delete m_tempfile;
873 
874  qDeleteAll( m_bookmarkActions );
875 
876  delete m_exportAsMenu;
877 
878 #ifdef OKULAR_KEEP_FILE_OPEN
879  delete m_keeper;
880 #endif
881 }
882 
883 
884 bool Part::openDocument(const KUrl& url, uint page)
885 {
886  Okular::DocumentViewport vp( page - 1 );
887  vp.rePos.enabled = true;
888  vp.rePos.normalizedX = 0;
889  vp.rePos.normalizedY = 0;
890  vp.rePos.pos = Okular::DocumentViewport::TopLeft;
891  if ( vp.isValid() )
892  m_document->setNextDocumentViewport( vp );
893  return openUrl( url );
894 }
895 
896 
897 void Part::startPresentation()
898 {
899  m_cliPresentation = true;
900 }
901 
902 
903 QStringList Part::supportedMimeTypes() const
904 {
905  return m_document->supportedMimeTypes();
906 }
907 
908 
909 KUrl Part::realUrl() const
910 {
911  if ( !m_realUrl.isEmpty() )
912  return m_realUrl;
913 
914  return url();
915 }
916 
917 // ViewerInterface
918 
919 void Part::showSourceLocation(const QString& fileName, int line, int column, bool showGraphically)
920 {
921  const QString u = QString( "src:%1 %2" ).arg( line + 1 ).arg( fileName );
922  GotoAction action( QString(), u );
923  m_document->processAction( &action );
924  if( showGraphically )
925  {
926  m_pageView->setLastSourceLocationViewport( m_document->viewport() );
927  }
928 }
929 
930 void Part::clearLastShownSourceLocation()
931 {
932  m_pageView->clearLastSourceLocationViewport();
933 }
934 
935 bool Part::isWatchFileModeEnabled() const
936 {
937  return !m_watcher->isStopped();
938 }
939 
940 void Part::setWatchFileModeEnabled(bool enabled)
941 {
942  if ( enabled && m_watcher->isStopped() )
943  {
944  m_watcher->startScan();
945  }
946  else if( !enabled && !m_watcher->isStopped() )
947  {
948  m_dirtyHandler->stop();
949  m_watcher->stopScan();
950  }
951 }
952 
953 bool Part::areSourceLocationsShownGraphically() const
954 {
955  return m_pageView->areSourceLocationsShownGraphically();
956 }
957 
958 void Part::setShowSourceLocationsGraphically(bool show)
959 {
960  m_pageView->setShowSourceLocationsGraphically(show);
961 }
962 
963 bool Part::openNewFilesInTabs() const
964 {
965  return Okular::Settings::self()->shellOpenFileInTabs();
966 }
967 
968 void Part::slotHandleActivatedSourceReference(const QString& absFileName, int line, int col, bool *handled)
969 {
970  emit openSourceReference( absFileName, line, col );
971  if ( m_embedMode == Okular::ViewerWidgetMode )
972  {
973  *handled = true;
974  }
975 }
976 
977 void Part::openUrlFromDocument(const KUrl &url)
978 {
979  if ( m_embedMode == PrintPreviewMode )
980  return;
981 
982  if (KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, widget()))
983  {
984  m_bExtension->openUrlNotify();
985  m_bExtension->setLocationBarUrl(url.prettyUrl());
986  openUrl(url);
987  } else {
988  KMessageBox::error( widget(), i18n("Could not open '%1'. File does not exist", url.pathOrUrl() ) );
989  }
990 }
991 
992 void Part::openUrlFromBookmarks(const KUrl &_url)
993 {
994  KUrl url = _url;
995  Okular::DocumentViewport vp( _url.htmlRef() );
996  if ( vp.isValid() )
997  m_document->setNextDocumentViewport( vp );
998  url.setHTMLRef( QString() );
999  if ( m_document->currentDocument() == url )
1000  {
1001  if ( vp.isValid() )
1002  m_document->setViewport( vp );
1003  }
1004  else
1005  openUrl( url );
1006 }
1007 
1008 void Part::handleDroppedUrls( const KUrl::List& urls )
1009 {
1010  if ( urls.isEmpty() )
1011  return;
1012 
1013  if ( m_embedMode != NativeShellMode || !openNewFilesInTabs() )
1014  {
1015  openUrlFromDocument( urls.first() );
1016  return;
1017  }
1018 
1019  emit urlsDropped( urls );
1020 }
1021 
1022 void Part::slotJobStarted(KIO::Job *job)
1023 {
1024  if (job)
1025  {
1026  QStringList supportedMimeTypes = m_document->supportedMimeTypes();
1027  job->addMetaData("accept", supportedMimeTypes.join(", ") + ", */*;q=0.5");
1028 
1029  connect(job, SIGNAL(result(KJob*)), this, SLOT(slotJobFinished(KJob*)));
1030  }
1031 }
1032 
1033 void Part::slotJobFinished(KJob *job)
1034 {
1035  if ( job->error() == KIO::ERR_USER_CANCELED )
1036  {
1037  m_pageView->displayMessage( i18n( "The loading of %1 has been canceled.", realUrl().pathOrUrl() ) );
1038  }
1039 }
1040 
1041 void Part::loadCancelled(const QString &reason)
1042 {
1043  emit setWindowCaption( QString() );
1044  resetStartArguments();
1045 
1046  // when m_viewportDirty.pageNumber != -1 we come from slotDoFileDirty
1047  // so we don't want to show an ugly messagebox just because the document is
1048  // taking more than usual to be recreated
1049  if (m_viewportDirty.pageNumber == -1)
1050  {
1051  if (!reason.isEmpty())
1052  {
1053  KMessageBox::error( widget(), i18n("Could not open %1. Reason: %2", url().prettyUrl(), reason ) );
1054  }
1055  }
1056 }
1057 
1058 void Part::setWindowTitleFromDocument()
1059 {
1060  // If 'DocumentTitle' should be used, check if the document has one. If
1061  // either case is false, use the file name.
1062  QString title = Okular::Settings::displayDocumentNameOrPath() == Okular::Settings::EnumDisplayDocumentNameOrPath::Path ? realUrl().pathOrUrl() : realUrl().fileName();
1063 
1064  if ( Okular::Settings::displayDocumentTitle() )
1065  {
1066  const QString docTitle = m_document->metaData( "DocumentTitle" ).toString();
1067  if ( !docTitle.isEmpty() && !docTitle.trimmed().isEmpty() )
1068  {
1069  title = docTitle;
1070  }
1071  }
1072 
1073  emit setWindowCaption( title );
1074 }
1075 
1076 KConfigDialog * Part::slotGeneratorPreferences( )
1077 {
1078  // Create dialog
1079  KConfigDialog * dialog = new KConfigDialog( m_pageView, "generator_prefs", Okular::Settings::self() );
1080  dialog->setAttribute( Qt::WA_DeleteOnClose );
1081 
1082  if( m_embedMode == ViewerWidgetMode )
1083  {
1084  dialog->setCaption( i18n( "Configure Viewer Backends" ) );
1085  }
1086  else
1087  {
1088  dialog->setCaption( i18n( "Configure Backends" ) );
1089  }
1090 
1091  m_document->fillConfigDialog( dialog );
1092 
1093  // Show it
1094  dialog->setWindowModality( Qt::ApplicationModal );
1095  dialog->show();
1096 
1097  return dialog;
1098 }
1099 
1100 
1101 void Part::notifySetup( const QVector< Okular::Page * > & /*pages*/, int setupFlags )
1102 {
1103  if ( !( setupFlags & Okular::DocumentObserver::DocumentChanged ) )
1104  return;
1105 
1106  rebuildBookmarkMenu();
1107  updateAboutBackendAction();
1108  m_findBar->resetSearch();
1109  m_searchWidget->setEnabled( m_document->supportsSearching() );
1110 }
1111 
1112 void Part::notifyViewportChanged( bool /*smoothMove*/ )
1113 {
1114  updateViewActions();
1115 }
1116 
1117 void Part::notifyPageChanged( int page, int flags )
1118 {
1119  if ( flags & Okular::DocumentObserver::NeedSaveAs )
1120  setModified();
1121 
1122  if ( !(flags & Okular::DocumentObserver::Bookmark ) )
1123  return;
1124 
1125  rebuildBookmarkMenu();
1126  if ( page == m_document->viewport().pageNumber )
1127  updateBookmarksActions();
1128 }
1129 
1130 
1131 void Part::goToPage(uint i)
1132 {
1133  if ( i <= m_document->pages() )
1134  m_document->setViewportPage( i - 1 );
1135 }
1136 
1137 
1138 void Part::openDocument( const QString &doc )
1139 {
1140  openUrl( KUrl( doc ) );
1141 }
1142 
1143 
1144 uint Part::pages()
1145 {
1146  return m_document->pages();
1147 }
1148 
1149 
1150 uint Part::currentPage()
1151 {
1152  return m_document->pages() ? m_document->currentPage() + 1 : 0;
1153 }
1154 
1155 
1156 QString Part::currentDocument()
1157 {
1158  return m_document->currentDocument().pathOrUrl();
1159 }
1160 
1161 
1162 QString Part::documentMetaData( const QString &metaData ) const
1163 {
1164  const Okular::DocumentInfo * info = m_document->documentInfo();
1165  if ( info )
1166  {
1167  QDomElement docElement = info->documentElement();
1168  for ( QDomNode node = docElement.firstChild(); !node.isNull(); node = node.nextSibling() )
1169  {
1170  const QDomElement element = node.toElement();
1171  if ( metaData.compare( element.tagName(), Qt::CaseInsensitive ) == 0 )
1172  return element.attribute( "value" );
1173  }
1174  }
1175 
1176  return QString();
1177 }
1178 
1179 
1180 bool Part::slotImportPSFile()
1181 {
1182  QString app = KStandardDirs::findExe( "ps2pdf" );
1183  if ( app.isEmpty() )
1184  {
1185  // TODO point the user to their distro packages?
1186  KMessageBox::error( widget(), i18n( "The program \"ps2pdf\" was not found, so Okular can not import PS files using it." ), i18n("ps2pdf not found") );
1187  return false;
1188  }
1189 
1190  KUrl url = KFileDialog::getOpenUrl( KUrl(), "application/postscript", this->widget() );
1191  if ( url.isLocalFile() )
1192  {
1193  KTemporaryFile tf;
1194  tf.setSuffix( ".pdf" );
1195  tf.setAutoRemove( false );
1196  if ( !tf.open() )
1197  return false;
1198  m_temporaryLocalFile = tf.fileName();
1199  tf.close();
1200 
1201  setLocalFilePath( url.toLocalFile() );
1202  QStringList args;
1203  QProcess *p = new QProcess();
1204  args << url.toLocalFile() << m_temporaryLocalFile;
1205  m_pageView->displayMessage(i18n("Importing PS file as PDF (this may take a while)..."));
1206  connect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(psTransformEnded(int,QProcess::ExitStatus)));
1207  p->start(app, args);
1208  return true;
1209  }
1210 
1211  m_temporaryLocalFile.clear();
1212  return false;
1213 }
1214 
1215 static void addFileToWatcher( KDirWatch *watcher, const QString &filePath)
1216 {
1217  if ( !watcher->contains( filePath ) ) watcher->addFile(filePath);
1218  const QFileInfo fi(filePath);
1219  if ( !watcher->contains( fi.absolutePath() ) ) watcher->addDir(fi.absolutePath());
1220  if ( fi.isSymLink() ) watcher->addFile( fi.readLink() );
1221 }
1222 
1223 Document::OpenResult Part::doOpenFile( const KMimeType::Ptr &mimeA, const QString &fileNameToOpenA, bool *isCompressedFile )
1224 {
1225  Document::OpenResult openResult = Document::OpenError;
1226  bool uncompressOk = true;
1227  KMimeType::Ptr mime = mimeA;
1228  QString fileNameToOpen = fileNameToOpenA;
1229  QString compressedMime = compressedMimeFor( mime->name() );
1230  if ( compressedMime.isEmpty() )
1231  compressedMime = compressedMimeFor( mime->parentMimeType() );
1232  if ( !compressedMime.isEmpty() )
1233  {
1234  *isCompressedFile = true;
1235  uncompressOk = handleCompressed( fileNameToOpen, localFilePath(), compressedMime );
1236  mime = KMimeType::findByPath( fileNameToOpen );
1237  }
1238  else
1239  {
1240  *isCompressedFile = false;
1241  }
1242 
1243  isDocumentArchive = false;
1244  if ( uncompressOk )
1245  {
1246  if ( mime->is( "application/vnd.kde.okular-archive" ) )
1247  {
1248  openResult = m_document->openDocumentArchive( fileNameToOpen, url() );
1249  isDocumentArchive = true;
1250  }
1251  else
1252  {
1253  openResult = m_document->openDocument( fileNameToOpen, url(), mime );
1254  }
1255 
1256  // if the file didn't open correctly it might be encrypted, so ask for a pass
1257  QString walletName, walletFolder, walletKey;
1258  m_document->walletDataForFile(fileNameToOpen, &walletName, &walletFolder, &walletKey);
1259  bool firstInput = true;
1260  bool triedWallet = false;
1261  KWallet::Wallet * wallet = 0;
1262  bool keep = true;
1263  while ( openResult == Document::OpenNeedsPassword )
1264  {
1265  QString password;
1266 
1267  // 1.A. try to retrieve the first password from the kde wallet system
1268  if ( !triedWallet && !walletKey.isNull() )
1269  {
1270  const WId parentwid = widget()->effectiveWinId();
1271  wallet = KWallet::Wallet::openWallet( walletName, parentwid );
1272  if ( wallet )
1273  {
1274  // use the KPdf folder (and create if missing)
1275  if ( !wallet->hasFolder( walletFolder ) )
1276  wallet->createFolder( walletFolder );
1277  wallet->setFolder( walletFolder );
1278 
1279  // look for the pass in that folder
1280  QString retrievedPass;
1281  if ( !wallet->readPassword( walletKey, retrievedPass ) )
1282  password = retrievedPass;
1283  }
1284  triedWallet = true;
1285  }
1286 
1287  // 1.B. if not retrieved, ask the password using the kde password dialog
1288  if ( password.isNull() )
1289  {
1290  QString prompt;
1291  if ( firstInput )
1292  prompt = i18n( "Please enter the password to read the document:" );
1293  else
1294  prompt = i18n( "Incorrect password. Try again:" );
1295  firstInput = false;
1296 
1297  // if the user presses cancel, abort opening
1298  KPasswordDialog dlg( widget(), wallet ? KPasswordDialog::ShowKeepPassword : KPasswordDialog::KPasswordDialogFlags() );
1299  dlg.setCaption( i18n( "Document Password" ) );
1300  dlg.setPrompt( prompt );
1301  if( !dlg.exec() )
1302  break;
1303  password = dlg.password();
1304  if ( wallet )
1305  keep = dlg.keepPassword();
1306  }
1307 
1308  // 2. reopen the document using the password
1309  if ( mime->is( "application/vnd.kde.okular-archive" ) )
1310  {
1311  openResult = m_document->openDocumentArchive( fileNameToOpen, url(), password );
1312  isDocumentArchive = true;
1313  }
1314  else
1315  {
1316  openResult = m_document->openDocument( fileNameToOpen, url(), mime, password );
1317  }
1318 
1319  // 3. if the password is correct and the user chose to remember it, store it to the wallet
1320  if ( openResult == Document::OpenSuccess && wallet && /*safety check*/ wallet->isOpen() && keep )
1321  {
1322  wallet->writePassword( walletKey, password );
1323  }
1324  }
1325  }
1326 
1327  return openResult;
1328 }
1329 
1330 bool Part::openFile()
1331 {
1332  QList<KMimeType::Ptr> mimes;
1333  QString fileNameToOpen = localFilePath();
1334  const bool isstdin = url().isLocalFile() && url().fileName( KUrl::ObeyTrailingSlash ) == QLatin1String( "-" );
1335  const QFileInfo fileInfo( fileNameToOpen );
1336  if ( !isstdin && !fileInfo.exists() )
1337  return false;
1338  KMimeType::Ptr pathMime = KMimeType::findByPath( fileNameToOpen );
1339  if ( !arguments().mimeType().isEmpty() )
1340  {
1341  KMimeType::Ptr argMime = KMimeType::mimeType( arguments().mimeType() );
1342 
1343  // Select the "childmost" mimetype, if none of them
1344  // inherits the other trust more what pathMime says
1345  // but still do a second try if that one fails
1346  if ( argMime->is( pathMime->name() ) )
1347  {
1348  mimes << argMime;
1349  }
1350  else if ( pathMime->is( argMime->name() ) )
1351  {
1352  mimes << pathMime;
1353  }
1354  else
1355  {
1356  mimes << pathMime << argMime;
1357  }
1358 
1359  if (mimes[0]->name() == "text/plain") {
1360  KMimeType::Ptr contentMime = KMimeType::findByFileContent( fileNameToOpen );
1361  mimes.prepend( contentMime );
1362  }
1363  }
1364  else
1365  {
1366  mimes << pathMime;
1367  }
1368 
1369  KMimeType::Ptr mime;
1370  Document::OpenResult openResult = Document::OpenError;
1371  bool isCompressedFile = false;
1372  while ( !mimes.isEmpty() && openResult == Document::OpenError ) {
1373  mime = mimes.takeFirst();
1374  openResult = doOpenFile( mime, fileNameToOpen, &isCompressedFile );
1375  }
1376 
1377  bool canSearch = m_document->supportsSearching();
1378  emit mimeTypeChanged( mime );
1379 
1380  // update one-time actions
1381  const bool ok = openResult == Document::OpenSuccess;
1382  emit enableCloseAction( ok );
1383  m_find->setEnabled( ok && canSearch );
1384  m_findNext->setEnabled( ok && canSearch );
1385  m_findPrev->setEnabled( ok && canSearch );
1386  if( m_saveAs ) m_saveAs->setEnabled( ok && (m_document->canSaveChanges() || isDocumentArchive) );
1387  if( m_saveCopyAs ) m_saveCopyAs->setEnabled( ok );
1388  emit enablePrintAction( ok && m_document->printingSupport() != Okular::Document::NoPrinting );
1389  m_printPreview->setEnabled( ok && m_document->printingSupport() != Okular::Document::NoPrinting );
1390  m_showProperties->setEnabled( ok );
1391  bool hasEmbeddedFiles = ok && m_document->embeddedFiles() && m_document->embeddedFiles()->count() > 0;
1392  if ( m_showEmbeddedFiles ) m_showEmbeddedFiles->setEnabled( hasEmbeddedFiles );
1393  m_topMessage->setVisible( hasEmbeddedFiles && Okular::Settings::showOSD() );
1394 
1395  // Warn the user that XFA forms are not supported yet (NOTE: poppler generator only)
1396  if ( ok && m_document->metaData( "HasUnsupportedXfaForm" ).toBool() == true )
1397  {
1398  m_formsMessage->setText( i18n( "This document has XFA forms, which are currently <b>unsupported</b>." ) );
1399  m_formsMessage->setIcon( KIcon( "dialog-warning" ) );
1400  m_formsMessage->setMessageType( KMessageWidget::Warning );
1401  m_formsMessage->setVisible( true );
1402  }
1403  // m_pageView->toggleFormsAction() may be null on dummy mode
1404  else if ( ok && m_pageView->toggleFormsAction() && m_pageView->toggleFormsAction()->isEnabled() )
1405  {
1406  m_formsMessage->setText( i18n( "This document has forms. Click on the button to interact with them, or use View -> Show Forms." ) );
1407  m_formsMessage->setMessageType( KMessageWidget::Information );
1408  m_formsMessage->setVisible( true );
1409  }
1410  else
1411  {
1412  m_formsMessage->setVisible( false );
1413  }
1414 
1415  if ( m_showPresentation ) m_showPresentation->setEnabled( ok );
1416  if ( ok )
1417  {
1418  if ( m_exportAs )
1419  {
1420  m_exportFormats = m_document->exportFormats();
1421  QList<Okular::ExportFormat>::ConstIterator it = m_exportFormats.constBegin();
1422  QList<Okular::ExportFormat>::ConstIterator itEnd = m_exportFormats.constEnd();
1423  QMenu *menu = m_exportAs->menu();
1424  for ( ; it != itEnd; ++it )
1425  {
1426  menu->addAction( actionForExportFormat( *it ) );
1427  }
1428  }
1429  if ( isCompressedFile )
1430  {
1431  m_realUrl = url();
1432  }
1433 #ifdef OKULAR_KEEP_FILE_OPEN
1434  if ( keepFileOpen() )
1435  m_keeper->open( fileNameToOpen );
1436 #endif
1437  }
1438  if ( m_exportAsText ) m_exportAsText->setEnabled( ok && m_document->canExportToText() );
1439  if ( m_exportAsDocArchive ) m_exportAsDocArchive->setEnabled( ok );
1440  if ( m_exportAs ) m_exportAs->setEnabled( ok );
1441 
1442  // update viewing actions
1443  updateViewActions();
1444 
1445  m_fileWasRemoved = false;
1446 
1447  if ( !ok )
1448  {
1449  // if can't open document, update windows so they display blank contents
1450  m_pageView->viewport()->update();
1451  m_thumbnailList->update();
1452  setUrl( KUrl() );
1453  return false;
1454  }
1455 
1456  // set the file to the fileWatcher
1457  if ( url().isLocalFile() )
1458  {
1459  addFileToWatcher( m_watcher, localFilePath() );
1460  }
1461 
1462  // if the 'OpenTOC' flag is set, open the TOC
1463  if ( m_document->metaData( "OpenTOC" ).toBool() && m_sidebar->isItemEnabled( 0 ) && !m_sidebar->isCollapsed() && m_sidebar->currentIndex() != 0 )
1464  {
1465  m_sidebar->setCurrentIndex( 0, Sidebar::DoNotUncollapseIfCollapsed );
1466  }
1467  // if the 'StartFullScreen' flag is set, or the command line flag was
1468  // specified, start presentation
1469  if ( m_document->metaData( "StartFullScreen" ).toBool() || m_cliPresentation )
1470  {
1471  bool goAheadWithPresentationMode = true;
1472  if ( !m_cliPresentation )
1473  {
1474  const QString text = i18n( "The document requested to be launched in presentation mode.\n"
1475  "Do you want to allow it?" );
1476  const QString caption = i18n( "Presentation Mode" );
1477  const KGuiItem yesItem = KGuiItem( i18n( "Allow" ), "dialog-ok", i18n( "Allow the presentation mode" ) );
1478  const KGuiItem noItem = KGuiItem( i18n( "Do Not Allow" ), "process-stop", i18n( "Do not allow the presentation mode" ) );
1479  const int result = KMessageBox::questionYesNo( widget(), text, caption, yesItem, noItem );
1480  if ( result == KMessageBox::No )
1481  goAheadWithPresentationMode = false;
1482  }
1483  m_cliPresentation = false;
1484  if ( goAheadWithPresentationMode )
1485  QMetaObject::invokeMethod( this, "slotShowPresentation", Qt::QueuedConnection );
1486  }
1487  m_generatorGuiClient = factory() ? m_document->guiClient() : 0;
1488  if ( m_generatorGuiClient )
1489  factory()->addClient( m_generatorGuiClient );
1490  if ( m_cliPrint )
1491  {
1492  m_cliPrint = false;
1493  slotPrint();
1494  }
1495  return true;
1496 }
1497 
1498 bool Part::openUrl(const KUrl &_url)
1499 {
1500  // Close current document if any
1501  if ( !closeUrl() )
1502  return false;
1503 
1504  KUrl url( _url );
1505  if ( url.hasHTMLRef() )
1506  {
1507  const QString dest = url.htmlRef();
1508  bool ok = true;
1509  const int page = dest.toInt( &ok );
1510  if ( ok )
1511  {
1512  Okular::DocumentViewport vp( page - 1 );
1513  vp.rePos.enabled = true;
1514  vp.rePos.normalizedX = 0;
1515  vp.rePos.normalizedY = 0;
1516  vp.rePos.pos = Okular::DocumentViewport::TopLeft;
1517  m_document->setNextDocumentViewport( vp );
1518  }
1519  else
1520  {
1521  m_document->setNextDocumentDestination( dest );
1522  }
1523  url.setHTMLRef( QString() );
1524  }
1525 
1526  // this calls in sequence the 'closeUrl' and 'openFile' methods
1527  bool openOk = KParts::ReadWritePart::openUrl( url );
1528 
1529  if ( openOk )
1530  {
1531  m_viewportDirty.pageNumber = -1;
1532 
1533  setWindowTitleFromDocument();
1534  }
1535  else
1536  {
1537  resetStartArguments();
1538  KMessageBox::error( widget(), i18n("Could not open %1", url.pathOrUrl() ) );
1539  }
1540 
1541  return openOk;
1542 }
1543 
1544 bool Part::queryClose()
1545 {
1546  if ( !isReadWrite() || !isModified() )
1547  return true;
1548 
1549  const int res = KMessageBox::warningYesNoCancel( widget(),
1550  i18n( "Do you want to save your annotation changes or discard them?" ),
1551  i18n( "Close Document" ),
1552  KStandardGuiItem::saveAs(),
1553  KStandardGuiItem::discard() );
1554 
1555  switch ( res )
1556  {
1557  case KMessageBox::Yes: // Save as
1558  slotSaveFileAs();
1559  return !isModified(); // Only allow closing if file was really saved
1560  case KMessageBox::No: // Discard
1561  return true;
1562  default: // Cancel
1563  return false;
1564  }
1565 }
1566 
1567 bool Part::closeUrl(bool promptToSave)
1568 {
1569  if ( promptToSave && !queryClose() )
1570  return false;
1571 
1572  setModified( false );
1573 
1574  if (!m_temporaryLocalFile.isNull() && m_temporaryLocalFile != localFilePath())
1575  {
1576  QFile::remove( m_temporaryLocalFile );
1577  m_temporaryLocalFile.clear();
1578  }
1579 
1580  slotHidePresentation();
1581  emit enableCloseAction( false );
1582  m_find->setEnabled( false );
1583  m_findNext->setEnabled( false );
1584  m_findPrev->setEnabled( false );
1585  if( m_saveAs ) m_saveAs->setEnabled( false );
1586  if( m_saveCopyAs ) m_saveCopyAs->setEnabled( false );
1587  m_printPreview->setEnabled( false );
1588  m_showProperties->setEnabled( false );
1589  if ( m_showEmbeddedFiles ) m_showEmbeddedFiles->setEnabled( false );
1590  if ( m_exportAs ) m_exportAs->setEnabled( false );
1591  if ( m_exportAsText ) m_exportAsText->setEnabled( false );
1592  if ( m_exportAsDocArchive ) m_exportAsDocArchive->setEnabled( false );
1593  m_exportFormats.clear();
1594  if ( m_exportAs )
1595  {
1596  QMenu *menu = m_exportAs->menu();
1597  QList<QAction*> acts = menu->actions();
1598  int num = acts.count();
1599  for ( int i = 2; i < num; ++i )
1600  {
1601  menu->removeAction( acts.at(i) );
1602  delete acts.at(i);
1603  }
1604  }
1605  if ( m_showPresentation ) m_showPresentation->setEnabled( false );
1606  emit setWindowCaption("");
1607  emit enablePrintAction(false);
1608  m_realUrl = KUrl();
1609  if ( url().isLocalFile() )
1610  {
1611  m_watcher->removeFile( localFilePath() );
1612  QFileInfo fi(localFilePath());
1613  m_watcher->removeDir( fi.absolutePath() );
1614  if ( fi.isSymLink() ) m_watcher->removeFile( fi.readLink() );
1615  }
1616  m_fileWasRemoved = false;
1617  if ( m_generatorGuiClient )
1618  factory()->removeClient( m_generatorGuiClient );
1619  m_generatorGuiClient = 0;
1620  m_document->closeDocument();
1621  updateViewActions();
1622  delete m_tempfile;
1623  m_tempfile = 0;
1624  if ( widget() )
1625  {
1626  m_searchWidget->clearText();
1627  m_topMessage->setVisible( false );
1628  m_formsMessage->setVisible( false );
1629  }
1630 #ifdef OKULAR_KEEP_FILE_OPEN
1631  m_keeper->close();
1632 #endif
1633  bool r = KParts::ReadWritePart::closeUrl();
1634  setUrl(KUrl());
1635 
1636  return r;
1637 }
1638 
1639 bool Part::closeUrl()
1640 {
1641  return closeUrl( true );
1642 }
1643 
1644 void Part::guiActivateEvent(KParts::GUIActivateEvent *event)
1645 {
1646  updateViewActions();
1647 
1648  KParts::ReadWritePart::guiActivateEvent(event);
1649 }
1650 
1651 void Part::close()
1652 {
1653  if ( m_embedMode == NativeShellMode )
1654  {
1655  closeUrl();
1656  }
1657  else KMessageBox::information( widget(), i18n( "This link points to a close document action that does not work when using the embedded viewer." ), QString(), "warnNoCloseIfNotInOkular" );
1658 }
1659 
1660 
1661 void Part::cannotQuit()
1662 {
1663  KMessageBox::information( widget(), i18n( "This link points to a quit application action that does not work when using the embedded viewer." ), QString(), "warnNoQuitIfNotInOkular" );
1664 }
1665 
1666 
1667 void Part::slotShowLeftPanel()
1668 {
1669  bool showLeft = m_showLeftPanel->isChecked();
1670  Okular::Settings::setShowLeftPanel( showLeft );
1671  Okular::Settings::self()->writeConfig();
1672  // show/hide left panel
1673  m_sidebar->setSidebarVisibility( showLeft );
1674 }
1675 
1676 void Part::slotShowBottomBar()
1677 {
1678  const bool showBottom = m_showBottomBar->isChecked();
1679  Okular::Settings::setShowBottomBar( showBottom );
1680  Okular::Settings::self()->writeConfig();
1681  // show/hide bottom bar
1682  m_bottomBar->setVisible( showBottom );
1683 }
1684 
1685 void Part::slotFileDirty( const QString& path )
1686 {
1687  // The beauty of this is that each start cancels the previous one.
1688  // This means that timeout() is only fired when there have
1689  // no changes to the file for the last 750 milisecs.
1690  // This ensures that we don't update on every other byte that gets
1691  // written to the file.
1692  if ( path == localFilePath() )
1693  {
1694  // Only start watching the file in case if it wasn't removed
1695  if (QFile::exists(localFilePath()))
1696  m_dirtyHandler->start( 750 );
1697  else
1698  m_fileWasRemoved = true;
1699  }
1700  else
1701  {
1702  const QFileInfo fi(localFilePath());
1703  if ( fi.absolutePath() == path )
1704  {
1705  // Our parent has been dirtified
1706  if (!QFile::exists(localFilePath()))
1707  {
1708  m_fileWasRemoved = true;
1709  }
1710  else if (m_fileWasRemoved && QFile::exists(localFilePath()))
1711  {
1712  // we need to watch the new file
1713  m_watcher->removeFile(localFilePath());
1714  m_watcher->addFile(localFilePath());
1715  m_dirtyHandler->start( 750 );
1716  }
1717  }
1718  else if ( fi.isSymLink() && fi.readLink() == path )
1719  {
1720  if ( QFile::exists( fi.readLink() ))
1721  m_dirtyHandler->start( 750 );
1722  else
1723  m_fileWasRemoved = true;
1724  }
1725  }
1726 }
1727 
1728 
1729 void Part::slotDoFileDirty()
1730 {
1731  bool tocReloadPrepared = false;
1732 
1733  // do the following the first time the file is reloaded
1734  if ( m_viewportDirty.pageNumber == -1 )
1735  {
1736  // store the url of the current document
1737  m_oldUrl = url();
1738 
1739  // store the current viewport
1740  m_viewportDirty = m_document->viewport();
1741 
1742  // store the current toolbox pane
1743  m_dirtyToolboxIndex = m_sidebar->currentIndex();
1744  m_wasSidebarVisible = m_sidebar->isSidebarVisible();
1745  m_wasSidebarCollapsed = m_sidebar->isCollapsed();
1746 
1747  // store if presentation view was open
1748  m_wasPresentationOpen = ((PresentationWidget*)m_presentationWidget != 0);
1749 
1750  // preserves the toc state after reload
1751  m_toc->prepareForReload();
1752  tocReloadPrepared = true;
1753 
1754  // store the page rotation
1755  m_dirtyPageRotation = m_document->rotation();
1756 
1757  // inform the user about the operation in progress
1758  // TODO: Remove this line and integrate reload info in queryClose
1759  m_pageView->displayMessage( i18n("Reloading the document...") );
1760  }
1761 
1762  // close and (try to) reopen the document
1763  if ( !closeUrl() )
1764  {
1765  m_viewportDirty.pageNumber = -1;
1766 
1767  if ( tocReloadPrepared )
1768  {
1769  m_toc->rollbackReload();
1770  }
1771  return;
1772  }
1773 
1774  if ( tocReloadPrepared )
1775  m_toc->finishReload();
1776 
1777  // inform the user about the operation in progress
1778  m_pageView->displayMessage( i18n("Reloading the document...") );
1779 
1780  if ( KParts::ReadWritePart::openUrl( m_oldUrl ) )
1781  {
1782  // on successful opening, restore the previous viewport
1783  if ( m_viewportDirty.pageNumber >= (int) m_document->pages() )
1784  m_viewportDirty.pageNumber = (int) m_document->pages() - 1;
1785  m_document->setViewport( m_viewportDirty );
1786  m_oldUrl = KUrl();
1787  m_viewportDirty.pageNumber = -1;
1788  m_document->setRotation( m_dirtyPageRotation );
1789  if ( m_sidebar->currentIndex() != m_dirtyToolboxIndex && m_sidebar->isItemEnabled( m_dirtyToolboxIndex )
1790  && !m_sidebar->isCollapsed() )
1791  {
1792  m_sidebar->setCurrentIndex( m_dirtyToolboxIndex );
1793  }
1794  if ( m_sidebar->isSidebarVisible() != m_wasSidebarVisible )
1795  {
1796  m_sidebar->setSidebarVisibility( m_wasSidebarVisible );
1797  }
1798  if ( m_sidebar->isCollapsed() != m_wasSidebarCollapsed )
1799  {
1800  m_sidebar->setCollapsed( m_wasSidebarCollapsed );
1801  }
1802  if (m_wasPresentationOpen) slotShowPresentation();
1803  emit enablePrintAction(true && m_document->printingSupport() != Okular::Document::NoPrinting);
1804  }
1805  else
1806  {
1807  // start watching the file again (since we dropped it on close)
1808  addFileToWatcher( m_watcher, localFilePath() );
1809  m_dirtyHandler->start( 750 );
1810  }
1811 }
1812 
1813 
1814 void Part::updateViewActions()
1815 {
1816  bool opened = m_document->pages() > 0;
1817  if ( opened )
1818  {
1819  m_gotoPage->setEnabled( m_document->pages() > 1 );
1820 
1821  // Check if you are at the beginning or not
1822  if (m_document->currentPage() != 0)
1823  {
1824  m_beginningOfDocument->setEnabled( true );
1825  m_prevPage->setEnabled( true );
1826  }
1827  else
1828  {
1829  if (m_pageView->verticalScrollBar()->value() != 0)
1830  {
1831  // The page isn't at the very beginning
1832  m_beginningOfDocument->setEnabled( true );
1833  }
1834  else
1835  {
1836  // The page is at the very beginning of the document
1837  m_beginningOfDocument->setEnabled( false );
1838  }
1839  // The document is at the first page, you can go to a page before
1840  m_prevPage->setEnabled( false );
1841  }
1842 
1843  if (m_document->pages() == m_document->currentPage() + 1 )
1844  {
1845  // If you are at the end, disable go to next page
1846  m_nextPage->setEnabled( false );
1847  if (m_pageView->verticalScrollBar()->value() == m_pageView->verticalScrollBar()->maximum())
1848  {
1849  // If you are the end of the page of the last document, you can't go to the last page
1850  m_endOfDocument->setEnabled( false );
1851  }
1852  else
1853  {
1854  // Otherwise you can move to the endif
1855  m_endOfDocument->setEnabled( true );
1856  }
1857  }
1858  else
1859  {
1860  // If you are not at the end, enable go to next page
1861  m_nextPage->setEnabled( true );
1862  m_endOfDocument->setEnabled( true );
1863  }
1864 
1865  if (m_historyBack) m_historyBack->setEnabled( !m_document->historyAtBegin() );
1866  if (m_historyNext) m_historyNext->setEnabled( !m_document->historyAtEnd() );
1867  m_reload->setEnabled( true );
1868  if (m_copy) m_copy->setEnabled( true );
1869  if (m_selectAll) m_selectAll->setEnabled( true );
1870  }
1871  else
1872  {
1873  m_gotoPage->setEnabled( false );
1874  m_beginningOfDocument->setEnabled( false );
1875  m_endOfDocument->setEnabled( false );
1876  m_prevPage->setEnabled( false );
1877  m_nextPage->setEnabled( false );
1878  if (m_historyBack) m_historyBack->setEnabled( false );
1879  if (m_historyNext) m_historyNext->setEnabled( false );
1880  m_reload->setEnabled( false );
1881  if (m_copy) m_copy->setEnabled( false );
1882  if (m_selectAll) m_selectAll->setEnabled( false );
1883  }
1884 
1885  if ( factory() )
1886  {
1887  QWidget *menu = factory()->container("menu_okular_part_viewer", this);
1888  if (menu) menu->setEnabled( opened );
1889 
1890  menu = factory()->container("view_orientation", this);
1891  if (menu) menu->setEnabled( opened );
1892  }
1893  emit viewerMenuStateChange( opened );
1894 
1895  updateBookmarksActions();
1896 }
1897 
1898 
1899 void Part::updateBookmarksActions()
1900 {
1901  bool opened = m_document->pages() > 0;
1902  if ( opened )
1903  {
1904  m_addBookmark->setEnabled( true );
1905  if ( m_document->bookmarkManager()->isBookmarked( m_document->viewport() ) )
1906  {
1907  m_addBookmark->setText( i18n( "Remove Bookmark" ) );
1908  m_addBookmark->setIcon( KIcon( "edit-delete-bookmark" ) );
1909  m_renameBookmark->setEnabled( true );
1910  }
1911  else
1912  {
1913  m_addBookmark->setText( m_addBookmarkText );
1914  m_addBookmark->setIcon( m_addBookmarkIcon );
1915  m_renameBookmark->setEnabled( false );
1916  }
1917  }
1918  else
1919  {
1920  m_addBookmark->setEnabled( false );
1921  m_addBookmark->setText( m_addBookmarkText );
1922  m_addBookmark->setIcon( m_addBookmarkIcon );
1923  m_renameBookmark->setEnabled( false );
1924  }
1925 }
1926 
1927 
1928 void Part::enableTOC(bool enable)
1929 {
1930  m_sidebar->setItemEnabled(0, enable);
1931 
1932  // If present, show the TOC when a document is opened
1933  if ( enable && m_sidebar->currentIndex() != 0 )
1934  {
1935  m_sidebar->setCurrentIndex( 0, Sidebar::DoNotUncollapseIfCollapsed );
1936  }
1937 }
1938 
1939 void Part::slotRebuildBookmarkMenu()
1940 {
1941  rebuildBookmarkMenu();
1942 }
1943 
1944 void Part::slotShowFindBar()
1945 {
1946  m_findBar->show();
1947  m_findBar->focusAndSetCursor();
1948  m_closeFindBar->setEnabled( true );
1949 }
1950 
1951 void Part::slotHideFindBar()
1952 {
1953  if ( m_findBar->maybeHide() )
1954  {
1955  m_pageView->setFocus();
1956  m_closeFindBar->setEnabled( false );
1957  }
1958 }
1959 
1960 //BEGIN go to page dialog
1961 class GotoPageDialog : public KDialog
1962 {
1963  public:
1964  GotoPageDialog(QWidget *p, int current, int max) : KDialog(p)
1965  {
1966  setCaption(i18n("Go to Page"));
1967  setButtons(Ok | Cancel);
1968  setDefaultButton(Ok);
1969 
1970  QWidget *w = new QWidget(this);
1971  setMainWidget(w);
1972 
1973  QVBoxLayout *topLayout = new QVBoxLayout(w);
1974  topLayout->setMargin(0);
1975  topLayout->setSpacing(spacingHint());
1976  e1 = new KIntNumInput(current, w);
1977  e1->setRange(1, max);
1978  e1->setEditFocus(true);
1979  e1->setSliderEnabled(true);
1980 
1981  QLabel *label = new QLabel(i18n("&Page:"), w);
1982  label->setBuddy(e1);
1983  topLayout->addWidget(label);
1984  topLayout->addWidget(e1);
1985  // A little bit extra space
1986  topLayout->addSpacing(spacingHint());
1987  topLayout->addStretch(10);
1988  e1->setFocus();
1989  }
1990 
1991  int getPage() const
1992  {
1993  return e1->value();
1994  }
1995 
1996  protected:
1997  KIntNumInput *e1;
1998 };
1999 //END go to page dialog
2000 
2001 void Part::slotGoToPage()
2002 {
2003  GotoPageDialog pageDialog( m_pageView, m_document->currentPage() + 1, m_document->pages() );
2004  if ( pageDialog.exec() == QDialog::Accepted )
2005  m_document->setViewportPage( pageDialog.getPage() - 1 );
2006 }
2007 
2008 
2009 void Part::slotPreviousPage()
2010 {
2011  if ( m_document->isOpened() && !(m_document->currentPage() < 1) )
2012  m_document->setViewportPage( m_document->currentPage() - 1 );
2013 }
2014 
2015 
2016 void Part::slotNextPage()
2017 {
2018  if ( m_document->isOpened() && m_document->currentPage() < (m_document->pages() - 1) )
2019  m_document->setViewportPage( m_document->currentPage() + 1 );
2020 }
2021 
2022 
2023 void Part::slotGotoFirst()
2024 {
2025  if ( m_document->isOpened() ) {
2026  m_document->setViewportPage( 0 );
2027  m_beginningOfDocument->setEnabled( false );
2028  }
2029 }
2030 
2031 
2032 void Part::slotGotoLast()
2033 {
2034  if ( m_document->isOpened() )
2035  {
2036  DocumentViewport endPage(m_document->pages() -1 );
2037  endPage.rePos.enabled = true;
2038  endPage.rePos.normalizedX = 0;
2039  endPage.rePos.normalizedY = 1;
2040  endPage.rePos.pos = Okular::DocumentViewport::TopLeft;
2041  m_document->setViewport(endPage);
2042  m_endOfDocument->setEnabled(false);
2043  }
2044 }
2045 
2046 
2047 void Part::slotHistoryBack()
2048 {
2049  m_document->setPrevViewport();
2050 }
2051 
2052 
2053 void Part::slotHistoryNext()
2054 {
2055  m_document->setNextViewport();
2056 }
2057 
2058 
2059 void Part::slotAddBookmark()
2060 {
2061  DocumentViewport vp = m_document->viewport();
2062  if ( m_document->bookmarkManager()->isBookmarked( vp ) )
2063  {
2064  m_document->bookmarkManager()->removeBookmark( vp );
2065  }
2066  else
2067  {
2068  m_document->bookmarkManager()->addBookmark( vp );
2069  }
2070 }
2071 
2072 void Part::slotRenameBookmark( const DocumentViewport &viewport )
2073 {
2074  Q_ASSERT(m_document->bookmarkManager()->isBookmarked( viewport ));
2075  if ( m_document->bookmarkManager()->isBookmarked( viewport ) )
2076  {
2077  KBookmark bookmark = m_document->bookmarkManager()->bookmark( viewport );
2078  const QString newName = KInputDialog::getText( i18n( "Rename Bookmark" ), i18n( "Enter the new name of the bookmark:" ), bookmark.fullText(), 0, widget());
2079  if (!newName.isEmpty())
2080  {
2081  m_document->bookmarkManager()->renameBookmark(&bookmark, newName);
2082  }
2083  }
2084 }
2085 
2086 void Part::slotRenameBookmarkFromMenu()
2087 {
2088  QAction *action = dynamic_cast<QAction *>(sender());
2089  Q_ASSERT( action );
2090  if ( action )
2091  {
2092  DocumentViewport vp( action->data().toString() );
2093  slotRenameBookmark( vp );
2094  }
2095 }
2096 
2097 void Part::slotRenameCurrentViewportBookmark()
2098 {
2099  slotRenameBookmark( m_document->viewport() );
2100 }
2101 
2102 void Part::slotAboutToShowContextMenu(KMenu * /*menu*/, QAction *action, QMenu *contextMenu)
2103 {
2104  const QList<QAction*> actions = contextMenu->findChildren<QAction*>("OkularPrivateRenameBookmarkActions");
2105  foreach(QAction *a, actions)
2106  {
2107  contextMenu->removeAction(a);
2108  delete a;
2109  }
2110 
2111  KBookmarkAction *ba = dynamic_cast<KBookmarkAction*>(action);
2112  if (ba != NULL)
2113  {
2114  QAction *separatorAction = contextMenu->addSeparator();
2115  separatorAction->setObjectName("OkularPrivateRenameBookmarkActions");
2116  QAction *renameAction = contextMenu->addAction( KIcon( "edit-rename" ), i18n( "Rename this Bookmark" ), this, SLOT(slotRenameBookmarkFromMenu()) );
2117  renameAction->setData(ba->property("htmlRef").toString());
2118  renameAction->setObjectName("OkularPrivateRenameBookmarkActions");
2119  }
2120 }
2121 
2122 void Part::slotPreviousBookmark()
2123 {
2124  const KBookmark bookmark = m_document->bookmarkManager()->previousBookmark( m_document->viewport() );
2125 
2126  if ( !bookmark.isNull() )
2127  {
2128  DocumentViewport vp( bookmark.url().htmlRef() );
2129  m_document->setViewport( vp );
2130  }
2131 }
2132 
2133 
2134 void Part::slotNextBookmark()
2135 {
2136  const KBookmark bookmark = m_document->bookmarkManager()->nextBookmark( m_document->viewport() );
2137 
2138  if ( !bookmark.isNull() )
2139  {
2140  DocumentViewport vp( bookmark.url().htmlRef() );
2141  m_document->setViewport( vp );
2142  }
2143 }
2144 
2145 
2146 void Part::slotFind()
2147 {
2148  // when in presentation mode, there's already a search bar, taking care of
2149  // the 'find' requests
2150  if ( (PresentationWidget*)m_presentationWidget != 0 )
2151  {
2152  m_presentationWidget->slotFind();
2153  }
2154  else
2155  {
2156  slotShowFindBar();
2157  }
2158 }
2159 
2160 
2161 void Part::slotFindNext()
2162 {
2163  if (m_findBar->isHidden())
2164  slotShowFindBar();
2165  else
2166  m_findBar->findNext();
2167 }
2168 
2169 
2170 void Part::slotFindPrev()
2171 {
2172  if (m_findBar->isHidden())
2173  slotShowFindBar();
2174  else
2175  m_findBar->findPrev();
2176 }
2177 
2178 bool Part::saveFile()
2179 {
2180  kDebug() << "Okular part doesn't support saving the file in the location from which it was opened";
2181  return false;
2182 }
2183 
2184 void Part::slotSaveFileAs()
2185 {
2186  if ( m_embedMode == PrintPreviewMode )
2187  return;
2188 
2189  /* Show a warning before saving if the generator can't save annotations,
2190  * unless we are going to save a .okular archive. */
2191  if ( !isDocumentArchive && !m_document->canSaveChanges( Document::SaveAnnotationsCapability ) )
2192  {
2193  /* Search local annotations */
2194  bool containsLocalAnnotations = false;
2195  const int pagecount = m_document->pages();
2196 
2197  for ( int pageno = 0; pageno < pagecount; ++pageno )
2198  {
2199  const Okular::Page *page = m_document->page( pageno );
2200  foreach ( const Okular::Annotation *ann, page->annotations() )
2201  {
2202  if ( !(ann->flags() & Okular::Annotation::External) )
2203  {
2204  containsLocalAnnotations = true;
2205  break;
2206  }
2207  }
2208  if ( containsLocalAnnotations )
2209  break;
2210  }
2211 
2212  /* Don't show it if there are no local annotations */
2213  if ( containsLocalAnnotations )
2214  {
2215  int res = KMessageBox::warningContinueCancel( widget(), i18n("Your annotations will not be exported.\nYou can export the annotated document using File -> Export As -> Document Archive") );
2216  if ( res != KMessageBox::Continue )
2217  return; // Canceled
2218  }
2219  }
2220 
2221  KUrl saveUrl = KFileDialog::getSaveUrl( url(),
2222  QString(), widget(), QString(),
2223  KFileDialog::ConfirmOverwrite );
2224  if ( !saveUrl.isValid() || saveUrl.isEmpty() )
2225  return;
2226 
2227  saveAs( saveUrl );
2228 }
2229 
2230 bool Part::saveAs( const KUrl & saveUrl )
2231 {
2232  KTemporaryFile tf;
2233  QString fileName;
2234  if ( !tf.open() )
2235  {
2236  KMessageBox::information( widget(), i18n("Could not open the temporary file for saving." ) );
2237  return false;
2238  }
2239  fileName = tf.fileName();
2240  tf.close();
2241 
2242  QString errorText;
2243  bool saved;
2244 
2245  if ( isDocumentArchive )
2246  saved = m_document->saveDocumentArchive( fileName );
2247  else
2248  saved = m_document->saveChanges( fileName, &errorText );
2249 
2250  if ( !saved )
2251  {
2252  if (errorText.isEmpty())
2253  {
2254  KMessageBox::information( widget(), i18n("File could not be saved in '%1'. Try to save it to another location.", fileName ) );
2255  }
2256  else
2257  {
2258  KMessageBox::information( widget(), i18n("File could not be saved in '%1'. %2", fileName, errorText ) );
2259  }
2260  return false;
2261  }
2262 
2263  KIO::Job *copyJob = KIO::file_copy( fileName, saveUrl, -1, KIO::Overwrite );
2264  if ( !KIO::NetAccess::synchronousRun( copyJob, widget() ) )
2265  {
2266  KMessageBox::information( widget(), i18n("File could not be saved in '%1'. Try to save it to another location.", saveUrl.prettyUrl() ) );
2267  return false;
2268  }
2269 
2270  setModified( false );
2271  return true;
2272 }
2273 
2274 
2275 void Part::slotSaveCopyAs()
2276 {
2277  if ( m_embedMode == PrintPreviewMode )
2278  return;
2279 
2280  KUrl saveUrl = KFileDialog::getSaveUrl( KUrl("kfiledialog:///okular/" + url().fileName()),
2281  QString(), widget(), QString(),
2282  KFileDialog::ConfirmOverwrite );
2283  if ( saveUrl.isValid() && !saveUrl.isEmpty() )
2284  {
2285  // make use of the already downloaded (in case of remote URLs) file,
2286  // no point in downloading that again
2287  KUrl srcUrl = KUrl::fromPath( localFilePath() );
2288  KTemporaryFile * tempFile = 0;
2289  // duh, our local file disappeared...
2290  if ( !QFile::exists( localFilePath() ) )
2291  {
2292  if ( url().isLocalFile() )
2293  {
2294 #ifdef OKULAR_KEEP_FILE_OPEN
2295  // local file: try to get it back from the open handle on it
2296  if ( ( tempFile = m_keeper->copyToTemporary() ) )
2297  srcUrl = KUrl::fromPath( tempFile->fileName() );
2298 #else
2299  const QString msg = i18n( "Okular cannot copy %1 to the specified location.\n\nThe document does not exist anymore.", localFilePath() );
2300  KMessageBox::sorry( widget(), msg );
2301  return;
2302 #endif
2303  }
2304  else
2305  {
2306  // we still have the original remote URL of the document,
2307  // so copy the document from there
2308  srcUrl = url();
2309  }
2310  }
2311 
2312  KIO::Job *copyJob = KIO::file_copy( srcUrl, saveUrl, -1, KIO::Overwrite );
2313  if ( !KIO::NetAccess::synchronousRun( copyJob, widget() ) )
2314  KMessageBox::information( widget(), i18n("File could not be saved in '%1'. Try to save it to another location.", saveUrl.prettyUrl() ) );
2315 
2316  delete tempFile;
2317  }
2318 }
2319 
2320 
2321 void Part::slotGetNewStuff()
2322 {
2323 #if 0
2324  KNS::Engine engine(widget());
2325  engine.init( "okular.knsrc" );
2326  // show the modal dialog over pageview and execute it
2327  KNS::Entry::List entries = engine.downloadDialogModal( m_pageView );
2328  Q_UNUSED( entries )
2329 #endif
2330 }
2331 
2332 
2333 void Part::slotPreferences()
2334 {
2335  // Create dialog
2336  PreferencesDialog * dialog = new PreferencesDialog( m_pageView, Okular::Settings::self(), m_embedMode );
2337  dialog->setAttribute( Qt::WA_DeleteOnClose );
2338 
2339  // Show it
2340  dialog->show();
2341 }
2342 
2343 
2344 void Part::slotAnnotationPreferences()
2345 {
2346  // Create dialog
2347  PreferencesDialog * dialog = new PreferencesDialog( m_pageView, Okular::Settings::self(), m_embedMode );
2348  dialog->setAttribute( Qt::WA_DeleteOnClose );
2349 
2350  // Show it
2351  dialog->switchToAnnotationsPage();
2352  dialog->show();
2353 }
2354 
2355 
2356 void Part::slotNewConfig()
2357 {
2358  // Apply settings here. A good policy is to check whether the setting has
2359  // changed before applying changes.
2360 
2361  // Watch File
2362  setWatchFileModeEnabled(Okular::Settings::watchFile());
2363 
2364  // Main View (pageView)
2365  m_pageView->reparseConfig();
2366 
2367  // update document settings
2368  m_document->reparseConfig();
2369 
2370  // update TOC settings
2371  if ( m_sidebar->isItemEnabled(0) )
2372  m_toc->reparseConfig();
2373 
2374  // update ThumbnailList contents
2375  if ( Okular::Settings::showLeftPanel() && !m_thumbnailList->isHidden() )
2376  m_thumbnailList->updateWidgets();
2377 
2378  // update Reviews settings
2379  if ( m_sidebar->isItemEnabled(2) )
2380  m_reviewsWidget->reparseConfig();
2381 
2382  setWindowTitleFromDocument ();
2383 }
2384 
2385 
2386 void Part::slotPrintPreview()
2387 {
2388  if (m_document->pages() == 0) return;
2389 
2390  QPrinter printer;
2391 
2392  // Native printing supports KPrintPreview, Postscript needs to use FilePrinterPreview
2393  if ( m_document->printingSupport() == Okular::Document::NativePrinting )
2394  {
2395  KPrintPreview previewdlg( &printer, widget() );
2396  setupPrint( printer );
2397  doPrint( printer );
2398  previewdlg.exec();
2399  }
2400  else
2401  {
2402  // Generate a temp filename for Print to File, then release the file so generator can write to it
2403  KTemporaryFile tf;
2404  tf.setAutoRemove( true );
2405  tf.setSuffix( ".ps" );
2406  tf.open();
2407  printer.setOutputFileName( tf.fileName() );
2408  tf.close();
2409  setupPrint( printer );
2410  doPrint( printer );
2411  if ( QFile::exists( printer.outputFileName() ) )
2412  {
2413  Okular::FilePrinterPreview previewdlg( printer.outputFileName(), widget() );
2414  previewdlg.exec();
2415  }
2416  }
2417 }
2418 
2419 
2420 void Part::slotShowMenu(const Okular::Page *page, const QPoint &point)
2421 {
2422  if ( m_embedMode == PrintPreviewMode )
2423  return;
2424 
2425  bool reallyShow = false;
2426  const bool currentPage = page && page->number() == m_document->viewport().pageNumber;
2427 
2428  if (!m_actionsSearched)
2429  {
2430  // the quest for options_show_menubar
2431  KActionCollection *ac;
2432  QAction *act;
2433 
2434  if (factory())
2435  {
2436  const QList<KXMLGUIClient*> clients(factory()->clients());
2437  for(int i = 0 ; (!m_showMenuBarAction || !m_showFullScreenAction) && i < clients.size(); ++i)
2438  {
2439  ac = clients.at(i)->actionCollection();
2440  // show_menubar
2441  act = ac->action("options_show_menubar");
2442  if (act && qobject_cast<KToggleAction*>(act))
2443  m_showMenuBarAction = qobject_cast<KToggleAction*>(act);
2444  // fullscreen
2445  act = ac->action("fullscreen");
2446  if (act && qobject_cast<KToggleFullScreenAction*>(act))
2447  m_showFullScreenAction = qobject_cast<KToggleFullScreenAction*>(act);
2448  }
2449  }
2450  m_actionsSearched = true;
2451  }
2452 
2453  KMenu *popup = new KMenu( widget() );
2454  QAction *addBookmark = 0;
2455  QAction *removeBookmark = 0;
2456  QAction *fitPageWidth = 0;
2457  if (page)
2458  {
2459  popup->addTitle( i18n( "Page %1", page->number() + 1 ) );
2460  if ( ( !currentPage && m_document->bookmarkManager()->isBookmarked( page->number() ) ) ||
2461  ( currentPage && m_document->bookmarkManager()->isBookmarked( m_document->viewport() ) ) )
2462  removeBookmark = popup->addAction( KIcon("edit-delete-bookmark"), i18n("Remove Bookmark") );
2463  else
2464  addBookmark = popup->addAction( KIcon("bookmark-new"), i18n("Add Bookmark") );
2465  if ( m_pageView->canFitPageWidth() )
2466  fitPageWidth = popup->addAction( KIcon("zoom-fit-best"), i18n("Fit Width") );
2467  popup->addAction( m_prevBookmark );
2468  popup->addAction( m_nextBookmark );
2469  reallyShow = true;
2470  }
2471  /*
2472  //Albert says: I have not ported this as i don't see it does anything
2473  if ( d->mouseOnRect ) // and rect->objectType() == ObjectRect::Image ...
2474  {
2475  m_popup->insertItem( SmallIcon("document-save"), i18n("Save Image..."), 4 );
2476  m_popup->setItemEnabled( 4, false );
2477  }*/
2478 
2479  if ((m_showMenuBarAction && !m_showMenuBarAction->isChecked()) || (m_showFullScreenAction && m_showFullScreenAction->isChecked()))
2480  {
2481  popup->addTitle( i18n( "Tools" ) );
2482  if (m_showMenuBarAction && !m_showMenuBarAction->isChecked()) popup->addAction(m_showMenuBarAction);
2483  if (m_showFullScreenAction && m_showFullScreenAction->isChecked()) popup->addAction(m_showFullScreenAction);
2484  reallyShow = true;
2485 
2486  }
2487 
2488  if (reallyShow)
2489  {
2490  QAction *res = popup->exec(point);
2491  if (res)
2492  {
2493  if (res == addBookmark)
2494  {
2495  if (currentPage)
2496  m_document->bookmarkManager()->addBookmark( m_document->viewport() );
2497  else
2498  m_document->bookmarkManager()->addBookmark( page->number() );
2499  }
2500  else if (res == removeBookmark)
2501  {
2502  if (currentPage)
2503  m_document->bookmarkManager()->removeBookmark( m_document->viewport() );
2504  else
2505  m_document->bookmarkManager()->removeBookmark( page->number() );
2506  }
2507  else if (res == fitPageWidth)
2508  {
2509  m_pageView->fitPageWidth( page->number() );
2510  }
2511  }
2512  }
2513  delete popup;
2514 }
2515 
2516 
2517 void Part::slotShowProperties()
2518 {
2519  PropertiesDialog *d = new PropertiesDialog(widget(), m_document);
2520  d->exec();
2521  delete d;
2522 }
2523 
2524 
2525 void Part::slotShowEmbeddedFiles()
2526 {
2527  EmbeddedFilesDialog *d = new EmbeddedFilesDialog(widget(), m_document);
2528  d->exec();
2529  delete d;
2530 }
2531 
2532 
2533 void Part::slotShowPresentation()
2534 {
2535  if ( !m_presentationWidget )
2536  {
2537  m_presentationWidget = new PresentationWidget( widget(), m_document, actionCollection() );
2538  }
2539 }
2540 
2541 
2542 void Part::slotHidePresentation()
2543 {
2544  if ( m_presentationWidget )
2545  delete (PresentationWidget*) m_presentationWidget;
2546 }
2547 
2548 
2549 void Part::slotTogglePresentation()
2550 {
2551  if ( m_document->isOpened() )
2552  {
2553  if ( !m_presentationWidget )
2554  m_presentationWidget = new PresentationWidget( widget(), m_document, actionCollection() );
2555  else delete (PresentationWidget*) m_presentationWidget;
2556  }
2557 }
2558 
2559 
2560 void Part::reload()
2561 {
2562  if ( m_document->isOpened() )
2563  {
2564  slotReload();
2565  }
2566 }
2567 
2568 void Part::enableStartWithPrint()
2569 {
2570  m_cliPrint = true;
2571 }
2572 
2573 void Part::slotAboutBackend()
2574 {
2575  const KComponentData *data = m_document->componentData();
2576  if ( !data )
2577  return;
2578 
2579  KAboutData aboutData( *data->aboutData() );
2580 
2581  if ( aboutData.programIconName().isEmpty() || aboutData.programIconName() == aboutData.appName() )
2582  {
2583  if ( const Okular::DocumentInfo *documentInfo = m_document->documentInfo() )
2584  {
2585  const QString mimeTypeName = documentInfo->get("mimeType");
2586  if ( !mimeTypeName.isEmpty() )
2587  {
2588  if ( KMimeType::Ptr type = KMimeType::mimeType( mimeTypeName ) )
2589  aboutData.setProgramIconName( type->iconName() );
2590  }
2591  }
2592  }
2593 
2594  KAboutApplicationDialog dlg( &aboutData, widget() );
2595  dlg.exec();
2596 }
2597 
2598 
2599 void Part::slotExportAs(QAction * act)
2600 {
2601  QList<QAction*> acts = m_exportAs->menu() ? m_exportAs->menu()->actions() : QList<QAction*>();
2602  int id = acts.indexOf( act );
2603  if ( ( id < 0 ) || ( id >= acts.count() ) )
2604  return;
2605 
2606  QString filter;
2607  switch ( id )
2608  {
2609  case 0:
2610  filter = "text/plain";
2611  break;
2612  case 1:
2613  filter = "application/vnd.kde.okular-archive";
2614  break;
2615  default:
2616  filter = m_exportFormats.at( id - 2 ).mimeType()->name();
2617  break;
2618  }
2619  QString fileName = KFileDialog::getSaveFileName( url().isLocalFile() ? url().directory() : QString(),
2620  filter, widget(), QString(),
2621  KFileDialog::ConfirmOverwrite );
2622  if ( !fileName.isEmpty() )
2623  {
2624  bool saved = false;
2625  switch ( id )
2626  {
2627  case 0:
2628  saved = m_document->exportToText( fileName );
2629  break;
2630  case 1:
2631  saved = m_document->saveDocumentArchive( fileName );
2632  break;
2633  default:
2634  saved = m_document->exportTo( fileName, m_exportFormats.at( id - 2 ) );
2635  break;
2636  }
2637  if ( !saved )
2638  KMessageBox::information( widget(), i18n("File could not be saved in '%1'. Try to save it to another location.", fileName ) );
2639  }
2640 }
2641 
2642 
2643 void Part::slotReload()
2644 {
2645  // stop the dirty handler timer, otherwise we may conflict with the
2646  // auto-refresh system
2647  m_dirtyHandler->stop();
2648 
2649  slotDoFileDirty();
2650 }
2651 
2652 
2653 void Part::slotPrint()
2654 {
2655  if (m_document->pages() == 0) return;
2656 
2657 #ifdef Q_WS_WIN
2658  QPrinter printer(QPrinter::HighResolution);
2659 #else
2660  QPrinter printer;
2661 #endif
2662  QPrintDialog *printDialog = 0;
2663  QWidget *printConfigWidget = 0;
2664 
2665  // Must do certain QPrinter setup before creating QPrintDialog
2666  setupPrint( printer );
2667 
2668  // Create the Print Dialog with extra config widgets if required
2669  if ( m_document->canConfigurePrinter() )
2670  {
2671  printConfigWidget = m_document->printConfigurationWidget();
2672  }
2673  if ( printConfigWidget )
2674  {
2675  printDialog = KdePrint::createPrintDialog( &printer, QList<QWidget*>() << printConfigWidget, widget() );
2676  }
2677  else
2678  {
2679  printDialog = KdePrint::createPrintDialog( &printer, widget() );
2680  }
2681 
2682  if ( printDialog )
2683  {
2684 
2685  // Set the available Print Range
2686  printDialog->setMinMax( 1, m_document->pages() );
2687  printDialog->setFromTo( 1, m_document->pages() );
2688 
2689  // If the user has bookmarked pages for printing, then enable Selection
2690  if ( !m_document->bookmarkedPageRange().isEmpty() )
2691  {
2692  printDialog->addEnabledOption( QAbstractPrintDialog::PrintSelection );
2693  }
2694 
2695  // If the Document type doesn't support print to both PS & PDF then disable the Print Dialog option
2696  if ( printDialog->isOptionEnabled( QAbstractPrintDialog::PrintToFile ) &&
2697  !m_document->supportsPrintToFile() )
2698  {
2699  printDialog->setEnabledOptions( printDialog->enabledOptions() ^ QAbstractPrintDialog::PrintToFile );
2700  }
2701 
2702 #if QT_VERSION >= KDE_MAKE_VERSION(4,7,0)
2703  // Enable the Current Page option in the dialog.
2704  if ( m_document->pages() > 1 && currentPage() > 0 )
2705  {
2706  printDialog->setOption( QAbstractPrintDialog::PrintCurrentPage );
2707  }
2708 #endif
2709 
2710  if ( printDialog->exec() )
2711  doPrint( printer );
2712  delete printDialog;
2713  }
2714 }
2715 
2716 
2717 void Part::setupPrint( QPrinter &printer )
2718 {
2719  printer.setOrientation(m_document->orientation());
2720 
2721  // title
2722  QString title = m_document->metaData( "DocumentTitle" ).toString();
2723  if ( title.isEmpty() )
2724  {
2725  title = m_document->currentDocument().fileName();
2726  }
2727  if ( !title.isEmpty() )
2728  {
2729  printer.setDocName( title );
2730  }
2731 }
2732 
2733 
2734 void Part::doPrint(QPrinter &printer)
2735 {
2736  if (!m_document->isAllowed(Okular::AllowPrint))
2737  {
2738  KMessageBox::error(widget(), i18n("Printing this document is not allowed."));
2739  return;
2740  }
2741 
2742  if (!m_document->print(printer))
2743  {
2744  const QString error = m_document->printError();
2745  if (error.isEmpty())
2746  {
2747  KMessageBox::error(widget(), i18n("Could not print the document. Unknown error. Please report to bugs.kde.org"));
2748  }
2749  else
2750  {
2751  KMessageBox::error(widget(), i18n("Could not print the document. Detailed error is \"%1\". Please report to bugs.kde.org", error));
2752  }
2753  }
2754 }
2755 
2756 
2757 void Part::restoreDocument(const KConfigGroup &group)
2758 {
2759  KUrl url ( group.readPathEntry( "URL", QString() ) );
2760  if ( url.isValid() )
2761  {
2762  QString viewport = group.readEntry( "Viewport" );
2763  if (!viewport.isEmpty()) m_document->setNextDocumentViewport( Okular::DocumentViewport( viewport ) );
2764  openUrl( url );
2765  }
2766 }
2767 
2768 
2769 void Part::saveDocumentRestoreInfo(KConfigGroup &group)
2770 {
2771  group.writePathEntry( "URL", url().url() );
2772  group.writeEntry( "Viewport", m_document->viewport().toString() );
2773 }
2774 
2775 
2776 void Part::psTransformEnded(int exit, QProcess::ExitStatus status)
2777 {
2778  Q_UNUSED( exit )
2779  if ( status != QProcess::NormalExit )
2780  return;
2781 
2782  QProcess *senderobj = sender() ? qobject_cast< QProcess * >( sender() ) : 0;
2783  if ( senderobj )
2784  {
2785  senderobj->close();
2786  senderobj->deleteLater();
2787  }
2788 
2789  setLocalFilePath( m_temporaryLocalFile );
2790  openUrl( m_temporaryLocalFile );
2791  m_temporaryLocalFile.clear();
2792 }
2793 
2794 
2795 void Part::displayInfoMessage( const QString &message, KMessageWidget::MessageType messageType, int duration )
2796 {
2797  if ( !Okular::Settings::showOSD() )
2798  {
2799  if (messageType == KMessageWidget::Error)
2800  {
2801  KMessageBox::error( widget(), message );
2802  }
2803  return;
2804  }
2805 
2806  // hide messageWindow if string is empty
2807  if ( message.isEmpty() )
2808  m_infoMessage->animatedHide();
2809 
2810  // display message (duration is length dependant)
2811  if ( duration < 0 )
2812  {
2813  duration = 500 + 100 * message.length();
2814  }
2815  m_infoTimer->start( duration );
2816  m_infoMessage->setText( message );
2817  m_infoMessage->setMessageType( messageType );
2818  m_infoMessage->setVisible( true );
2819 }
2820 
2821 
2822 void Part::errorMessage( const QString &message, int duration )
2823 {
2824  displayInfoMessage( message, KMessageWidget::Error, duration );
2825 }
2826 
2827 void Part::warningMessage( const QString &message, int duration )
2828 {
2829  displayInfoMessage( message, KMessageWidget::Warning, duration );
2830 }
2831 
2832 void Part::noticeMessage( const QString &message, int duration )
2833 {
2834  // less important message -> simpleer display widget in the PageView
2835  m_pageView->displayMessage( message, QString(), PageViewMessage::Info, duration );
2836 }
2837 
2838 
2839 void Part::unsetDummyMode()
2840 {
2841  if ( m_embedMode == PrintPreviewMode )
2842  return;
2843 
2844  m_sidebar->setItemEnabled( 2, true );
2845  m_sidebar->setItemEnabled( 3, true );
2846  m_sidebar->setSidebarVisibility( Okular::Settings::showLeftPanel() );
2847 
2848  // add back and next in history
2849  m_historyBack = KStandardAction::documentBack( this, SLOT(slotHistoryBack()), actionCollection() );
2850  m_historyBack->setWhatsThis( i18n( "Go to the place you were before" ) );
2851  connect(m_pageView, SIGNAL(mouseBackButtonClick()), m_historyBack, SLOT(trigger()));
2852 
2853  m_historyNext = KStandardAction::documentForward( this, SLOT(slotHistoryNext()), actionCollection());
2854  m_historyNext->setWhatsThis( i18n( "Go to the place you were after" ) );
2855  connect(m_pageView, SIGNAL(mouseForwardButtonClick()), m_historyNext, SLOT(trigger()));
2856 
2857  m_pageView->setupActions( actionCollection() );
2858 
2859  // attach the actions of the children widgets too
2860  m_formsMessage->addAction( m_pageView->toggleFormsAction() );
2861  m_formsMessage->setVisible( m_pageView->toggleFormsAction() != 0 );
2862 
2863  // ensure history actions are in the correct state
2864  updateViewActions();
2865 }
2866 
2867 
2868 bool Part::handleCompressed( QString &destpath, const QString &path, const QString &compressedMimetype )
2869 {
2870  m_tempfile = 0;
2871 
2872  // we are working with a compressed file, decompressing
2873  // temporary file for decompressing
2874  KTemporaryFile *newtempfile = new KTemporaryFile();
2875  newtempfile->setAutoRemove(true);
2876 
2877  if ( !newtempfile->open() )
2878  {
2879  KMessageBox::error( widget(),
2880  i18n("<qt><strong>File Error!</strong> Could not create temporary file "
2881  "<nobr><strong>%1</strong></nobr>.</qt>",
2882  strerror(newtempfile->error())));
2883  delete newtempfile;
2884  return false;
2885  }
2886 
2887  // decompression filer
2888  QIODevice* filterDev = KFilterDev::deviceForFile( path, compressedMimetype );
2889  if (!filterDev)
2890  {
2891  delete newtempfile;
2892  return false;
2893  }
2894 
2895  if ( !filterDev->open(QIODevice::ReadOnly) )
2896  {
2897  KMessageBox::detailedError( widget(),
2898  i18n("<qt><strong>File Error!</strong> Could not open the file "
2899  "<nobr><strong>%1</strong></nobr> for uncompression. "
2900  "The file will not be loaded.</qt>", path),
2901  i18n("<qt>This error typically occurs if you do "
2902  "not have enough permissions to read the file. "
2903  "You can check ownership and permissions if you "
2904  "right-click on the file in the Dolphin "
2905  "file manager and then choose the 'Properties' tab.</qt>"));
2906 
2907  delete filterDev;
2908  delete newtempfile;
2909  return false;
2910  }
2911 
2912  char buf[65536];
2913  int read = 0, wrtn = 0;
2914 
2915  while ((read = filterDev->read(buf, sizeof(buf))) > 0)
2916  {
2917  wrtn = newtempfile->write(buf, read);
2918  if ( read != wrtn )
2919  break;
2920  }
2921  delete filterDev;
2922  if ((read != 0) || (newtempfile->size() == 0))
2923  {
2924  KMessageBox::detailedError(widget(),
2925  i18n("<qt><strong>File Error!</strong> Could not uncompress "
2926  "the file <nobr><strong>%1</strong></nobr>. "
2927  "The file will not be loaded.</qt>", path ),
2928  i18n("<qt>This error typically occurs if the file is corrupt. "
2929  "If you want to be sure, try to decompress the file manually "
2930  "using command-line tools.</qt>"));
2931  delete newtempfile;
2932  return false;
2933  }
2934  m_tempfile = newtempfile;
2935  destpath = m_tempfile->fileName();
2936  return true;
2937 }
2938 
2939 void Part::rebuildBookmarkMenu( bool unplugActions )
2940 {
2941  if ( unplugActions )
2942  {
2943  unplugActionList( "bookmarks_currentdocument" );
2944  qDeleteAll( m_bookmarkActions );
2945  m_bookmarkActions.clear();
2946  }
2947  KUrl u = m_document->currentDocument();
2948  if ( u.isValid() )
2949  {
2950  m_bookmarkActions = m_document->bookmarkManager()->actionsForUrl( u );
2951  }
2952  bool havebookmarks = true;
2953  if ( m_bookmarkActions.isEmpty() )
2954  {
2955  havebookmarks = false;
2956  QAction * a = new KAction( 0 );
2957  a->setText( i18n( "No Bookmarks" ) );
2958  a->setEnabled( false );
2959  m_bookmarkActions.append( a );
2960  }
2961  plugActionList( "bookmarks_currentdocument", m_bookmarkActions );
2962 
2963  if (factory())
2964  {
2965  const QList<KXMLGUIClient*> clients(factory()->clients());
2966  bool containerFound = false;
2967  for (int i = 0; !containerFound && i < clients.size(); ++i)
2968  {
2969  QWidget *container = factory()->container("bookmarks", clients[i]);
2970  if (container && container->actions().contains(m_bookmarkActions.first()))
2971  {
2972  Q_ASSERT(dynamic_cast<KMenu*>(container));
2973  disconnect(container, 0, this, 0);
2974  connect(container, SIGNAL(aboutToShowContextMenu(KMenu*,QAction*,QMenu*)), this, SLOT(slotAboutToShowContextMenu(KMenu*,QAction*,QMenu*)));
2975  containerFound = true;
2976  }
2977  }
2978  }
2979 
2980  m_prevBookmark->setEnabled( havebookmarks );
2981  m_nextBookmark->setEnabled( havebookmarks );
2982 }
2983 
2984 void Part::updateAboutBackendAction()
2985 {
2986  const KComponentData *data = m_document->componentData();
2987  if ( data )
2988  {
2989  m_aboutBackend->setEnabled( true );
2990  }
2991  else
2992  {
2993  m_aboutBackend->setEnabled( false );
2994  }
2995 }
2996 
2997 void Part::resetStartArguments()
2998 {
2999  m_cliPrint = false;
3000 }
3001 
3002 void Part::setReadWrite(bool readwrite)
3003 {
3004  m_document->setAnnotationEditingEnabled( readwrite );
3005  ReadWritePart::setReadWrite( readwrite );
3006 }
3007 
3008 } // namespace Okular
3009 
3010 #include "part.moc"
3011 
3012 /* kate: replace-tabs on; indent-width 4; */
QIODevice
QSpacerItem
Okular::Part::slotShowBottomBar
void slotShowBottomBar()
Definition: part.cpp:1676
QAction::setText
void setText(const QString &text)
generator.h
Okular::DocumentViewport::pos
Position pos
Definition: document.h:1067
QList::clear
void clear()
Okular::BookmarkManager::removeBookmark
void removeBookmark(int page)
Remove a bookmark for the given page.
Definition: bookmarkmanager.cpp:459
Okular::Document::reparseConfig
void reparseConfig()
Reparses and applies the configuration.
Definition: document.cpp:2527
Okular::Document::exportFormats
QList< ExportFormat > exportFormats() const
Returns the list of supported export formats.
Definition: document.cpp:2770
QString::indexOf
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
QWidget
Okular::OkularLiveConnectExtension
Definition: extensions.h:36
detectConfigFileName
static QString detectConfigFileName(const QVariantList &args)
Definition: part.cpp:268
Okular::Part::queryClose
bool queryClose()
Definition: part.cpp:1544
Okular::Part::Part
Part(QWidget *parentWidget, QObject *parent, const QVariantList &args, KComponentData componentData)
If one element of 'args' contains one of the strings "Print/Preview" or "ViewerWidget", the part will be set up in the corresponding mode.
Definition: part.cpp:301
QAbstractPrintDialog::setFromTo
void setFromTo(int from, int to)
Okular::Part::slotPrintPreview
Q_SCRIPTABLE void slotPrintPreview()
Definition: part.cpp:2386
Okular::Document::NoPrinting
Printing Not Supported.
Definition: document.h:562
QMetaObject::normalizedSignature
QByteArray normalizedSignature(const char *method)
Okular::Part::slotPrint
void slotPrint()
Definition: part.cpp:2653
Okular::Part::slotFindPrev
void slotFindPrev()
Definition: part.cpp:2170
Okular::Part::loadCancelled
void loadCancelled(const QString &reason)
Definition: part.cpp:1041
Okular::PartFactory::~PartFactory
virtual ~PartFactory()
Definition: part.cpp:162
Okular::Document::setViewport
void setViewport(const DocumentViewport &viewport, DocumentObserver *excludeObserver=0, bool smoothMove=false)
Sets the current document viewport to the given viewport.
Definition: document.cpp:3176
Okular::Part::saveFile
bool saveFile()
Definition: part.cpp:2178
bookmarkmanager.h
Okular::BookmarkManager::bookmark
KBookmark bookmark(int page) const
Returns the bookmark for the given page of the document.
Definition: bookmarkmanager.cpp:292
QByteArray
QAbstractPrintDialog::setMinMax
void setMinMax(int min, int max)
Okular::Document::NativePrinting
Native Cross-Platform Printing.
Definition: document.h:563
Okular::EmbedMode
EmbedMode
Describes the possible embedding modes of the part.
Definition: part.h:79
QPrinter::setOutputFileName
void setOutputFileName(const QString &fileName)
QDomElement::attribute
QString attribute(const QString &name, const QString &defValue) const
QPrinter
Okular::BookmarkManager::nextBookmark
KBookmark nextBookmark(const DocumentViewport &viewport) const
Given a viewport, returns the next bookmark.
Definition: bookmarkmanager.cpp:701
QFile::remove
bool remove()
Okular::Part::handleDroppedUrls
void handleDroppedUrls(const KUrl::List &urls)
Definition: part.cpp:1008
Okular::Document::canConfigurePrinter
bool canConfigurePrinter() const
Returns whether the document can configure the printer itself.
Definition: document.cpp:2566
Okular::Document::bookmarkManager
BookmarkManager * bookmarkManager() const
Returns the bookmark manager of the document.
Definition: document.cpp:3511
Okular::Document::pages
uint pages() const
Returns the number of pages of the document.
Definition: document.cpp:2700
QAction::data
QVariant data() const
Okular::Part::goToPage
Q_SCRIPTABLE Q_NOREPLY void goToPage(uint page)
Definition: part.cpp:1131
Okular::ExportFormat::PlainText
Plain text.
Definition: generator.h:148
Okular::Document::supportsPrintToFile
bool supportsPrintToFile() const
Returns whether the document supports printing to both PDF and PS files.
Definition: document.cpp:3872
Okular::Part::slotGetNewStuff
void slotGetNewStuff()
Definition: part.cpp:2321
Okular::Part::documentMetaData
Q_SCRIPTABLE QString documentMetaData(const QString &metaData) const
Definition: part.cpp:1162
Okular::PartFactory::create
virtual QObject * create(const char *iface, QWidget *parentWidget, QObject *parent, const QVariantList &args, const QString &keyword)
Definition: part.cpp:166
QAction::setIcon
void setIcon(const QIcon &icon)
QList::at
const T & at(int i) const
Okular::Page::number
int number() const
Returns the number of the page in the document.
Definition: page.cpp:144
Okular::Document::exportToText
bool exportToText(const QString &fileName) const
Exports the document as ASCII text and saves it under fileName.
Definition: document.cpp:2758
QMenu::addAction
void addAction(QAction *action)
Okular::Part::slotGeneratorPreferences
KConfigDialog * slotGeneratorPreferences()
Definition: part.cpp:1076
Okular::Document::currentDocument
KUrl currentDocument() const
Returns the url of the currently opened document.
Definition: document.cpp:2705
Okular::Part::startPresentation
void startPresentation()
Start the presentation mode.
Definition: part.cpp:897
Okular::Part::updateBookmarksActions
void updateBookmarksActions()
Definition: part.cpp:1899
QDBusConnection::registerObject
bool registerObject(const QString &path, QObject *object, QFlags< QDBusConnection::RegisterOption > options)
Okular::KHTMLPartMode
Definition: part.h:84
QFileInfo::isSymLink
bool isSymLink() const
Okular::Part::displayInfoMessage
void displayInfoMessage(const QString &message, KMessageWidget::MessageType messageType=KMessageWidget::Information, int duration=-1)
Definition: part.cpp:2795
Okular::Document::print
bool print(QPrinter &printer)
Prints the document to the given printer.
Definition: document.cpp:3877
Okular::Part::areSourceLocationsShownGraphically
bool areSourceLocationsShownGraphically() const
Returns true iff source locations are shown graphically.
Definition: part.cpp:953
Okular::Part::clearLastShownSourceLocation
void clearLastShownSourceLocation()
Clear the source location that was set last in the viewer.
Definition: part.cpp:930
QObject::metaObject
virtual const QMetaObject * metaObject() const
Okular::Part::slotAboutToShowContextMenu
void slotAboutToShowContextMenu(KMenu *menu, QAction *action, QMenu *contextMenu)
Definition: part.cpp:2102
QHBoxLayout
QHash::constFind
const_iterator constFind(const Key &key) const
Okular::Part::slotDoFileDirty
void slotDoFileDirty()
Definition: part.cpp:1729
QDBusConnection::sessionBus
QDBusConnection sessionBus()
Okular::Document::supportedMimeTypes
QStringList supportedMimeTypes() const
Returns the list with the supported MIME types.
Definition: document.cpp:3970
QDomDocument::documentElement
QDomElement documentElement() const
Okular::Part::slotExportAs
void slotExportAs(QAction *)
Definition: part.cpp:2599
QPoint
QDomNode
Okular::PartFactory
Definition: part.h:356
Okular::Part::warningMessage
void warningMessage(const QString &message, int duration=-1)
Definition: part.cpp:2827
QStringList::join
QString join(const QString &separator) const
QPrintDialog::setOption
void setOption(PrintDialogOption option, bool on)
Okular::DocumentViewport::enabled
bool enabled
Definition: document.h:1064
Okular::DocumentObserver::Bookmark
Bookmarks has been changed.
Definition: observer.h:43
Okular::Part::noticeMessage
void noticeMessage(const QString &message, int duration=-1)
Definition: part.cpp:2832
QFile::exists
bool exists() const
QFrame::setFrameStyle
void setFrameStyle(int style)
QIODevice::open
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
QBoxLayout::addSpacing
void addSpacing(int size)
Okular::ViewerWidgetMode
Definition: part.h:85
Okular::Part::setWatchFileModeEnabled
void setWatchFileModeEnabled(bool enable)
Allows to enable or disable the watch file mode.
Definition: part.cpp:940
QFile::copy
bool copy(const QString &newName)
Okular::Document::SaveAnnotationsCapability
Can save annotation changes.
Definition: document.h:626
page.h
Okular::Part::slotAboutBackend
void slotAboutBackend()
Definition: part.cpp:2573
Okular::Part::slotRenameBookmarkFromMenu
void slotRenameBookmarkFromMenu()
Definition: part.cpp:2086
Okular::Part::cannotQuit
void cannotQuit()
Definition: part.cpp:1661
QList::size
int size() const
Okular::Document::setNextViewport
void setNextViewport()
Sets the current document viewport to the previous viewport in the viewport history.
Definition: document.cpp:3256
QString::isNull
bool isNull() const
Okular::Part::psTransformEnded
void psTransformEnded(int, QProcess::ExitStatus)
Definition: part.cpp:2776
Okular::Document::printError
QString printError() const
Returns the last print error in case print() failed.
Definition: document.cpp:3882
Okular::Document::isOpened
bool isOpened() const
Returns whether the document is currently opened.
Definition: document.cpp:2561
Okular::Document::OpenResult
OpenResult
Describes the result of an open document operation.
Definition: document.h:103
QList::indexOf
int indexOf(const T &value, int from) const
QAbstractPrintDialog::addEnabledOption
void addEnabledOption(PrintDialogOption option)
Okular::Document::rotation
Rotation rotation() const
Returns the current rotation of the document.
Definition: document.cpp:2799
QString::clear
void clear()
Okular::Document::removeObserver
void removeObserver(DocumentObserver *observer)
Unregisters the given observer for the document.
Definition: document.cpp:2497
QLabel::setBuddy
void setBuddy(QWidget *buddy)
QDomNode::toElement
QDomElement toElement() const
QObject::findChildren
QList< T > findChildren(const QString &name) const
Okular::Part::slotPreviousBookmark
void slotPreviousBookmark()
Definition: part.cpp:2122
Okular::Part::slotNewConfig
void slotNewConfig()
Definition: part.cpp:2356
Okular::PartFactory::PartFactory
PartFactory()
Definition: part.cpp:157
QPrinter::outputFileName
QString outputFileName() const
actionForExportFormat
static QAction * actionForExportFormat(const Okular::ExportFormat &format, QObject *parent=0)
Definition: part.cpp:177
Okular::Document::printConfigurationWidget
QWidget * printConfigurationWidget() const
Returns a custom printer configuration page or 0 if no custom printer configuration page is available...
Definition: document.cpp:3921
Okular::Part::~Part
~Part()
Definition: part.cpp:847
Okular::ExportFormat::standardFormat
static ExportFormat standardFormat(StandardExportFormat type)
Builds a standard format for the specified type .
Definition: generator.cpp:624
Okular::Document::page
const Page * page(int number) const
Returns the page object for the given page number or 0 if the number is out of range.
Definition: document.cpp:2667
Okular::Part::closeUrl
bool closeUrl()
Definition: part.cpp:1639
Okular::Part::slotRenameCurrentViewportBookmark
void slotRenameCurrentViewportBookmark()
Definition: part.cpp:2097
Okular::Part::mimeTypeChanged
void mimeTypeChanged(KMimeType::Ptr mimeType)
QWidget::setEnabled
void setEnabled(bool)
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
Okular::Part::saveDocumentRestoreInfo
void saveDocumentRestoreInfo(KConfigGroup &group)
Definition: part.cpp:2769
QList::count
int count(const T &value) const
Okular::Part::pages
Q_SCRIPTABLE uint pages()
Definition: part.cpp:1144
Okular::DocumentObserver::NeedSaveAs
Set along with Annotations when Save As is needed or annotation changes will be lost.
Definition: observer.h:48
Okular::Part::slotShowMenu
void slotShowMenu(const Okular::Page *page, const QPoint &point)
Definition: part.cpp:2420
QList::append
void append(const T &value)
Okular::Part::saveAs
bool saveAs(const KUrl &saveUrl)
Definition: part.cpp:2230
QHash::constEnd
const_iterator constEnd() const
QTimer
Okular::Part::enableCloseAction
void enableCloseAction(bool enable)
Okular::Part::slotReload
void slotReload()
Definition: part.cpp:2643
Okular::Part::openDocument
bool openDocument(const KUrl &url, uint page)
Open the document at the specified url at page page.
Definition: part.cpp:884
Okular::Document::isAllowed
bool isAllowed(Permission action) const
Returns whether the given action is allowed in the document.
Definition: document.cpp:2710
QHash
QPrintDialog
Okular::Part::guiActivateEvent
void guiActivateEvent(KParts::GUIActivateEvent *event)
Definition: part.cpp:1644
Okular::Part::setReadWrite
void setReadWrite(bool readwrite)
Definition: part.cpp:3002
Okular::Part::slotHidePresentation
void slotHidePresentation()
Definition: part.cpp:2542
Okular::Part::enablePrintAction
void enablePrintAction(bool enable)
Okular::Document::documentInfo
const DocumentInfo * documentInfo() const
Returns the meta data of the document or 0 if no meta data are available.
Definition: document.cpp:2577
Okular::Part::notifySetup
void notifySetup(const QVector< Okular::Page * > &pages, int setupFlags)
This method is called whenever the document is initialized or reconstructed.
Definition: part.cpp:1101
QProcess
QObject
action.h
annotations.h
Okular::Document::setRotation
void setRotation(int rotation)
This slot is called whenever the user changes the rotation of the document.
Definition: document.cpp:4449
QString::toInt
int toInt(bool *ok, int base) const
QList::isEmpty
bool isEmpty() const
QBoxLayout::addItem
virtual void addItem(QLayoutItem *item)
QObject::objectName
objectName
Okular::Annotation::External
Is stored external.
Definition: annotations.h:134
QString::isEmpty
bool isEmpty() const
Okular::Annotation::flags
int flags() const
Returns the flags of the annotation.
Definition: annotations.cpp:593
Okular::PrintPreviewMode
Definition: part.h:83
QString::trimmed
QString trimmed() const
Okular::Document::canSaveChanges
bool canSaveChanges(SaveCapability cap) const
Returns whether it's possible to save a given category of changes to another document.
Definition: document.cpp:4022
Okular::Document::bookmarkedPageRange
QString bookmarkedPageRange() const
Returns the range of the bookmarked.pages.
Definition: document.cpp:3532
Okular::GotoAction
The Goto action changes the viewport to another page or loads an external document.
Definition: action.h:115
Okular::Document::OpenError
Definition: document.h:106
Okular::Part::setWindowTitleFromDocument
void setWindowTitleFromDocument()
Definition: part.cpp:1058
Okular::Document::saveDocumentArchive
bool saveDocumentArchive(const QString &fileName)
Saves a document archive.
Definition: document.cpp:4196
aboutdata.h
extensions.h
Okular::Document::OpenNeedsPassword
Definition: document.h:107
Okular::Part
This is a "Part".
Definition: part.h:96
Okular::Part::slotFind
Q_SCRIPTABLE void slotFind()
Definition: part.cpp:2146
Okular::Part::slotShowProperties
void slotShowProperties()
Definition: part.cpp:2517
Okular::Document
The Document.
Definition: document.h:84
QVBoxLayout
QPrinter::setDocName
void setDocName(const QString &name)
Okular::Page
Collector for all the data belonging to a page.
Definition: page.h:49
QIODevice::read
qint64 read(char *data, qint64 maxSize)
Okular::Part::currentDocument
Q_SCRIPTABLE QString currentDocument()
Definition: part.cpp:1156
Okular::Document::closeDocument
void closeDocument()
Closes the document.
Definition: document.cpp:2347
document.h
Okular::Part::slotHideFindBar
void slotHideFindBar()
Definition: part.cpp:1951
QObject::deleteLater
void deleteLater()
QList::first
T & first()
QMenu::addSeparator
QAction * addSeparator()
Okular::Part::openUrl
bool openUrl(const KUrl &url)
Definition: part.cpp:1498
Okular::Part::slotGotoFirst
Q_SCRIPTABLE void slotGotoFirst()
Definition: part.cpp:2023
QString
QList
QFileInfo::readLink
QString readLink() const
QLayout::setMargin
void setMargin(int margin)
Okular::Part::close
void close()
Definition: part.cpp:1651
Okular::Part::slotShowLeftPanel
void slotShowLeftPanel()
Definition: part.cpp:1667
QAbstractPrintDialog::isOptionEnabled
bool isOptionEnabled(PrintDialogOption option) const
QStringList
Okular::Part::slotGoToPage
void slotGoToPage()
Definition: part.cpp:2001
Okular::DocumentViewport::pageNumber
int pageNumber
The number of the page nearest the center of the viewport.
Definition: document.h:1048
Okular::Document::componentData
const KComponentData * componentData() const
Returns the component data associated with the generator.
Definition: document.cpp:3991
QProcess::close
virtual void close()
Okular::DocumentViewport::rePos
struct Okular::DocumentViewport::@0 rePos
If 'rePos.enabled == true' then this structure contains the viewport center or top left depending on ...
Okular::Document::printingSupport
PrintingType printingSupport() const
Returns what sort of printing the document supports: Native, Postscript, None.
Definition: document.cpp:3850
Okular::Part::slotPreviousPage
Q_SCRIPTABLE void slotPreviousPage()
Definition: part.cpp:2009
QFileInfo
QAction::setData
void setData(const QVariant &userData)
Okular::Page::annotations
QLinkedList< Annotation * > annotations() const
Returns the list of annotations of the page.
Definition: page.cpp:482
QFileInfo::exists
bool exists() const
QMenu
Okular::Part::openUrlFromDocument
void openUrlFromDocument(const KUrl &url)
Definition: part.cpp:977
Okular::Part::currentPage
Q_SCRIPTABLE uint currentPage()
Definition: part.cpp:1150
QMetaObject::indexOfSlot
int indexOfSlot(const char *slot) const
Okular::Part::errorMessage
void errorMessage(const QString &message, int duration=0)
Definition: part.cpp:2822
QAction::setShortcut
void setShortcut(const QKeySequence &shortcut)
Okular::Document::viewport
const DocumentViewport & viewport() const
Returns the current viewport of the document.
Definition: document.cpp:2672
Okular::Part::slotAddBookmark
void slotAddBookmark()
Definition: part.cpp:2059
QFrame
QMetaObject::className
const char * className() const
QList::contains
bool contains(const T &value) const
QTimer::stop
void stop()
QMetaObject::invokeMethod
bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType type, QGenericReturnArgument ret, QGenericArgument val0, QGenericArgument val1, QGenericArgument val2, QGenericArgument val3, QGenericArgument val4, QGenericArgument val5, QGenericArgument val6, QGenericArgument val7, QGenericArgument val8, QGenericArgument val9)
Okular::DocumentInfo
A DOM tree containing information about the document.
Definition: document.h:1086
Okular::Part::slotShowEmbeddedFiles
void slotShowEmbeddedFiles()
Definition: part.cpp:2525
Okular::Document::metaData
QVariant metaData(const QString &key, const QVariant &option=QVariant()) const
Returns the meta data for the given key and option or an empty variant if the key doesn't exists...
Definition: document.cpp:2794
QDomNode::isNull
bool isNull() const
QPrinter::setOrientation
void setOrientation(Orientation orientation)
Okular::Document::setPrevViewport
void setPrevViewport()
Sets the current document viewport to the next viewport in the viewport history.
Definition: document.cpp:3239
QAbstractPrintDialog::setEnabledOptions
void setEnabledOptions(QFlags< QAbstractPrintDialog::PrintDialogOption > options)
QHash::const_iterator
Okular::DocumentObserver::DocumentChanged
The document is a new document.
Definition: observer.h:55
Okular::AllowPrint
Allows to print the document.
Definition: global.h:24
Okular::Document::openDocument
OpenResult openDocument(const QString &docFile, const KUrl &url, const KMimeType::Ptr &mime, const QString &password=QString())
Opens the document.
Definition: document.cpp:2128
QKeyEvent
Okular::DocumentViewport::normalizedX
double normalizedX
Definition: document.h:1065
Okular::BookmarkManager::isBookmarked
bool isBookmarked(int page) const
Returns whether the given page is bookmarked.
Definition: bookmarkmanager.cpp:689
Okular::Part::slotNextBookmark
void slotNextBookmark()
Definition: part.cpp:2134
Okular::Part::slotFindNext
void slotFindNext()
Definition: part.cpp:2161
Okular::addFileToWatcher
static void addFileToWatcher(KDirWatch *watcher, const QString &filePath)
Definition: part.cpp:1215
Okular::BookmarkManager::actionsForUrl
QList< QAction * > actionsForUrl(const KUrl &url) const
Returns a list of actions for the bookmarks of the specified url.
Definition: bookmarkmanager.cpp:587
Okular::Document::setNextDocumentViewport
void setNextDocumentViewport(const DocumentViewport &viewport)
Sets the next viewport in the viewport history.
Definition: document.cpp:3275
Okular::Part::openSourceReference
void openSourceReference(const QString &absFileName, int line, int column)
Okular::Document::setAnnotationEditingEnabled
void setAnnotationEditingEnabled(bool enable)
Control annotation editing (creation, modification and removal), which is enabled by default...
Definition: document.cpp:4304
Okular::Part::enableStartWithPrint
Q_SCRIPTABLE Q_NOREPLY void enableStartWithPrint()
Definition: part.cpp:2568
Okular::Part::slotFileDirty
void slotFileDirty(const QString &)
Definition: part.cpp:1685
detectEmbedMode
static Okular::EmbedMode detectEmbedMode(QWidget *parentWidget, QObject *parent, const QVariantList &args)
Definition: part.cpp:237
QDomNode::firstChild
QDomNode firstChild() const
Okular::Part::slotShowPresentation
void slotShowPresentation()
Definition: part.cpp:2533
QString::mid
QString mid(int position, int n) const
QPrintDialog::exec
virtual int exec()
QVector< Okular::Page * >
Okular::Document::guiClient
KXMLGUIClient * guiClient()
Returns the gui client of the generator, if it provides one.
Definition: document.cpp:2336
compressedMimeFor
static QString compressedMimeFor(const QString &mime_to_check)
Definition: part.cpp:187
Okular::Document::historyAtBegin
bool historyAtBegin() const
Returns whether the document history is at the begin.
Definition: document.cpp:2784
Okular::Document::configurableGenerators
int configurableGenerators() const
Returns the number of generators that have a configuration widget.
Definition: document.cpp:3963
Okular::Part::slotTogglePresentation
Q_SCRIPTABLE void slotTogglePresentation()
Definition: part.cpp:2549
Okular::DocumentViewport::normalizedY
double normalizedY
Definition: document.h:1066
QList::takeFirst
T takeFirst()
QLatin1String
QKeySequence
Okular::Document::exportTo
bool exportTo(const QString &fileName, const ExportFormat &format) const
Exports the document in the given format and saves it under fileName.
Definition: document.cpp:2779
QBoxLayout::addStretch
void addStretch(int stretch)
Okular::Part::openFile
bool openFile()
Definition: part.cpp:1330
QHash::isEmpty
bool isEmpty() const
Okular::Part::isWatchFileModeEnabled
bool isWatchFileModeEnabled() const
Returns true iff the watch file mode is enabled.
Definition: part.cpp:935
Okular::ExportFormat
Defines an entry for the export menu.
Definition: generator.h:76
Okular::Annotation
Annotation struct holds properties shared by all annotations.
Definition: annotations.h:90
Okular::Document::canExportToText
bool canExportToText() const
Returns whether the document supports the export to ASCII text.
Definition: document.cpp:2749
Okular::Part::urlsDropped
void urlsDropped(const KUrl::List &urls)
Okular::Part::openNewFilesInTabs
bool openNewFilesInTabs() const
Should the shell that supports tabs pen new files in tabs?
Definition: part.cpp:963
Okular::Part::restoreDocument
void restoreDocument(const KConfigGroup &group)
Definition: part.cpp:2757
Okular::Part::setShowSourceLocationsGraphically
void setShowSourceLocationsGraphically(bool show)
Allows to control whether source locations are shown graphically, or not.
Definition: part.cpp:958
QAction
Okular::Part::realUrl
KUrl realUrl() const
Definition: part.cpp:909
Okular::Part::enableTOC
void enableTOC(bool enable)
Definition: part.cpp:1928
QWidget::removeAction
void removeAction(QAction *action)
Okular::BookmarkManager::addBookmark
void addBookmark(int page)
Adds a bookmark for the given page.
Definition: bookmarkmanager.cpp:385
Okular::Part::slotPreferences
Q_SCRIPTABLE void slotPreferences()
Definition: part.cpp:2333
Okular::Document::historyAtEnd
bool historyAtEnd() const
Returns whether the document history is at the end.
Definition: document.cpp:2789
Okular::Part::showSourceLocation
void showSourceLocation(const QString &fileName, int line, int column, bool showGraphically=true)
Show the specified source location centrally in the viewer.
Definition: part.cpp:919
Okular::Part::slotNextPage
Q_SCRIPTABLE void slotNextPage()
Definition: part.cpp:2016
Okular::Part::slotHistoryNext
void slotHistoryNext()
Definition: part.cpp:2053
fileprinter.h
QString::length
int length() const
Okular::Document::setNextDocumentDestination
void setNextDocumentDestination(const QString &namedDestination)
Sets the next namedDestination in the viewport history.
Definition: document.cpp:3280
Okular::Part::openUrlFromBookmarks
void openUrlFromBookmarks(const KUrl &url)
Definition: part.cpp:992
QVariant::toBool
bool toBool() const
QApplication::isLeftToRight
bool isLeftToRight()
QString::left
QString left(int n) const
QIODevice::write
qint64 write(const char *data, qint64 maxSize)
QString::fromLatin1
QString fromLatin1(const char *str, int size)
Okular::Part::viewerMenuStateChange
void viewerMenuStateChange(bool enabled)
Okular::Document::saveChanges
bool saveChanges(const QString &fileName)
Save the document and the optional changes to it to the specified fileName.
Definition: document.cpp:4039
Okular::Part::slotHistoryBack
void slotHistoryBack()
Definition: part.cpp:2047
QTimer::start
void start(int msec)
Okular::Document::registerView
void registerView(View *view)
Register the specified view for the current document.
Definition: document.cpp:4060
QList::prepend
void prepend(const T &value)
Okular::Part::notifyPageChanged
void notifyPageChanged(int page, int flags)
This method is called whenever the content on page described by the passed flags has been changed...
Definition: part.cpp:1117
Okular::Part::supportedMimeTypes
QStringList supportedMimeTypes() const
Return a list with the supported mimetypes.
Definition: part.cpp:903
Okular::Part::notifyViewportChanged
void notifyViewportChanged(bool smoothMove)
This method is called whenever the viewport has been changed.
Definition: part.cpp:1112
Okular::DocumentViewport
A view on the document.
Definition: document.h:1016
QDomElement::tagName
QString tagName() const
Okular::Document::addObserver
void addObserver(DocumentObserver *observer)
Registers a new observer for the document.
Definition: document.cpp:2484
Okular::Part::slotRebuildBookmarkMenu
void slotRebuildBookmarkMenu()
Definition: part.cpp:1939
Okular::Document::fillConfigDialog
void fillConfigDialog(KConfigDialog *dialog)
Fill the KConfigDialog dialog with the setting pages of the generators.
Definition: document.cpp:3932
Okular::UnknownEmbedMode
Definition: part.h:81
Okular::Part::slotSaveCopyAs
void slotSaveCopyAs()
Definition: part.cpp:2275
Okular::DocumentViewport::toString
QString toString() const
Returns the viewport as xml description.
Definition: document.cpp:4583
Okular::Document::supportsSearching
bool supportsSearching() const
Returns whether the document supports searching.
Definition: document.cpp:2723
Okular::Part::slotSaveFileAs
void slotSaveFileAs()
Definition: part.cpp:2184
Okular::BookmarkManager::previousBookmark
KBookmark previousBookmark(const DocumentViewport &viewport) const
Given a viewport, returns the previous bookmark.
Definition: bookmarkmanager.cpp:720
Okular::Document::processAction
void processAction(const Action *action)
Processes the given action.
Definition: document.cpp:3578
Okular::BrowserExtension
Definition: extensions.h:21
Okular::DocumentViewport::TopLeft
Relative to the top left corner of the page.
Definition: document.h:1056
QVariant::type
Type type() const
okularAboutData
KAboutData okularAboutData(const char *name, const char *iname)
Definition: aboutdata.h:17
QFileInfo::absolutePath
QString absolutePath() const
Okular::Part::slotShowFindBar
void slotShowFindBar()
Definition: part.cpp:1944
Okular::Document::orientation
QPrinter::Orientation orientation() const
Returns the orientation of the document (for printing purposes).
Definition: document.cpp:4282
QWidget::actions
QList< QAction * > actions() const
Okular::BookmarkManager::renameBookmark
void renameBookmark(KBookmark *bm, const QString &newName)
Returns the bookmark given bookmark of the document.
Definition: bookmarkmanager.cpp:477
QLabel
Okular::Document::OpenSuccess
Definition: document.h:105
QDomElement
QAbstractPrintDialog::enabledOptions
PrintDialogOptions enabledOptions() const
QString::compare
int compare(const QString &other) const
QString::arg
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
Okular::Part::reload
Q_SCRIPTABLE Q_NOREPLY void reload()
Definition: part.cpp:2560
QVariant::toString
QString toString() const
KPluginFactory
Okular::Part::slotImportPSFile
bool slotImportPSFile()
Definition: part.cpp:1180
Okular::Document::embeddedFiles
const QList< EmbeddedFile * > * embeddedFiles() const
Returns the list of embedded files or 0 if no embedded files are available.
Definition: document.cpp:2662
Okular::NativeShellMode
Definition: part.h:82
Okular::Part::slotGotoLast
Q_SCRIPTABLE void slotGotoLast()
Definition: part.cpp:2032
QProcess::start
void start(const QString &program, const QStringList &arguments, QFlags< QIODevice::OpenModeFlag > mode)
QAction::setEnabled
void setEnabled(bool)
QBoxLayout::setSpacing
void setSpacing(int spacing)
Okular::DocumentViewport::isValid
bool isValid() const
Returns whether the viewport is valid.
Definition: document.cpp:4599
QFile::encodeName
QByteArray encodeName(const QString &fileName)
part.h
Okular::Part::slotJobStarted
void slotJobStarted(KIO::Job *job)
Definition: part.cpp:1022
Okular::Document::setViewportPage
void setViewportPage(int page, DocumentObserver *excludeObserver=0, bool smoothMove=false)
Sets the current document viewport to the given page.
Definition: document.cpp:3164
Okular::Document::walletDataForFile
void walletDataForFile(const QString &fileName, QString *walletName, QString *walletFolder, QString *walletKey) const
Returns which wallet data to use to read/write the password for the given fileName.
Definition: document.cpp:4310
Okular::Part::slotJobFinished
void slotJobFinished(KJob *job)
Definition: part.cpp:1033
Okular::Document::openDocumentArchive
OpenResult openDocumentArchive(const QString &docFile, const KUrl &url, const QString &password=QString())
Opens a document archive.
Definition: document.cpp:4104
QTimer::setSingleShot
void setSingleShot(bool singleShot)
QVariant
Okular::Part::updateViewActions
void updateViewActions()
Definition: part.cpp:1814
Okular::Document::currentPage
uint currentPage() const
Returns the number of the current page.
Definition: document.cpp:2695
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:19:25 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

okular

Skip menu "okular"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdegraphics API Reference

Skip menu "kdegraphics API Reference"
  •     libkdcraw
  •     libkexiv2
  •     libkipi
  •     libksane
  • okular

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal