27 #include <qapplication.h>
32 #include <QtGui/QPrinter>
33 #include <QtGui/QPrintDialog>
37 #include <kaboutapplicationdialog.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>
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>
59 #include <kfilterdev.h>
60 #include <kfilterbase.h>
62 #include <knewstuff2/engine.h>
64 #include <kdeprintdialog.h>
65 #include <kprintpreview.h>
66 #include <kbookmarkmenu.h>
71 #include "ui/pageview.h"
73 #include "ui/searchwidget.h"
74 #include "ui/thumbnaillist.h"
75 #include "ui/side_reviews.h"
76 #include "ui/minibar.h"
77 #include "ui/embeddedfilesdialog.h"
78 #include "ui/propertiesdialog.h"
79 #include "ui/presentationwidget.h"
80 #include "ui/pagesizelabel.h"
81 #include "ui/bookmarklist.h"
82 #include "ui/findbar.h"
83 #include "ui/sidebar.h"
84 #include "ui/fileprinterpreview.h"
85 #include "ui/guiutils.h"
86 #include "conf/preferencesdialog.h"
112 void open(
const QString & path )
115 m_handle = std::fopen( QFile::encodeName( path ),
"r" );
122 int ret = std::fclose( m_handle );
128 KTemporaryFile* copyToTemporary()
const
133 KTemporaryFile * retFile =
new KTemporaryFile;
136 std::rewind( m_handle );
140 c = std::fgetc( m_handle );
143 if ( !retFile->putChar( (
char)c ) )
145 }
while ( !feof( m_handle ) );
153 std::FILE * m_handle;
167 Q_UNUSED ( keyword );
170 object->setReadWrite( QLatin1String(iface) == QLatin1String(
"KParts::ReadWritePart") );
178 QAction *act =
new QAction( format.description(), parent );
179 if ( !format.icon().isNull() )
181 act->setIcon( format.icon() );
191 static QHash< QString, QString > compressedMimeMap;
192 static bool supportBzip =
false;
193 static bool supportXz =
false;
194 const QString app_gzip( QString::fromLatin1(
"application/x-gzip" ) );
195 const QString app_bzip( QString::fromLatin1(
"application/x-bzip" ) );
196 const QString app_xz( QString::fromLatin1(
"application/x-xz" ) );
197 if ( compressedMimeMap.isEmpty() )
199 std::auto_ptr< KFilterBase > f;
200 compressedMimeMap[ QString::fromLatin1(
"image/x-gzeps" ) ] = app_gzip;
202 f.reset( KFilterBase::findFilterByMimeType( app_bzip ) );
206 compressedMimeMap[ QString::fromLatin1(
"application/x-bzpdf" ) ] = app_bzip;
207 compressedMimeMap[ QString::fromLatin1(
"application/x-bzpostscript" ) ] = app_bzip;
208 compressedMimeMap[ QString::fromLatin1(
"application/x-bzdvi" ) ] = app_bzip;
209 compressedMimeMap[ QString::fromLatin1(
"image/x-bzeps" ) ] = app_bzip;
212 f.reset( KFilterBase::findFilterByMimeType( app_xz ) );
218 QHash< QString, QString >::const_iterator it = compressedMimeMap.constFind( mime_to_check );
219 if ( it != compressedMimeMap.constEnd() )
222 KMimeType::Ptr mime = KMimeType::mimeType( mime_to_check );
225 if ( mime->is( app_gzip ) )
227 else if ( supportBzip && mime->is( app_bzip ) )
229 else if ( supportXz && mime->is( app_xz ) )
238 Q_UNUSED( parentWidget );
241 && ( parent->objectName() == QLatin1String(
"okular::Shell" )
242 || parent->objectName() == QLatin1String(
"okular/okular__Shell" ) ) )
246 && ( QByteArray(
"KHTMLPart" ) == parent->metaObject()->className() ) )
249 Q_FOREACH (
const QVariant &arg, args )
251 if ( arg.type() == QVariant::String )
253 if ( arg.toString() == QLatin1String(
"Print/Preview" ) )
257 else if ( arg.toString() == QLatin1String(
"ViewerWidget" ) )
269 Q_FOREACH (
const QVariant &arg, args )
271 if ( arg.type() == QVariant::String )
273 QString argString = arg.toString();
274 int separatorIndex = argString.indexOf(
"=" );
275 if ( separatorIndex >= 0 && argString.left( separatorIndex ) == QLatin1String(
"ConfigFileName" ) )
277 return argString.mid( separatorIndex + 1 );
285 #undef OKULAR_KEEP_FILE_OPEN
287 #ifdef OKULAR_KEEP_FILE_OPEN
288 static bool keepFileOpen()
290 static bool keep_file_open = !qgetenv(
"OKULAR_NO_KEEP_FILE_OPEN").toInt();
291 return keep_file_open;
295 int Okular::Part::numberOfParts = 0;
302 const QVariantList &args,
303 KComponentData componentData )
304 : KParts::ReadWritePart(parent),
305 m_tempfile( 0 ), m_fileWasRemoved( false ), m_showMenuBarAction( 0 ), m_showFullScreenAction( 0 ), m_actionsSearched( false ),
306 m_cliPresentation(false), m_cliPrint(false), m_embedMode(
detectEmbedMode(parentWidget, parent, args)), m_generatorGuiClient(0), m_keeper( 0 )
310 if ( configFileName.isEmpty() )
312 configFileName = KStandardDirs::locateLocal(
"config",
"okularpartrc" );
314 if ( !QFile::exists( configFileName ) )
316 QString oldkpdfconffile = KStandardDirs::locateLocal(
"config",
"kpdfpartrc" );
317 if ( QFile::exists( oldkpdfconffile ) )
318 QFile::copy( oldkpdfconffile, configFileName );
321 Okular::Settings::instance( configFileName );
324 if (numberOfParts == 1) {
325 QDBusConnection::sessionBus().registerObject(
"/okular",
this, QDBusConnection::ExportScriptableSlots);
327 QDBusConnection::sessionBus().registerObject(QString(
"/okular%1").arg(numberOfParts),
this, QDBusConnection::ExportScriptableSlots);
332 connect(
this, SIGNAL(started(KIO::Job*)),
this, SLOT(
slotJobStarted(KIO::Job*)));
336 connect(
this, SIGNAL(canceled(QString)),
this, SLOT(
loadCancelled(QString)));
344 setComponentData( componentData );
346 GuiUtils::addIconLoader( iconLoader() );
348 m_sidebar =
new Sidebar( parentWidget );
349 setWidget( m_sidebar );
353 connect( m_document, SIGNAL(linkFind()),
this, SLOT(
slotFind()) );
354 connect( m_document, SIGNAL(linkGoToPage()),
this, SLOT(
slotGoToPage()) );
359 connect( m_document, SIGNAL(
close()),
this, SLOT(
close()) );
361 if ( parent && parent->metaObject()->indexOfSlot( QMetaObject::normalizedSignature(
"slotQuit()" ) ) != -1 )
362 connect( m_document, SIGNAL(quit()), parent, SLOT(slotQuit()) );
364 connect( m_document, SIGNAL(quit()),
this, SLOT(
cannotQuit()) );
375 m_toc =
new TOC( 0, m_document );
376 connect( m_toc, SIGNAL(hasTOC(
bool)),
this, SLOT(
enableTOC(
bool)) );
377 tbIndex = m_sidebar->addItem( m_toc, KIcon(QApplication::isLeftToRight() ?
"format-justify-left" :
"format-justify-right"), i18n(
"Contents") );
381 KVBox * thumbsBox =
new ThumbnailsBox( 0 );
382 thumbsBox->setSpacing( 6 );
383 m_searchWidget =
new SearchWidget( thumbsBox, m_document );
384 m_thumbnailList =
new ThumbnailList( thumbsBox, m_document );
388 tbIndex = m_sidebar->addItem( thumbsBox, KIcon(
"view-preview" ), i18n(
"Thumbnails") );
389 m_sidebar->setCurrentIndex( tbIndex );
392 m_reviewsWidget =
new Reviews( 0, m_document );
393 m_sidebar->addItem( m_reviewsWidget, KIcon(
"draw-freehand"), i18n(
"Reviews") );
394 m_sidebar->setItemEnabled( 2,
false );
397 m_bookmarkList =
new BookmarkList( m_document, 0 );
398 m_sidebar->addItem( m_bookmarkList, KIcon(
"bookmarks"), i18n(
"Bookmarks") );
399 m_sidebar->setItemEnabled( 3,
false );
402 #ifdef OKULAR_ENABLE_MINIBAR
404 m_sidebar->setBottomWidget( miniBarContainer );
405 QVBoxLayout * miniBarLayout =
new QVBoxLayout( miniBarContainer );
406 miniBarLayout->setMargin( 0 );
408 miniBarLayout->addItem(
new QSpacerItem( 6, 6, QSizePolicy::Fixed, QSizePolicy::Fixed ) );
410 QFrame * bevelContainer =
new QFrame( miniBarContainer );
411 bevelContainer->setFrameStyle( QFrame::StyledPanel | QFrame::Sunken );
412 QVBoxLayout * bevelContainerLayout =
new QVBoxLayout( bevelContainer );
413 bevelContainerLayout->setMargin( 4 );
414 m_progressWidget =
new ProgressWidget( bevelContainer, m_document );
415 bevelContainerLayout->addWidget( m_progressWidget );
416 miniBarLayout->addWidget( bevelContainer );
417 miniBarLayout->addItem(
new QSpacerItem( 6, 6, QSizePolicy::Fixed, QSizePolicy::Fixed ) );
422 m_sidebar->setMainWidget( rightContainer );
423 QVBoxLayout * rightLayout =
new QVBoxLayout( rightContainer );
424 rightLayout->setMargin( 0 );
425 rightLayout->setSpacing( 0 );
428 m_topMessage =
new PageViewTopMessage( rightContainer );
429 m_topMessage->setup( i18n(
"This document has embedded files. <a href=\"okular:/embeddedfiles\">Click here to see them</a> or go to File -> Embedded Files." ), KIcon(
"mail-attachment" ) );
431 rightLayout->addWidget( m_topMessage );
432 m_formsMessage =
new PageViewTopMessage( rightContainer );
433 rightLayout->addWidget( m_formsMessage );
434 m_pageView =
new PageView( rightContainer, m_document );
436 QMetaObject::invokeMethod( m_pageView,
"setFocus", Qt::QueuedConnection );
440 connect( m_document, SIGNAL(error(QString,
int)), m_pageView, SLOT(errorMessage(QString,
int)) );
441 connect( m_document, SIGNAL(warning(QString,
int)), m_pageView, SLOT(warningMessage(QString,
int)) );
442 connect( m_document, SIGNAL(notice(QString,
int)), m_pageView, SLOT(noticeMessage(QString,
int)) );
443 connect( m_document, SIGNAL(sourceReferenceActivated(
const QString&,
int,
int,
bool*)),
this, SLOT(slotHandleActivatedSourceReference(
const QString&,
int,
int,
bool*)) );
444 rightLayout->addWidget( m_pageView );
445 m_findBar =
new FindBar( m_document, rightContainer );
446 rightLayout->addWidget( m_findBar );
447 m_bottomBar =
new QWidget( rightContainer );
448 QHBoxLayout * bottomBarLayout =
new QHBoxLayout( m_bottomBar );
449 m_pageSizeLabel =
new PageSizeLabel( m_bottomBar, m_document );
450 bottomBarLayout->setMargin( 0 );
451 bottomBarLayout->setSpacing( 0 );
452 bottomBarLayout->addWidget( m_pageSizeLabel->antiWidget() );
453 bottomBarLayout->addItem(
new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
454 m_miniBarLogic =
new MiniBarLogic(
this, m_document );
455 m_miniBar =
new MiniBar( m_bottomBar, m_miniBarLogic );
456 bottomBarLayout->addWidget( m_miniBar );
457 bottomBarLayout->addItem(
new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
458 bottomBarLayout->addWidget( m_pageSizeLabel );
459 rightLayout->addWidget( m_bottomBar );
461 m_pageNumberTool =
new MiniBar( 0, m_miniBarLogic );
463 connect( m_findBar, SIGNAL(forwardKeyPressEvent(QKeyEvent*)), m_pageView, SLOT(externalKeyPressEvent(QKeyEvent*)));
464 connect( m_miniBar, SIGNAL(forwardKeyPressEvent(QKeyEvent*)), m_pageView, SLOT(externalKeyPressEvent(QKeyEvent*)));
465 connect( m_pageView, SIGNAL(escPressed()), m_findBar, SLOT(resetSearch()) );
466 connect( m_pageNumberTool, SIGNAL(forwardKeyPressEvent(QKeyEvent*)), m_pageView, SLOT(externalKeyPressEvent(QKeyEvent*)));
478 #ifdef OKULAR_ENABLE_MINIBAR
488 setupViewerActions();
496 setViewerShortcuts();
500 m_watcher =
new KDirWatch(
this );
501 connect( m_watcher, SIGNAL(dirty(QString)),
this, SLOT(
slotFileDirty(QString)) );
502 m_dirtyHandler =
new QTimer(
this );
503 m_dirtyHandler->setSingleShot(
true );
504 connect( m_dirtyHandler, SIGNAL(timeout()),
this, SLOT(
slotDoFileDirty()) );
509 connect( Okular::Settings::self(), SIGNAL(configChanged()),
this, SLOT(
slotNewConfig()) );
512 const KService::Ptr kttsd = KService::serviceByDesktopName(
"kttsd");
513 Okular::Settings::setUseKTTSD( kttsd );
514 Okular::Settings::self()->writeConfig();
516 rebuildBookmarkMenu(
false );
520 setXMLFile(
"part-viewermode.rc");
525 setXMLFile(
"part.rc");
528 m_pageView->setupBaseActions( actionCollection() );
530 m_sidebar->setSidebarVisibility(
false );
534 m_pageView->setupViewerActions( actionCollection() );
546 m_pageView->updateActionState(
false,
false,
false );
549 m_sidebar->setAutoFillBackground(
false );
551 #ifdef OKULAR_KEEP_FILE_OPEN
552 m_keeper =
new FileKeeper();
556 void Part::setupViewerActions()
559 KActionCollection * ac = actionCollection();
562 m_gotoPage = KStandardAction::gotoPage(
this, SLOT(
slotGoToPage()), ac );
563 m_gotoPage->setShortcut( QKeySequence(Qt::CTRL + Qt::Key_G) );
565 connect( m_miniBar, SIGNAL(gotoPage()), m_gotoPage, SLOT(trigger()) );
566 connect( m_pageNumberTool, SIGNAL(gotoPage()), m_gotoPage, SLOT(trigger()) );
569 m_prevPage->setIconText( i18nc(
"Previous page",
"Previous" ) );
570 m_prevPage->setToolTip( i18n(
"Go back to the Previous Page" ) );
571 m_prevPage->setWhatsThis( i18n(
"Moves to the previous page of the document" ) );
572 m_prevPage->setShortcut( 0 );
574 connect( m_miniBar, SIGNAL(prevPage()), m_prevPage, SLOT(trigger()) );
575 connect( m_pageNumberTool, SIGNAL(prevPage()), m_prevPage, SLOT(trigger()) );
576 #ifdef OKULAR_ENABLE_MINIBAR
577 connect( m_progressWidget, SIGNAL(prevPage()), m_prevPage, SLOT(trigger()) );
580 m_nextPage = KStandardAction::next(
this, SLOT(
slotNextPage()), ac );
581 m_nextPage->setIconText( i18nc(
"Next page",
"Next" ) );
582 m_nextPage->setToolTip( i18n(
"Advance to the Next Page" ) );
583 m_nextPage->setWhatsThis( i18n(
"Moves to the next page of the document" ) );
584 m_nextPage->setShortcut( 0 );
586 connect( m_miniBar, SIGNAL(nextPage()), m_nextPage, SLOT(trigger()) );
587 connect( m_pageNumberTool, SIGNAL(nextPage()), m_nextPage, SLOT(trigger()) );
588 #ifdef OKULAR_ENABLE_MINIBAR
589 connect( m_progressWidget, SIGNAL(nextPage()), m_nextPage, SLOT(trigger()) );
592 m_beginningOfDocument = KStandardAction::firstPage(
this, SLOT(
slotGotoFirst()), ac );
593 ac->addAction(
"first_page", m_beginningOfDocument);
594 m_beginningOfDocument->setText(i18n(
"Beginning of the document"));
595 m_beginningOfDocument->setWhatsThis( i18n(
"Moves to the beginning of the document" ) );
597 m_endOfDocument = KStandardAction::lastPage(
this, SLOT(
slotGotoLast()), ac );
598 ac->addAction(
"last_page",m_endOfDocument);
599 m_endOfDocument->setText(i18n(
"End of the document"));
600 m_endOfDocument->setWhatsThis( i18n(
"Moves to the end of the document" ) );
606 m_addBookmark = KStandardAction::addBookmark(
this, SLOT(
slotAddBookmark()), ac );
607 m_addBookmarkText = m_addBookmark->text();
608 m_addBookmarkIcon = m_addBookmark->icon();
610 m_renameBookmark = ac->addAction(
"rename_bookmark");
611 m_renameBookmark->setText(i18n(
"Rename Bookmark" ));
612 m_renameBookmark->setIcon(KIcon(
"edit-rename" ));
613 m_renameBookmark->setWhatsThis( i18n(
"Rename the current bookmark" ) );
616 m_prevBookmark = ac->addAction(
"previous_bookmark");
617 m_prevBookmark->setText(i18n(
"Previous Bookmark" ));
618 m_prevBookmark->setIcon(KIcon(
"go-up-search" ));
619 m_prevBookmark->setWhatsThis( i18n(
"Go to the previous bookmark" ) );
622 m_nextBookmark = ac->addAction(
"next_bookmark");
623 m_nextBookmark->setText(i18n(
"Next Bookmark" ));
624 m_nextBookmark->setIcon(KIcon(
"go-down-search" ));
625 m_nextBookmark->setWhatsThis( i18n(
"Go to the next bookmark" ) );
626 connect( m_nextBookmark, SIGNAL(triggered()),
this, SLOT(
slotNextBookmark()) );
634 QList<QKeySequence> s = m_find->shortcuts();
635 s.append( QKeySequence( Qt::Key_Slash ) );
636 m_find->setShortcuts( s );
637 m_find->setEnabled(
false );
639 m_findNext = KStandardAction::findNext(
this, SLOT(
slotFindNext()), ac);
640 m_findNext->setEnabled(
false );
642 m_findPrev = KStandardAction::findPrev(
this, SLOT(
slotFindPrev()), ac );
643 m_findPrev->setEnabled(
false );
648 QAction * prefs = KStandardAction::preferences(
this, SLOT(
slotPreferences()), ac);
651 prefs->setText( i18n(
"Configure Okular..." ) );
656 prefs->setText( i18n(
"Configure Viewer..." ) );
659 KAction * genPrefs =
new KAction( ac );
660 ac->addAction(
"options_configure_generators", genPrefs);
663 genPrefs->setText( i18n(
"Configure Viewer Backends..." ) );
667 genPrefs->setText( i18n(
"Configure Backends..." ) );
669 genPrefs->setIcon( KIcon(
"configure" ) );
673 m_printPreview = KStandardAction::printPreview(
this, SLOT(
slotPrintPreview()), ac );
674 m_printPreview->setEnabled(
false );
679 m_showProperties = ac->addAction(
"properties");
680 m_showProperties->setText(i18n(
"&Properties"));
681 m_showProperties->setIcon(KIcon(
"document-properties"));
683 m_showProperties->setEnabled(
false );
685 m_showEmbeddedFiles = 0;
686 m_showPresentation = 0;
691 m_exportAsDocArchive = 0;
693 m_aboutBackend = ac->addAction(
"help_about_backend");
694 m_aboutBackend->setText(i18n(
"About Backend"));
695 m_aboutBackend->setEnabled(
false );
696 connect(m_aboutBackend, SIGNAL(triggered()),
this, SLOT(
slotAboutBackend()));
698 KAction *
reload = ac->add<KAction>(
"file_reload" );
699 reload->setText( i18n(
"Reloa&d" ) );
700 reload->setIcon( KIcon(
"view-refresh" ) );
701 reload->setWhatsThis( i18n(
"Reload the current document from disk." ) );
702 connect( reload, SIGNAL(triggered()),
this, SLOT(
slotReload()) );
703 reload->setShortcut( KStandardShortcut::reload() );
706 m_closeFindBar =
new KAction( i18n(
"Close &Find Bar" ), ac );
707 ac->addAction(
"close_find_bar", m_closeFindBar);
708 connect(m_closeFindBar, SIGNAL(triggered()),
this, SLOT(
slotHideFindBar()));
709 widget()->addAction(m_closeFindBar);
711 KAction *pageno =
new KAction( i18n(
"Page Number" ), ac );
712 pageno->setDefaultWidget( m_pageNumberTool );
713 ac->addAction(
"page_number", pageno );
716 void Part::setViewerShortcuts()
718 KActionCollection * ac = actionCollection();
720 m_gotoPage->setShortcut( QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_G) );
721 m_find->setShortcuts( QList<QKeySequence>() );
723 m_findNext->setShortcut( QKeySequence() );
724 m_findPrev->setShortcut( QKeySequence() );
726 m_addBookmark->setShortcut( QKeySequence( Qt::CTRL + Qt::ALT + Qt::Key_B ) );
728 m_beginningOfDocument->setShortcut( QKeySequence( Qt::CTRL + Qt::ALT + Qt::Key_Home ) );
729 m_endOfDocument->setShortcut( QKeySequence( Qt::CTRL + Qt::ALT + Qt::Key_End ) );
731 KAction *action =
static_cast<KAction*
>( ac->action(
"file_reload" ) );
732 if( action ) action->setShortcuts( QList<QKeySequence>() << QKeySequence( Qt::ALT + Qt::Key_F5 ) );
735 void Part::setupActions()
737 KActionCollection * ac = actionCollection();
739 m_copy = KStandardAction::create( KStandardAction::Copy, m_pageView, SLOT(copyTextSelection()), ac );
741 m_selectAll = KStandardAction::selectAll( m_pageView, SLOT(selectAll()), ac );
743 m_saveCopyAs = KStandardAction::saveAs(
this, SLOT(
slotSaveCopyAs()), ac );
744 m_saveCopyAs->setText( i18n(
"Save &Copy As..." ) );
745 m_saveCopyAs->setShortcut( KShortcut() );
746 ac->addAction(
"file_save_copy", m_saveCopyAs );
747 m_saveCopyAs->setEnabled(
false );
749 m_saveAs = KStandardAction::saveAs(
this, SLOT(
slotSaveFileAs()), ac );
750 m_saveAs->setEnabled(
false );
752 m_showLeftPanel = ac->add<KToggleAction>(
"show_leftpanel");
753 m_showLeftPanel->setText(i18n(
"Show &Navigation Panel"));
754 m_showLeftPanel->setIcon(KIcon(
"view-sidetree" ));
755 connect( m_showLeftPanel, SIGNAL(toggled(
bool)),
this, SLOT(
slotShowLeftPanel()) );
756 m_showLeftPanel->setShortcut( Qt::Key_F7 );
757 m_showLeftPanel->setChecked( Okular::Settings::showLeftPanel() );
760 m_showBottomBar = ac->add<KToggleAction>(
"show_bottombar");
761 m_showBottomBar->setText(i18n(
"Show &Page Bar"));
762 connect( m_showBottomBar, SIGNAL(toggled(
bool)),
this, SLOT(
slotShowBottomBar()) );
763 m_showBottomBar->setChecked( Okular::Settings::showBottomBar() );
766 m_showEmbeddedFiles = ac->addAction(
"embedded_files");
767 m_showEmbeddedFiles->setText(i18n(
"&Embedded Files"));
768 m_showEmbeddedFiles->setIcon( KIcon(
"mail-attachment" ) );
770 m_showEmbeddedFiles->setEnabled(
false );
772 m_exportAs = ac->addAction(
"file_export_as");
773 m_exportAs->setText(i18n(
"E&xport As"));
774 m_exportAs->setIcon( KIcon(
"document-export" ) );
775 m_exportAsMenu =
new QMenu();
776 connect(m_exportAsMenu, SIGNAL(triggered(QAction*)),
this, SLOT(
slotExportAs(QAction*)));
777 m_exportAs->setMenu( m_exportAsMenu );
779 m_exportAsMenu->addAction( m_exportAsText );
780 m_exportAs->setEnabled(
false );
781 m_exportAsText->setEnabled(
false );
783 i18nc(
"A document format, Okular-specific",
"Document Archive" ),
784 KMimeType::mimeType(
"application/vnd.kde.okular-archive" ) ), m_exportAsMenu );
785 m_exportAsMenu->addAction( m_exportAsDocArchive );
786 m_exportAsDocArchive->setEnabled(
false );
788 m_showPresentation = ac->addAction(
"presentation");
789 m_showPresentation->setText(i18n(
"P&resentation"));
790 m_showPresentation->setIcon( KIcon(
"view-presentation" ) );
792 m_showPresentation->setShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_P ) );
793 m_showPresentation->setEnabled(
false );
795 QAction * importPS = ac->addAction(
"import_ps");
796 importPS->setText(i18n(
"&Import PostScript as PDF..."));
797 importPS->setIcon(KIcon(
"document-import"));
800 QAction * ghns = ac->addAction(
"get_new_stuff");
801 ghns->setText(i18n(
"&Get Books From Internet..."));
802 ghns->setIcon(KIcon(
"get-hot-new-stuff"));
805 ghns->setShortcut( Qt::Key_G );
808 KToggleAction *blackscreenAction =
new KToggleAction( i18n(
"Switch Blackscreen Mode" ), ac );
809 ac->addAction(
"switch_blackscreen_mode", blackscreenAction );
810 blackscreenAction->setShortcut( QKeySequence( Qt::Key_B ) );
811 blackscreenAction->setIcon( KIcon(
"view-presentation" ) );
812 blackscreenAction->setEnabled(
false );
814 KToggleAction *drawingAction =
new KToggleAction( i18n(
"Toggle Drawing Mode" ), ac );
815 ac->addAction(
"presentation_drawing_mode", drawingAction );
816 drawingAction->setIcon( KIcon(
"draw-freehand" ) );
817 drawingAction->setEnabled(
false );
819 KAction *eraseDrawingAction =
new KAction( i18n(
"Erase Drawings" ), ac );
820 ac->addAction(
"presentation_erase_drawings", eraseDrawingAction );
821 eraseDrawingAction->setIcon( KIcon(
"draw-eraser" ) );
822 eraseDrawingAction->setEnabled(
false );
824 KAction *configureAnnotations =
new KAction( i18n(
"Configure Annotations..." ), ac );
825 ac->addAction(
"options_configure_annotations", configureAnnotations );
826 configureAnnotations->setIcon( KIcon(
"configure" ) );
827 connect(configureAnnotations, SIGNAL(triggered()),
this, SLOT(slotAnnotationPreferences()));
832 GuiUtils::removeIconLoader( iconLoader() );
840 delete m_thumbnailList;
842 delete m_pageNumberTool;
843 delete m_miniBarLogic;
845 #ifdef OKULAR_ENABLE_MINIBAR
846 delete m_progressWidget;
848 delete m_pageSizeLabel;
849 delete m_reviewsWidget;
850 delete m_bookmarkList;
856 qDeleteAll( m_bookmarkActions );
858 delete m_exportAsMenu;
860 #ifdef OKULAR_KEEP_FILE_OPEN
881 m_cliPresentation =
true;
893 if ( !m_realUrl.isEmpty() )
903 const QString u = QString(
"src:%1 %2" ).arg( line + 1 ).arg( fileName );
906 if( showGraphically )
908 m_pageView->setLastSourceLocationViewport( m_document->
viewport() );
914 m_pageView->clearLastSourceLocationViewport();
919 return !m_watcher->isStopped();
924 if ( enabled && m_watcher->isStopped() )
926 m_watcher->startScan();
928 else if( !enabled && !m_watcher->isStopped() )
930 m_dirtyHandler->stop();
931 m_watcher->stopScan();
937 return m_pageView->areSourceLocationsShownGraphically();
942 m_pageView->setShowSourceLocationsGraphically(show);
945 void Part::slotHandleActivatedSourceReference(
const QString& absFileName,
int line,
int col,
bool *handled)
959 if (KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, widget()))
961 m_bExtension->openUrlNotify();
962 m_bExtension->setLocationBarUrl(url.prettyUrl());
965 KMessageBox::error( widget(), i18n(
"Could not open '%1'. File does not exist", url.pathOrUrl() ) );
975 url.setHTMLRef( QString() );
990 job->addMetaData(
"accept", supportedMimeTypes.join(
", ") +
", */*;q=0.5");
992 connect(job, SIGNAL(result(KJob*)),
this, SLOT(
slotJobFinished(KJob*)));
998 if ( job->error() == KIO::ERR_USER_CANCELED )
1000 m_pageView->noticeMessage( i18n(
"The loading of %1 has been canceled.",
realUrl().pathOrUrl() ) );
1006 emit setWindowCaption( QString() );
1007 resetStartArguments();
1014 if (!reason.isEmpty())
1016 KMessageBox::error( widget(), i18n(
"Could not open %1. Reason: %2", url().prettyUrl(), reason ) );
1025 QString title = Okular::Settings::displayDocumentNameOrPath() == Okular::Settings::EnumDisplayDocumentNameOrPath::Path ?
realUrl().pathOrUrl() :
realUrl().fileName();
1027 if ( Okular::Settings::displayDocumentTitle() )
1029 const QString docTitle = m_document->
metaData(
"DocumentTitle" ).toString();
1030 if ( !docTitle.isEmpty() && !docTitle.trimmed().isEmpty() )
1036 emit setWindowCaption( title );
1042 KConfigDialog * dialog =
new KConfigDialog( m_pageView,
"generator_prefs", Okular::Settings::self() );
1043 dialog->setAttribute( Qt::WA_DeleteOnClose );
1047 dialog->setCaption( i18n(
"Configure Viewer Backends" ) );
1051 dialog->setCaption( i18n(
"Configure Backends" ) );
1057 dialog->setWindowModality( Qt::ApplicationModal );
1069 rebuildBookmarkMenu();
1070 updateAboutBackendAction();
1071 m_findBar->resetSearch();
1088 rebuildBookmarkMenu();
1096 if ( i <= m_document->
pages() )
1109 return m_document->
pages();
1130 QDomElement docElement = info->documentElement();
1131 for ( QDomNode node = docElement.firstChild(); !node.isNull(); node = node.nextSibling() )
1133 const QDomElement element = node.toElement();
1134 if ( metaData.compare( element.tagName(), Qt::CaseInsensitive ) == 0 )
1135 return element.attribute(
"value" );
1145 QString app = KStandardDirs::findExe(
"ps2pdf" );
1146 if ( app.isEmpty() )
1149 KMessageBox::error( widget(), i18n(
"The program \"ps2pdf\" was not found, so Okular can not import PS files using it." ), i18n(
"ps2pdf not found") );
1153 KUrl url = KFileDialog::getOpenUrl( KUrl(),
"application/postscript", this->widget() );
1154 if ( url.isLocalFile() )
1157 tf.setSuffix(
".pdf" );
1158 tf.setAutoRemove(
false );
1161 m_temporaryLocalFile = tf.fileName();
1164 setLocalFilePath( url.toLocalFile() );
1166 QProcess *p =
new QProcess();
1167 args << url.toLocalFile() << m_temporaryLocalFile;
1168 m_pageView->displayMessage(i18n(
"Importing PS file as PDF (this may take a while)..."));
1169 connect(p, SIGNAL(finished(
int,QProcess::ExitStatus)),
this, SLOT(
psTransformEnded(
int,QProcess::ExitStatus)));
1170 p->start(app, args);
1174 m_temporaryLocalFile.clear();
1180 if ( !watcher->contains( filePath ) ) watcher->addFile(filePath);
1181 const QFileInfo fi(filePath);
1182 if ( !watcher->contains( fi.absolutePath() ) ) watcher->addDir(fi.absolutePath());
1183 if ( fi.isSymLink() ) watcher->addFile( fi.readLink() );
1188 KMimeType::Ptr mime;
1189 QString fileNameToOpen = localFilePath();
1190 const bool isstdin = url().isLocalFile() && url().fileName( KUrl::ObeyTrailingSlash ) == QLatin1String(
"-" );
1191 const QFileInfo fileInfo( fileNameToOpen );
1192 if ( !isstdin && !fileInfo.exists() )
1194 if ( !arguments().mimeType().isEmpty() )
1196 mime = KMimeType::mimeType( arguments().mimeType() );
1200 mime = KMimeType::findByPath( fileNameToOpen );
1202 bool isCompressedFile =
false;
1203 bool uncompressOk =
true;
1205 if ( compressedMime.isEmpty() )
1207 if ( !compressedMime.isEmpty() )
1209 isCompressedFile =
true;
1210 uncompressOk = handleCompressed( fileNameToOpen, localFilePath(), compressedMime );
1211 mime = KMimeType::findByPath( fileNameToOpen );
1214 isDocumentArchive =
false;
1217 if ( mime->is(
"application/vnd.kde.okular-archive" ) )
1220 isDocumentArchive =
true;
1224 ok = m_document->
openDocument( fileNameToOpen, url(), mime );
1231 m_find->setEnabled( ok && canSearch );
1232 m_findNext->setEnabled( ok && canSearch );
1233 m_findPrev->setEnabled( ok && canSearch );
1234 if( m_saveAs ) m_saveAs->setEnabled( ok && (m_document->
canSaveChanges() || isDocumentArchive) );
1235 if( m_saveCopyAs ) m_saveCopyAs->setEnabled( ok );
1238 m_showProperties->setEnabled( ok );
1240 if ( m_showEmbeddedFiles ) m_showEmbeddedFiles->setEnabled( hasEmbeddedFiles );
1241 m_topMessage->setVisible( hasEmbeddedFiles && Okular::Settings::showOSD() );
1244 if ( ok && m_document->
metaData(
"HasUnsupportedXfaForm" ).toBool() == true )
1246 m_formsMessage->setup( i18n(
"This document has XFA forms, which are currently <b>unsupported</b>." ), KIcon(
"dialog-warning" ) );
1247 m_formsMessage->setVisible(
true );
1250 else if ( ok && m_pageView->toggleFormsAction() && m_pageView->toggleFormsAction()->isEnabled() )
1252 m_formsMessage->setup( i18n(
"This document has forms. Click on the button to interact with them, or use View -> Show Forms." ) );
1253 m_formsMessage->setVisible(
true );
1257 m_formsMessage->setVisible(
false );
1260 if ( m_showPresentation ) m_showPresentation->setEnabled( ok );
1266 QList<Okular::ExportFormat>::ConstIterator it = m_exportFormats.constBegin();
1267 QList<Okular::ExportFormat>::ConstIterator itEnd = m_exportFormats.constEnd();
1268 QMenu *menu = m_exportAs->menu();
1269 for ( ; it != itEnd; ++it )
1274 if ( isCompressedFile )
1278 #ifdef OKULAR_KEEP_FILE_OPEN
1279 if ( keepFileOpen() )
1280 m_keeper->open( fileNameToOpen );
1283 if ( m_exportAsText ) m_exportAsText->setEnabled( ok && m_document->
canExportToText() );
1284 if ( m_exportAsDocArchive ) m_exportAsDocArchive->setEnabled( ok );
1285 if ( m_exportAs ) m_exportAs->setEnabled( ok );
1290 m_fileWasRemoved =
false;
1295 m_pageView->viewport()->update();
1296 m_thumbnailList->update();
1302 if ( url().isLocalFile() )
1308 if ( m_document->
metaData(
"OpenTOC" ).toBool() && m_sidebar->isItemEnabled( 0 ) && !m_sidebar->isCollapsed() )
1310 m_sidebar->setCurrentIndex( 0, Sidebar::DoNotUncollapseIfCollapsed );
1314 if ( m_document->
metaData(
"StartFullScreen" ).toBool() || m_cliPresentation )
1316 bool goAheadWithPresentationMode =
true;
1317 if ( !m_cliPresentation )
1319 const QString text = i18n(
"The document requested to be launched in presentation mode.\n"
1320 "Do you want to allow it?" );
1321 const QString caption = i18n(
"Presentation Mode" );
1322 const KGuiItem yesItem = KGuiItem( i18n(
"Allow" ),
"dialog-ok", i18n(
"Allow the presentation mode" ) );
1323 const KGuiItem noItem = KGuiItem( i18n(
"Do Not Allow" ),
"process-stop", i18n(
"Do not allow the presentation mode" ) );
1324 const int result = KMessageBox::questionYesNo( widget(), text, caption, yesItem, noItem );
1325 if ( result == KMessageBox::No )
1326 goAheadWithPresentationMode =
false;
1328 m_cliPresentation =
false;
1329 if ( goAheadWithPresentationMode )
1330 QMetaObject::invokeMethod(
this,
"slotShowPresentation", Qt::QueuedConnection );
1332 m_generatorGuiClient = factory() ? m_document->
guiClient() : 0;
1333 if ( m_generatorGuiClient )
1334 factory()->addClient( m_generatorGuiClient );
1350 if ( url.hasHTMLRef() )
1352 const QString dest = url.htmlRef();
1354 const int page = dest.toInt( &ok );
1368 url.setHTMLRef( QString() );
1372 bool openOk = KParts::ReadWritePart::openUrl( url );
1382 resetStartArguments();
1383 KMessageBox::error( widget(), i18n(
"Could not open %1", url.pathOrUrl() ) );
1391 if ( !isReadWrite() || !isModified() )
1394 const int res = KMessageBox::warningYesNoCancel( widget(),
1395 i18n(
"Do you want to save your annotation changes or discard them?" ),
1396 i18n(
"Close Document" ),
1397 KStandardGuiItem::saveAs(),
1398 KStandardGuiItem::discard() );
1402 case KMessageBox::Yes:
1404 return !isModified();
1405 case KMessageBox::No:
1417 setModified(
false );
1419 if (!m_temporaryLocalFile.isNull() && m_temporaryLocalFile != localFilePath())
1421 QFile::remove( m_temporaryLocalFile );
1422 m_temporaryLocalFile.clear();
1427 m_find->setEnabled(
false );
1428 m_findNext->setEnabled(
false );
1429 m_findPrev->setEnabled(
false );
1430 if( m_saveAs ) m_saveAs->setEnabled(
false );
1431 if( m_saveCopyAs ) m_saveCopyAs->setEnabled(
false );
1432 m_printPreview->setEnabled(
false );
1433 m_showProperties->setEnabled(
false );
1434 if ( m_showEmbeddedFiles ) m_showEmbeddedFiles->setEnabled(
false );
1435 if ( m_exportAs ) m_exportAs->setEnabled(
false );
1436 if ( m_exportAsText ) m_exportAsText->setEnabled(
false );
1437 if ( m_exportAsDocArchive ) m_exportAsDocArchive->setEnabled(
false );
1438 m_exportFormats.clear();
1441 QMenu *menu = m_exportAs->menu();
1442 QList<QAction*> acts = menu->actions();
1443 int num = acts.count();
1444 for (
int i = 2; i < num; ++i )
1446 menu->removeAction( acts.at(i) );
1450 if ( m_showPresentation ) m_showPresentation->setEnabled(
false );
1451 emit setWindowCaption(
"");
1454 if ( url().isLocalFile() )
1456 m_watcher->removeFile( localFilePath() );
1457 QFileInfo fi(localFilePath());
1458 m_watcher->removeDir( fi.absolutePath() );
1459 if ( fi.isSymLink() ) m_watcher->removeFile( fi.readLink() );
1461 m_fileWasRemoved =
false;
1462 if ( m_generatorGuiClient )
1463 factory()->removeClient( m_generatorGuiClient );
1464 m_generatorGuiClient = 0;
1471 m_searchWidget->clearText();
1472 m_topMessage->setVisible(
false );
1473 m_formsMessage->setVisible(
false );
1475 #ifdef OKULAR_KEEP_FILE_OPEN
1478 bool r = KParts::ReadWritePart::closeUrl();
1493 KParts::ReadWritePart::guiActivateEvent(event);
1502 else KMessageBox::information( widget(), i18n(
"This link points to a close document action that does not work when using the embedded viewer." ), QString(),
"warnNoCloseIfNotInOkular" );
1508 KMessageBox::information( widget(), i18n(
"This link points to a quit application action that does not work when using the embedded viewer." ), QString(),
"warnNoQuitIfNotInOkular" );
1514 bool showLeft = m_showLeftPanel->isChecked();
1515 Okular::Settings::setShowLeftPanel( showLeft );
1516 Okular::Settings::self()->writeConfig();
1518 m_sidebar->setSidebarVisibility( showLeft );
1523 const bool showBottom = m_showBottomBar->isChecked();
1524 Okular::Settings::setShowBottomBar( showBottom );
1525 Okular::Settings::self()->writeConfig();
1527 m_bottomBar->setVisible( showBottom );
1537 if ( path == localFilePath() )
1540 if (QFile::exists(localFilePath()))
1541 m_dirtyHandler->start( 750 );
1543 m_fileWasRemoved =
true;
1547 const QFileInfo fi(localFilePath());
1548 if ( fi.absolutePath() == path )
1551 if (!QFile::exists(localFilePath()))
1553 m_fileWasRemoved =
true;
1555 else if (m_fileWasRemoved && QFile::exists(localFilePath()))
1558 m_watcher->removeFile(localFilePath());
1559 m_watcher->addFile(localFilePath());
1560 m_dirtyHandler->start( 750 );
1563 else if ( fi.isSymLink() && fi.readLink() == path )
1565 if ( QFile::exists( fi.readLink() ))
1566 m_dirtyHandler->start( 750 );
1568 m_fileWasRemoved =
true;
1576 bool tocReloadPrepared =
false;
1585 m_viewportDirty = m_document->
viewport();
1588 m_dirtyToolboxIndex = m_sidebar->currentIndex();
1589 m_wasSidebarVisible = m_sidebar->isSidebarVisible();
1590 m_wasSidebarCollapsed = m_sidebar->isCollapsed();
1593 m_wasPresentationOpen = ((PresentationWidget*)m_presentationWidget != 0);
1596 m_toc->prepareForReload();
1597 tocReloadPrepared =
true;
1600 m_dirtyPageRotation = m_document->
rotation();
1604 m_pageView->displayMessage( i18n(
"Reloading the document...") );
1612 if ( tocReloadPrepared )
1614 m_toc->rollbackReload();
1619 if ( tocReloadPrepared )
1620 m_toc->finishReload();
1623 m_pageView->displayMessage( i18n(
"Reloading the document...") );
1625 if ( KParts::ReadWritePart::openUrl( m_oldUrl ) )
1634 if ( m_sidebar->currentIndex() != m_dirtyToolboxIndex && m_sidebar->isItemEnabled( m_dirtyToolboxIndex )
1635 && !m_sidebar->isCollapsed() )
1637 m_sidebar->setCurrentIndex( m_dirtyToolboxIndex );
1639 if ( m_sidebar->isSidebarVisible() != m_wasSidebarVisible )
1641 m_sidebar->setSidebarVisibility( m_wasSidebarVisible );
1643 if ( m_sidebar->isCollapsed() != m_wasSidebarCollapsed )
1645 m_sidebar->setCollapsed( m_wasSidebarCollapsed );
1654 m_dirtyHandler->start( 750 );
1661 bool opened = m_document->
pages() > 0;
1664 m_gotoPage->setEnabled( m_document->
pages() > 1 );
1669 m_beginningOfDocument->setEnabled(
true );
1670 m_prevPage->setEnabled(
true );
1674 if (m_pageView->verticalScrollBar()->value() != 0)
1677 m_beginningOfDocument->setEnabled(
true );
1682 m_beginningOfDocument->setEnabled(
false );
1685 m_prevPage->setEnabled(
false );
1691 m_nextPage->setEnabled(
false );
1692 if (m_pageView->verticalScrollBar()->value() == m_pageView->verticalScrollBar()->maximum())
1695 m_endOfDocument->setEnabled(
false );
1700 m_endOfDocument->setEnabled(
true );
1706 m_nextPage->setEnabled(
true );
1707 m_endOfDocument->setEnabled(
true );
1710 if (m_historyBack) m_historyBack->setEnabled( !m_document->
historyAtBegin() );
1711 if (m_historyNext) m_historyNext->setEnabled( !m_document->
historyAtEnd() );
1712 m_reload->setEnabled(
true );
1713 if (m_copy) m_copy->setEnabled(
true );
1714 if (m_selectAll) m_selectAll->setEnabled(
true );
1718 m_gotoPage->setEnabled(
false );
1719 m_beginningOfDocument->setEnabled(
false );
1720 m_endOfDocument->setEnabled(
false );
1721 m_prevPage->setEnabled(
false );
1722 m_nextPage->setEnabled(
false );
1723 if (m_historyBack) m_historyBack->setEnabled(
false );
1724 if (m_historyNext) m_historyNext->setEnabled(
false );
1725 m_reload->setEnabled(
false );
1726 if (m_copy) m_copy->setEnabled(
false );
1727 if (m_selectAll) m_selectAll->setEnabled(
false );
1732 QWidget *menu = factory()->container(
"menu_okular_part_viewer",
this);
1733 if (menu) menu->setEnabled( opened );
1735 menu = factory()->container(
"view_orientation",
this);
1736 if (menu) menu->setEnabled( opened );
1746 bool opened = m_document->
pages() > 0;
1749 m_addBookmark->setEnabled(
true );
1752 m_addBookmark->setText( i18n(
"Remove Bookmark" ) );
1753 m_addBookmark->setIcon( KIcon(
"edit-delete-bookmark" ) );
1754 m_renameBookmark->setEnabled(
true );
1758 m_addBookmark->setText( m_addBookmarkText );
1759 m_addBookmark->setIcon( m_addBookmarkIcon );
1760 m_renameBookmark->setEnabled(
false );
1765 m_addBookmark->setEnabled(
false );
1766 m_addBookmark->setText( m_addBookmarkText );
1767 m_addBookmark->setIcon( m_addBookmarkIcon );
1768 m_renameBookmark->setEnabled(
false );
1775 m_sidebar->setItemEnabled(0, enable);
1780 m_sidebar->setCurrentIndex( 0, Sidebar::DoNotUncollapseIfCollapsed );
1786 rebuildBookmarkMenu();
1792 m_findBar->focusAndSetCursor();
1793 m_closeFindBar->setShortcut( QKeySequence( Qt::Key_Escape ) );
1798 if ( m_findBar->maybeHide() )
1800 m_pageView->setFocus();
1801 m_closeFindBar->setShortcut( QKeySequence( ) );
1806 class GotoPageDialog :
public KDialog
1809 GotoPageDialog(
QWidget *p,
int current,
int max) : KDialog(p)
1811 setCaption(i18n(
"Go to Page"));
1812 setButtons(Ok | Cancel);
1813 setDefaultButton(Ok);
1818 QVBoxLayout *topLayout =
new QVBoxLayout(w);
1819 topLayout->setMargin(0);
1820 topLayout->setSpacing(spacingHint());
1821 e1 =
new KIntNumInput(current, w);
1822 e1->setRange(1, max);
1823 e1->setEditFocus(
true);
1824 e1->setSliderEnabled(
true);
1826 QLabel *label =
new QLabel(i18n(
"&Page:"), w);
1827 label->setBuddy(e1);
1828 topLayout->addWidget(label);
1829 topLayout->addWidget(e1);
1831 topLayout->addSpacing(spacingHint());
1832 topLayout->addStretch(10);
1848 GotoPageDialog pageDialog( m_pageView, m_document->
currentPage() + 1, m_document->
pages() );
1849 if ( pageDialog.exec() == QDialog::Accepted )
1872 m_beginningOfDocument->setEnabled(
false );
1883 endPage.rePos.normalizedX = 0;
1884 endPage.rePos.normalizedY = 1;
1887 m_endOfDocument->setEnabled(
false);
1923 const QString newName = KInputDialog::getText( i18n(
"Rename Bookmark" ), i18n(
"Enter the new name of the bookmark:" ), bookmark.fullText(), 0, widget());
1924 if (!newName.isEmpty())
1933 QAction *action =
dynamic_cast<QAction *
>(sender());
1938 slotRenameBookmark( vp );
1944 slotRenameBookmark( m_document->
viewport() );
1949 const QList<QAction*> actions = contextMenu->findChildren<QAction*>(
"OkularPrivateRenameBookmarkActions");
1950 foreach(QAction *a, actions)
1952 contextMenu->removeAction(a);
1956 KBookmarkAction *ba =
dynamic_cast<KBookmarkAction*
>(action);
1959 QAction *separatorAction = contextMenu->addSeparator();
1960 separatorAction->setObjectName(
"OkularPrivateRenameBookmarkActions");
1961 QAction *renameAction = contextMenu->addAction( KIcon(
"edit-rename" ), i18n(
"Rename this Bookmark" ),
this, SLOT(
slotRenameBookmarkFromMenu()) );
1962 renameAction->setData(ba->property(
"htmlRef").toString());
1963 renameAction->setObjectName(
"OkularPrivateRenameBookmarkActions");
1971 if ( !bookmark.isNull() )
1983 if ( !bookmark.isNull() )
1995 if ( (PresentationWidget*)m_presentationWidget != 0 )
1997 m_presentationWidget->slotFind();
2008 if (m_findBar->isHidden())
2011 m_findBar->findNext();
2017 if (m_findBar->isHidden())
2020 m_findBar->findPrev();
2025 kDebug() <<
"Okular part doesn't support saving the file in the location from which it was opened";
2039 bool containsLocalAnnotations =
false;
2040 const int pagecount = m_document->
pages();
2042 for (
int pageno = 0; pageno < pagecount; ++pageno )
2049 containsLocalAnnotations =
true;
2053 if ( containsLocalAnnotations )
2058 if ( containsLocalAnnotations )
2060 int res = KMessageBox::warningContinueCancel( widget(), i18n(
"Your annotations will not be exported.\nYou can export the annotated document using File -> Export As -> Document Archive") );
2061 if ( res != KMessageBox::Continue )
2066 KUrl saveUrl = KFileDialog::getSaveUrl( url(),
2067 QString(), widget(), QString(),
2068 KFileDialog::ConfirmOverwrite );
2069 if ( !saveUrl.isValid() || saveUrl.isEmpty() )
2081 KMessageBox::information( widget(), i18n(
"Could not open the temporary file for saving." ) );
2084 fileName = tf.fileName();
2090 if ( isDocumentArchive )
2093 saved = m_document->
saveChanges( fileName, &errorText );
2097 if (errorText.isEmpty())
2099 KMessageBox::information( widget(), i18n(
"File could not be saved in '%1'. Try to save it to another location.", fileName ) );
2103 KMessageBox::information( widget(), i18n(
"File could not be saved in '%1'. %2", fileName, errorText ) );
2108 KIO::Job *copyJob = KIO::file_copy( fileName, saveUrl, -1, KIO::Overwrite );
2109 if ( !KIO::NetAccess::synchronousRun( copyJob, widget() ) )
2111 KMessageBox::information( widget(), i18n(
"File could not be saved in '%1'. Try to save it to another location.", saveUrl.prettyUrl() ) );
2115 setModified(
false );
2125 KUrl saveUrl = KFileDialog::getSaveUrl( KUrl(
"kfiledialog:///okular/" + url().fileName()),
2126 QString(), widget(), QString(),
2127 KFileDialog::ConfirmOverwrite );
2128 if ( saveUrl.isValid() && !saveUrl.isEmpty() )
2132 KUrl srcUrl = KUrl::fromPath( localFilePath() );
2133 KTemporaryFile * tempFile = 0;
2135 if ( !QFile::exists( localFilePath() ) )
2137 if ( url().isLocalFile() )
2139 #ifdef OKULAR_KEEP_FILE_OPEN
2141 if ( ( tempFile = m_keeper->copyToTemporary() ) )
2142 srcUrl = KUrl::fromPath( tempFile->fileName() );
2144 const QString msg = i18n(
"Okular cannot copy %1 to the specified location.\n\nThe document does not exist anymore.", localFilePath() );
2145 KMessageBox::sorry( widget(), msg );
2157 KIO::Job *copyJob = KIO::file_copy( srcUrl, saveUrl, -1, KIO::Overwrite );
2158 if ( !KIO::NetAccess::synchronousRun( copyJob, widget() ) )
2159 KMessageBox::information( widget(), i18n(
"File could not be saved in '%1'. Try to save it to another location.", saveUrl.prettyUrl() ) );
2169 KNS::Engine engine(widget());
2170 engine.init(
"okular.knsrc" );
2172 KNS::Entry::List entries = engine.downloadDialogModal( m_pageView );
2181 PreferencesDialog * dialog =
new PreferencesDialog( m_pageView, Okular::Settings::self(), m_embedMode );
2182 dialog->setAttribute( Qt::WA_DeleteOnClose );
2189 void Part::slotAnnotationPreferences()
2192 PreferencesDialog * dialog =
new PreferencesDialog( m_pageView, Okular::Settings::self(), m_embedMode );
2193 dialog->setAttribute( Qt::WA_DeleteOnClose );
2196 dialog->switchToAnnotationsPage();
2210 m_pageView->reparseConfig();
2216 if ( m_sidebar->isItemEnabled(0) )
2217 m_toc->reparseConfig();
2220 if ( Okular::Settings::showLeftPanel() && !m_thumbnailList->isHidden() )
2221 m_thumbnailList->updateWidgets();
2224 if ( m_sidebar->isItemEnabled(2) )
2225 m_reviewsWidget->reparseConfig();
2233 if (m_document->
pages() == 0)
return;
2240 KPrintPreview previewdlg( &printer, widget() );
2241 setupPrint( printer );
2249 tf.setAutoRemove(
true );
2250 tf.setSuffix(
".ps" );
2252 printer.setOutputFileName( tf.fileName() );
2254 setupPrint( printer );
2256 if ( QFile::exists( printer.outputFileName() ) )
2258 Okular::FilePrinterPreview previewdlg( printer.outputFileName(), widget() );
2270 bool reallyShow =
false;
2273 if (!m_actionsSearched)
2276 KActionCollection *ac;
2281 const QList<KXMLGUIClient*> clients(factory()->clients());
2282 for(
int i = 0 ; (!m_showMenuBarAction || !m_showFullScreenAction) && i < clients.size(); ++i)
2284 ac = clients.at(i)->actionCollection();
2286 act = ac->action(
"options_show_menubar");
2287 if (act && qobject_cast<KToggleAction*>(act))
2288 m_showMenuBarAction = qobject_cast<KToggleAction*>(act);
2290 act = ac->action(
"fullscreen");
2291 if (act && qobject_cast<KToggleFullScreenAction*>(act))
2292 m_showFullScreenAction = qobject_cast<KToggleFullScreenAction*>(act);
2295 m_actionsSearched =
true;
2298 KMenu *popup =
new KMenu( widget() );
2299 QAction *addBookmark = 0;
2300 QAction *removeBookmark = 0;
2301 QAction *fitPageWidth = 0;
2304 popup->addTitle( i18n(
"Page %1", page->
number() + 1 ) );
2307 removeBookmark = popup->addAction( KIcon(
"edit-delete-bookmark"), i18n(
"Remove Bookmark") );
2309 addBookmark = popup->addAction( KIcon(
"bookmark-new"), i18n(
"Add Bookmark") );
2310 if ( m_pageView->canFitPageWidth() )
2311 fitPageWidth = popup->addAction( KIcon(
"zoom-fit-best"), i18n(
"Fit Width") );
2312 popup->addAction( m_prevBookmark );
2313 popup->addAction( m_nextBookmark );
2324 if ((m_showMenuBarAction && !m_showMenuBarAction->isChecked()) || (m_showFullScreenAction && m_showFullScreenAction->isChecked()))
2326 popup->addTitle( i18n(
"Tools" ) );
2327 if (m_showMenuBarAction && !m_showMenuBarAction->isChecked()) popup->addAction(m_showMenuBarAction);
2328 if (m_showFullScreenAction && m_showFullScreenAction->isChecked()) popup->addAction(m_showFullScreenAction);
2335 QAction *res = popup->exec(point);
2338 if (res == addBookmark)
2345 else if (res == removeBookmark)
2352 else if (res == fitPageWidth)
2354 m_pageView->fitPageWidth( page->
number() );
2364 PropertiesDialog *d =
new PropertiesDialog(widget(), m_document);
2372 EmbeddedFilesDialog *d =
new EmbeddedFilesDialog(widget(), m_document);
2380 if ( !m_presentationWidget )
2382 m_presentationWidget =
new PresentationWidget( widget(), m_document, actionCollection() );
2389 if ( m_presentationWidget )
2390 delete (PresentationWidget*) m_presentationWidget;
2398 if ( !m_presentationWidget )
2399 m_presentationWidget =
new PresentationWidget( widget(), m_document, actionCollection() );
2400 else delete (PresentationWidget*) m_presentationWidget;
2424 KAboutData aboutData( *data->aboutData() );
2426 if ( aboutData.programIconName().isEmpty() || aboutData.programIconName() == aboutData.appName() )
2430 const QString mimeTypeName = documentInfo->get(
"mimeType");
2431 if ( !mimeTypeName.isEmpty() )
2433 if ( KMimeType::Ptr type = KMimeType::mimeType( mimeTypeName ) )
2434 aboutData.setProgramIconName( type->iconName() );
2439 KAboutApplicationDialog dlg( &aboutData, widget() );
2446 QList<QAction*> acts = m_exportAs->menu() ? m_exportAs->menu()->actions() : QList<QAction*>();
2447 int id = acts.indexOf( act );
2448 if ( (
id < 0 ) || (
id >= acts.count() ) )
2455 filter =
"text/plain";
2458 filter =
"application/vnd.kde.okular-archive";
2461 filter = m_exportFormats.at(
id - 2 ).mimeType()->name();
2464 QString fileName = KFileDialog::getSaveFileName( url().isLocalFile() ? url().directory() : QString(),
2465 filter, widget(), QString(),
2466 KFileDialog::ConfirmOverwrite );
2467 if ( !fileName.isEmpty() )
2479 saved = m_document->
exportTo( fileName, m_exportFormats.at(
id - 2 ) );
2483 KMessageBox::information( widget(), i18n(
"File could not be saved in '%1'. Try to save it to another location.", fileName ) );
2492 m_dirtyHandler->stop();
2500 if (m_document->
pages() == 0)
return;
2503 QPrinter printer(QPrinter::HighResolution);
2507 QPrintDialog *printDialog = 0;
2508 QWidget *printConfigWidget = 0;
2511 setupPrint( printer );
2518 if ( printConfigWidget )
2520 printDialog = KdePrint::createPrintDialog( &printer, QList<QWidget*>() << printConfigWidget, widget() );
2524 printDialog = KdePrint::createPrintDialog( &printer, widget() );
2531 printDialog->setMinMax( 1, m_document->
pages() );
2532 printDialog->setFromTo( 1, m_document->
pages() );
2537 printDialog->addEnabledOption( QAbstractPrintDialog::PrintSelection );
2541 if ( printDialog->isOptionEnabled( QAbstractPrintDialog::PrintToFile ) &&
2544 printDialog->setEnabledOptions( printDialog->enabledOptions() ^ QAbstractPrintDialog::PrintToFile );
2547 #if QT_VERSION >= KDE_MAKE_VERSION(4,7,0)
2551 printDialog->setOption( QAbstractPrintDialog::PrintCurrentPage );
2555 if ( printDialog->exec() )
2562 void Part::setupPrint( QPrinter &printer )
2564 printer.setOrientation(m_document->
orientation());
2567 QString title = m_document->
metaData(
"DocumentTitle" ).toString();
2568 if ( title.isEmpty() )
2572 if ( !title.isEmpty() )
2574 printer.setDocName( title );
2579 void Part::doPrint(QPrinter &printer)
2583 KMessageBox::error(widget(), i18n(
"Printing this document is not allowed."));
2587 if (!m_document->
print(printer))
2589 const QString error = m_document->
printError();
2590 if (error.isEmpty())
2592 KMessageBox::error(widget(), i18n(
"Could not print the document. Unknown error. Please report to bugs.kde.org"));
2596 KMessageBox::error(widget(), i18n(
"Could not print the document. Detailed error is \"%1\". Please report to bugs.kde.org", error));
2604 KUrl url ( group.readPathEntry(
"URL", QString() ) );
2605 if ( url.isValid() )
2607 QString viewport = group.readEntry(
"Viewport" );
2616 group.writePathEntry(
"URL", url().url() );
2624 if ( status != QProcess::NormalExit )
2627 QProcess *senderobj = sender() ? qobject_cast< QProcess * >( sender() ) : 0;
2631 senderobj->deleteLater();
2634 setLocalFilePath( m_temporaryLocalFile );
2635 openUrl( m_temporaryLocalFile );
2636 m_temporaryLocalFile.clear();
2640 void Part::unsetDummyMode()
2645 m_sidebar->setItemEnabled( 2,
true );
2646 m_sidebar->setItemEnabled( 3,
true );
2647 m_sidebar->setSidebarVisibility( Okular::Settings::showLeftPanel() );
2650 m_historyBack = KStandardAction::documentBack(
this, SLOT(
slotHistoryBack()), actionCollection() );
2651 m_historyBack->setWhatsThis( i18n(
"Go to the place you were before" ) );
2652 connect(m_pageView, SIGNAL(mouseBackButtonClick()), m_historyBack, SLOT(trigger()));
2654 m_historyNext = KStandardAction::documentForward(
this, SLOT(
slotHistoryNext()), actionCollection());
2655 m_historyNext->setWhatsThis( i18n(
"Go to the place you were after" ) );
2656 connect(m_pageView, SIGNAL(mouseForwardButtonClick()), m_historyNext, SLOT(trigger()));
2658 m_pageView->setupActions( actionCollection() );
2661 m_formsMessage->setActionButton( m_pageView->toggleFormsAction() );
2668 bool Part::handleCompressed( QString &destpath,
const QString &path,
const QString &compressedMimetype )
2674 KTemporaryFile *newtempfile =
new KTemporaryFile();
2675 newtempfile->setAutoRemove(
true);
2677 if ( !newtempfile->open() )
2679 KMessageBox::error( widget(),
2680 i18n(
"<qt><strong>File Error!</strong> Could not create temporary file "
2681 "<nobr><strong>%1</strong></nobr>.</qt>",
2682 strerror(newtempfile->error())));
2688 QIODevice* filterDev = KFilterDev::deviceForFile( path, compressedMimetype );
2695 if ( !filterDev->open(QIODevice::ReadOnly) )
2697 KMessageBox::detailedError( widget(),
2698 i18n(
"<qt><strong>File Error!</strong> Could not open the file "
2699 "<nobr><strong>%1</strong></nobr> for uncompression. "
2700 "The file will not be loaded.</qt>", path),
2701 i18n(
"<qt>This error typically occurs if you do "
2702 "not have enough permissions to read the file. "
2703 "You can check ownership and permissions if you "
2704 "right-click on the file in the Dolphin "
2705 "file manager and then choose the 'Properties' tab.</qt>"));
2713 int read = 0, wrtn = 0;
2715 while ((read = filterDev->read(buf,
sizeof(buf))) > 0)
2717 wrtn = newtempfile->write(buf, read);
2722 if ((read != 0) || (newtempfile->size() == 0))
2724 KMessageBox::detailedError(widget(),
2725 i18n(
"<qt><strong>File Error!</strong> Could not uncompress "
2726 "the file <nobr><strong>%1</strong></nobr>. "
2727 "The file will not be loaded.</qt>", path ),
2728 i18n(
"<qt>This error typically occurs if the file is corrupt. "
2729 "If you want to be sure, try to decompress the file manually "
2730 "using command-line tools.</qt>"));
2734 m_tempfile = newtempfile;
2735 destpath = m_tempfile->fileName();
2739 void Part::rebuildBookmarkMenu(
bool unplugActions )
2741 if ( unplugActions )
2743 unplugActionList(
"bookmarks_currentdocument" );
2744 qDeleteAll( m_bookmarkActions );
2745 m_bookmarkActions.clear();
2752 bool havebookmarks =
true;
2753 if ( m_bookmarkActions.isEmpty() )
2755 havebookmarks =
false;
2756 QAction * a =
new KAction( 0 );
2757 a->setText( i18n(
"No Bookmarks" ) );
2758 a->setEnabled(
false );
2759 m_bookmarkActions.append( a );
2761 plugActionList(
"bookmarks_currentdocument", m_bookmarkActions );
2765 const QList<KXMLGUIClient*> clients(factory()->clients());
2766 bool containerFound =
false;
2767 for (
int i = 0; !containerFound && i < clients.size(); ++i)
2769 QWidget *container = factory()->container(
"bookmarks", clients[i]);
2770 if (container && container->actions().contains(m_bookmarkActions.first()))
2772 Q_ASSERT(dynamic_cast<KMenu*>(container));
2773 disconnect(container, 0,
this, 0);
2774 connect(container, SIGNAL(aboutToShowContextMenu(KMenu*,QAction*,QMenu*)),
this, SLOT(
slotAboutToShowContextMenu(KMenu*,QAction*,QMenu*)));
2775 containerFound =
true;
2780 m_prevBookmark->setEnabled( havebookmarks );
2781 m_nextBookmark->setEnabled( havebookmarks );
2784 void Part::updateAboutBackendAction()
2789 m_aboutBackend->setEnabled(
true );
2793 m_aboutBackend->setEnabled(
false );
2797 void Part::resetStartArguments()
2805 ReadWritePart::setReadWrite( readwrite );
void removeBookmark(int page)
Remove a bookmark for the given page.
void reparseConfig()
Reparses and applies the configuration.
QList< ExportFormat > exportFormats() const
Returns the list of supported export formats.
static QString detectConfigFileName(const QVariantList &args)
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.
Q_SCRIPTABLE void slotPrintPreview()
void loadCancelled(const QString &reason)
void setViewport(const DocumentViewport &viewport, DocumentObserver *excludeObserver=0, bool smoothMove=false)
Sets the current document viewport to the given viewport.
KBookmark bookmark(int page) const
Returns the bookmark for the given page of the document.
Native Cross-Platform Printing.
EmbedMode
Describes the possible embedding modes of the part.
KBookmark nextBookmark(const DocumentViewport &viewport) const
Given a viewport, returns the next bookmark.
bool canConfigurePrinter() const
Returns whether the document can configure the printer itself.
BookmarkManager * bookmarkManager() const
Returns the bookmark manager of the document.
uint pages() const
Returns the number of pages of the document.
Q_SCRIPTABLE Q_NOREPLY void goToPage(uint page)
bool supportsPrintToFile() const
Returns whether the document supports printing to both PDF and PS files.
Q_SCRIPTABLE QString documentMetaData(const QString &metaData) const
virtual QObject * create(const char *iface, QWidget *parentWidget, QObject *parent, const QVariantList &args, const QString &keyword)
int number() const
Returns the number of the page in the document.
bool exportToText(const QString &fileName) const
Exports the document as ASCII text and saves it under fileName.
KConfigDialog * slotGeneratorPreferences()
KUrl currentDocument() const
Returns the url of the currently opened document.
void startPresentation()
Start the presentation mode.
void updateBookmarksActions()
bool print(QPrinter &printer)
Prints the document to the given printer.
bool areSourceLocationsShownGraphically() const
Returns true iff source locations are shown graphically.
void clearLastShownSourceLocation()
Clear the source location that was set last in the viewer.
void slotAboutToShowContextMenu(KMenu *menu, QAction *action, QMenu *contextMenu)
QStringList supportedMimeTypes() const
Returns the list with the supported MIME types.
void slotExportAs(QAction *)
Bookmarks has been changed.
void setWatchFileModeEnabled(bool enable)
Allows to enable or disable the watch file mode.
Can save annotation changes.
bool openDocument(const QString &docFile, const KUrl &url, const KMimeType::Ptr &mime)
Opens the document.
void slotRenameBookmarkFromMenu()
void setNextViewport()
Sets the current document viewport to the previous viewport in the viewport history.
void psTransformEnded(int, QProcess::ExitStatus)
QString printError() const
Returns the last print error in case print() failed.
bool isOpened() const
Returns whether the document is currently opened.
Rotation rotation() const
Returns the current rotation of the document.
void removeObserver(DocumentObserver *observer)
Unregisters the given observer for the document.
void slotPreviousBookmark()
static QAction * actionForExportFormat(const Okular::ExportFormat &format, QObject *parent=0)
QWidget * printConfigurationWidget() const
Returns a custom printer configuration page or 0 if no custom printer configuration page is available...
const Page * page(int number) const
Returns the page object for the given page number or 0 if the number is out of range.
void slotRenameCurrentViewportBookmark()
void saveDocumentRestoreInfo(KConfigGroup &group)
Q_SCRIPTABLE uint pages()
Set along with Annotations when Save As is needed or annotation changes will be lost.
void slotShowMenu(const Okular::Page *page, const QPoint &point)
bool saveAs(const KUrl &saveUrl)
void enableCloseAction(bool enable)
bool openDocument(const KUrl &url, uint page)
Open the document at the specified url at page page.
bool isAllowed(Permission action) const
Returns whether the given action is allowed in the document.
void guiActivateEvent(KParts::GUIActivateEvent *event)
void setReadWrite(bool readwrite)
void slotHidePresentation()
void enablePrintAction(bool enable)
const DocumentInfo * documentInfo() const
Returns the meta data of the document or 0 if no meta data are available.
void notifySetup(const QVector< Okular::Page * > &pages, int setupFlags)
This method is called whenever the document is initialized or reconstructed.
void setRotation(int rotation)
This slot is called whenever the user changes the rotation of the document.
int flags() const
Returns the flags of the annotation.
bool canSaveChanges(SaveCapability cap) const
Returns whether it's possible to save a given category of changes to another document.
QString bookmarkedPageRange() const
Returns the range of the bookmarked.pages.
The Goto action changes the viewport to another page or loads an external document.
void setWindowTitleFromDocument()
bool saveDocumentArchive(const QString &fileName)
Saves a document archive.
Q_SCRIPTABLE void slotFind()
void slotShowProperties()
Collector for all the data belonging to a page.
Q_SCRIPTABLE QString currentDocument()
void closeDocument()
Closes the document.
bool openUrl(const KUrl &url)
Q_SCRIPTABLE void slotGotoFirst()
int pageNumber
The number of the page nearest the center of the viewport.
const KComponentData * componentData() const
Returns the component data associated with the generator.
struct Okular::DocumentViewport::@0 rePos
If 'rePos.enabled == true' then this structure contains the viewport center or top left depending on ...
PrintingType printingSupport() const
Returns what sort of printing the document supports: Native, Postscript, None.
Q_SCRIPTABLE void slotPreviousPage()
QLinkedList< Annotation * > annotations() const
Returns the list of annotations of the page.
void openUrlFromDocument(const KUrl &url)
Q_SCRIPTABLE uint currentPage()
const DocumentViewport & viewport() const
Returns the current viewport of the document.
A DOM tree containing information about the document.
void slotShowEmbeddedFiles()
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...
void setPrevViewport()
Sets the current document viewport to the next viewport in the viewport history.
The document is a new document.
Allows to print the document.
bool isBookmarked(int page) const
Returns whether the given page is bookmarked.
static void addFileToWatcher(KDirWatch *watcher, const QString &filePath)
QList< QAction * > actionsForUrl(const KUrl &url) const
Returns a list of actions for the bookmarks of the specified url.
void setNextDocumentViewport(const DocumentViewport &viewport)
Sets the next viewport in the viewport history.
void openSourceReference(const QString &absFileName, int line, int column)
void setAnnotationEditingEnabled(bool enable)
Control annotation editing (creation, modification and removal), which is enabled by default...
Q_SCRIPTABLE Q_NOREPLY void enableStartWithPrint()
void slotFileDirty(const QString &)
static Okular::EmbedMode detectEmbedMode(QWidget *parentWidget, QObject *parent, const QVariantList &args)
void slotShowPresentation()
KXMLGUIClient * guiClient()
Returns the gui client of the generator, if it provides one.
static QString compressedMimeFor(const QString &mime_to_check)
bool historyAtBegin() const
Returns whether the document history is at the begin.
int configurableGenerators() const
Returns the number of generators that have a configuration widget.
Q_SCRIPTABLE void slotTogglePresentation()
bool exportTo(const QString &fileName, const ExportFormat &format) const
Exports the document in the given format and saves it under fileName.
bool isWatchFileModeEnabled() const
Returns true iff the watch file mode is enabled.
Annotation struct holds properties shared by all annotations.
bool canExportToText() const
Returns whether the document supports the export to ASCII text.
void restoreDocument(const KConfigGroup &group)
void setShowSourceLocationsGraphically(bool show)
Allows to control whether source locations are shown graphically, or not.
void enableTOC(bool enable)
void addBookmark(int page)
Adds a bookmark for the given page.
Q_SCRIPTABLE void slotPreferences()
bool historyAtEnd() const
Returns whether the document history is at the end.
void showSourceLocation(const QString &fileName, int line, int column, bool showGraphically=true)
Show the specified source location centrally in the viewer.
Q_SCRIPTABLE void slotNextPage()
void setNextDocumentDestination(const QString &namedDestination)
Sets the next namedDestination in the viewport history.
void openUrlFromBookmarks(const KUrl &url)
void viewerMenuStateChange(bool enabled)
bool saveChanges(const QString &fileName)
Save the document and the optional changes to it to the specified fileName.
void registerView(View *view)
Register the specified view for the current document.
void notifyPageChanged(int page, int flags)
This method is called whenever the content on page described by the passed flags has been changed...
QStringList supportedMimeTypes() const
Return a list with the supported mimetypes.
void notifyViewportChanged(bool smoothMove)
This method is called whenever the viewport has been changed.
void addObserver(DocumentObserver *observer)
Registers a new observer for the document.
void slotRebuildBookmarkMenu()
void fillConfigDialog(KConfigDialog *dialog)
Fill the KConfigDialog dialog with the setting pages of the generators.
QString toString() const
Returns the viewport as xml description.
bool supportsSearching() const
Returns whether the document supports searching.
KBookmark previousBookmark(const DocumentViewport &viewport) const
Given a viewport, returns the previous bookmark.
void processAction(const Action *action)
Processes the given action.
Relative to the top left corner of the page.
KAboutData okularAboutData(const char *name, const char *iname)
QPrinter::Orientation orientation() const
Returns the orientation of the document (for printing purposes).
void renameBookmark(KBookmark *bm, const QString &newName)
Returns the bookmark given bookmark of the document.
DocumentObserver * m_tiledObserver
Q_SCRIPTABLE Q_NOREPLY void reload()
const QList< EmbeddedFile * > * embeddedFiles() const
Returns the list of embedded files or 0 if no embedded files are available.
Q_SCRIPTABLE void slotGotoLast()
bool isValid() const
Returns whether the viewport is valid.
bool openDocumentArchive(const QString &docFile, const KUrl &url)
Opens a document archive.
void slotJobStarted(KIO::Job *job)
void setViewportPage(int page, DocumentObserver *excludeObserver=0, bool smoothMove=false)
Sets the current document viewport to the given page.
void slotJobFinished(KJob *job)
uint currentPage() const
Returns the number of the current page.