1 /***************************************************************************
2 * Copyright (C) 2002 by Wilco Greven <greven@kde.org> *
3 * Copyright (C) 2003-2004 by Christophe Devriese *
4 * <Christophe.Devriese@student.kuleuven.ac.be> *
5 * Copyright (C) 2003 by Andy Goossens <andygoossens@telenet.be> *
6 * Copyright (C) 2003 by Laurent Montel <montel@kde.org> *
7 * Copyright (C) 2004 by Dominique Devriese <devriese@kde.org> *
8 * Copyright (C) 2004-2007 by Albert Astals Cid <aacid@kde.org> *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 ***************************************************************************/
19 #include <kparts/part.h>
24 #include "core/observer.h"
25 #include "core/document.h"
26 #include "kdocumentviewer.h"
28 #include <QtDBus/QtDBus>
39 class KToggleFullScreenAction
;
49 class PageViewTopMessage
;
50 class PresentationWidget
;
65 class BrowserExtension
;
68 * This is a "Part". It that does all the real work in a KPart
72 * @author Wilco Greven <greven@kde.org>
75 class Part
: public KParts::ReadOnlyPart
, public Okular::DocumentObserver
, public KDocumentViewer
78 Q_CLASSINFO("D-Bus Interface", "org.kde.okular")
79 Q_INTERFACES(KDocumentViewer
)
82 // Default constructor
83 Part(QWidget
* parentWidget
, QObject
* parent
, const QVariantList
& args
);
88 // inherited from DocumentObserver
89 uint
observerId() const { return PART_ID
; }
90 void notifySetup( const QVector
< Okular::Page
* > &pages
, int setupFlags
);
91 void notifyViewportChanged( bool smoothMove
);
92 void notifyPageChanged( int page
, int flags
);
94 bool openDocument(const KUrl
& url
, uint page
);
95 void startPresentation();
96 QStringList
supportedMimeTypes() const;
100 public slots
: // dbus
101 Q_SCRIPTABLE Q_NOREPLY
void goToPage(uint page
);
102 Q_SCRIPTABLE Q_NOREPLY
void openDocument( const QString
&doc
);
103 Q_SCRIPTABLE uint
pages();
104 Q_SCRIPTABLE uint
currentPage();
105 Q_SCRIPTABLE QString
currentDocument();
106 Q_SCRIPTABLE
void slotPreferences();
107 Q_SCRIPTABLE
void slotFind();
108 Q_SCRIPTABLE
void slotPrintPreview();
109 Q_SCRIPTABLE
void slotPreviousPage();
110 Q_SCRIPTABLE
void slotNextPage();
111 Q_SCRIPTABLE
void slotGotoFirst();
112 Q_SCRIPTABLE
void slotGotoLast();
113 Q_SCRIPTABLE
void slotTogglePresentation();
114 Q_SCRIPTABLE Q_NOREPLY
void reload();
117 void enablePrintAction(bool enable
);
120 // reimplemented from KParts::ReadOnlyPart
122 bool openUrl(const KUrl
&url
);
126 // connected to actions
127 void openUrlFromDocument(const KUrl
&url
);
128 void openUrlFromBookmarks(const KUrl
&url
);
130 void slotHistoryBack();
131 void slotHistoryNext();
132 void slotAddBookmark();
133 void slotPreviousBookmark();
134 void slotNextBookmark();
137 void slotSaveFileAs();
138 void slotSaveCopyAs();
139 void slotGetNewStuff();
140 void slotNewConfig();
141 void slotNewGeneratorConfig();
142 void slotShowMenu(const Okular::Page
*page
, const QPoint
&point
);
143 void slotShowProperties();
144 void slotShowEmbeddedFiles();
145 void slotShowLeftPanel();
146 void slotShowPresentation();
147 void slotHidePresentation();
148 void slotExportAs(QAction
*);
149 bool slotImportPSFile();
150 void slotAboutBackend();
154 void slotShowFindBar();
155 void slotHideFindBar();
156 void setMimeTypes(KIO::Job
*job
);
157 void loadCancelled(const QString
&reason
);
158 void setWindowTitleFromDocument();
159 // can be connected to widget elements
160 void updateViewActions();
161 void updateBookmarksActions();
162 void enableTOC(bool enable
);
163 void slotRebuildBookmarkMenu();
166 // connected to Shell action (and browserExtension), not local one
168 void restoreDocument(const KConfigGroup
&group
);
169 void saveDocumentRestoreInfo(KConfigGroup
&group
);
170 void slotFileDirty( const QString
& );
171 void slotDoFileDirty();
172 void psTransformEnded(int, QProcess::ExitStatus
);
175 void setupPrint( QPrinter
&printer
);
176 void doPrint( QPrinter
&printer
);
177 bool handleCompressed( QString
&destpath
, const QString
&path
, const QString
&compressedMimetype
);
178 void rebuildBookmarkMenu( bool unplugActions
= true );
179 void updateAboutBackendAction();
180 void unsetDummyMode();
182 KTemporaryFile
*m_tempfile
;
185 Okular::Document
* m_document
;
186 QString m_temporaryLocalFile
;
190 SearchWidget
*m_searchWidget
;
192 PageViewTopMessage
* m_topMessage
;
193 PageViewTopMessage
* m_formsMessage
;
194 QPointer
<ThumbnailList
> m_thumbnailList
;
195 QPointer
<PageView
> m_pageView
;
197 QPointer
<MiniBar
> m_miniBar
;
198 QPointer
<PresentationWidget
> m_presentationWidget
;
199 QPointer
<ProgressWidget
> m_progressWidget
;
200 QPointer
<PageSizeLabel
> m_pageSizeLabel
;
201 QPointer
<Reviews
> m_reviewsWidget
;
202 QPointer
<BookmarkList
> m_bookmarkList
;
204 // document watcher (and reloader) variables
205 KDirWatch
*m_watcher
;
206 QTimer
*m_dirtyHandler
;
207 Okular::DocumentViewport m_viewportDirty
;
208 bool m_wasPresentationOpen
;
209 int m_dirtyToolboxIndex
;
210 bool m_wasSidebarVisible
;
211 bool m_fileWasRemoved
;
213 // Remember the search history
214 QStringList m_searchHistory
;
220 KAction
*m_firstPage
;
222 KAction
*m_historyBack
;
223 KAction
*m_historyNext
;
224 KAction
*m_addBookmark
;
225 KAction
*m_prevBookmark
;
226 KAction
*m_nextBookmark
;
228 KAction
*m_selectAll
;
233 KAction
*m_saveCopyAs
;
234 KAction
*m_printPreview
;
235 KAction
*m_showProperties
;
236 KAction
*m_showEmbeddedFiles
;
238 QAction
*m_exportAsText
;
239 QAction
*m_exportAsDocArchive
;
240 KAction
*m_showPresentation
;
241 KToggleAction
* m_showMenuBarAction
;
242 KToggleAction
* m_showLeftPanel
;
243 KToggleFullScreenAction
* m_showFullScreenAction
;
244 KAction
*m_aboutBackend
;
246 QMenu
*m_exportAsMenu
;
248 bool m_actionsSearched
;
249 BrowserExtension
*m_bExtension
;
251 QList
<Okular::ExportFormat
> m_exportFormats
;
252 QList
<QAction
*> m_bookmarkActions
;
253 bool m_cliPresentation
;
254 QString m_addBookmarkText
;
255 QIcon m_addBookmarkIcon
;
261 KXMLGUIClient
*m_generatorGuiClient
;
262 FileKeeper
*m_keeper
;
265 void slotGeneratorPreferences();
270 /* kate: replace-tabs on; indent-width 4; */