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();
136 void slotSaveFileAs();
137 void slotSaveCopyAs();
138 void slotGetNewStuff();
139 void slotNewConfig();
140 void slotNewGeneratorConfig();
141 void slotShowMenu(const Okular::Page
*page
, const QPoint
&point
);
142 void slotShowProperties();
143 void slotShowEmbeddedFiles();
144 void slotShowLeftPanel();
145 void slotShowPresentation();
146 void slotHidePresentation();
147 void slotExportAs(QAction
*);
148 bool slotImportPSFile();
149 void slotAboutBackend();
153 void slotShowFindBar();
154 void slotHideFindBar();
155 void setMimeTypes(KIO::Job
*job
);
156 void loadCancelled(const QString
&reason
);
157 void setWindowTitleFromDocument();
158 // can be connected to widget elements
159 void updateViewActions();
160 void updateBookmarksActions();
161 void enableTOC(bool enable
);
162 void slotRebuildBookmarkMenu();
165 // connected to Shell action (and browserExtension), not local one
167 void restoreDocument(const KConfigGroup
&group
);
168 void saveDocumentRestoreInfo(KConfigGroup
&group
);
169 void slotFileDirty( const QString
& );
170 void slotDoFileDirty();
171 void psTransformEnded(int, QProcess::ExitStatus
);
174 void setupPrint( QPrinter
&printer
);
175 void doPrint( QPrinter
&printer
);
176 bool handleCompressed( QString
&destpath
, const QString
&path
, const QString
&compressedMimetype
);
177 void rebuildBookmarkMenu( bool unplugActions
= true );
178 void updateAboutBackendAction();
179 void unsetDummyMode();
181 KTemporaryFile
*m_tempfile
;
184 Okular::Document
* m_document
;
185 QString m_temporaryLocalFile
;
189 SearchWidget
*m_searchWidget
;
191 PageViewTopMessage
* m_topMessage
;
192 PageViewTopMessage
* m_formsMessage
;
193 QPointer
<ThumbnailList
> m_thumbnailList
;
194 QPointer
<PageView
> m_pageView
;
196 QPointer
<MiniBar
> m_miniBar
;
197 QPointer
<PresentationWidget
> m_presentationWidget
;
198 QPointer
<ProgressWidget
> m_progressWidget
;
199 QPointer
<PageSizeLabel
> m_pageSizeLabel
;
200 QPointer
<Reviews
> m_reviewsWidget
;
201 QPointer
<BookmarkList
> m_bookmarkList
;
203 // document watcher (and reloader) variables
204 KDirWatch
*m_watcher
;
205 QTimer
*m_dirtyHandler
;
206 Okular::DocumentViewport m_viewportDirty
;
207 bool m_wasPresentationOpen
;
208 int m_dirtyToolboxIndex
;
209 bool m_wasSidebarVisible
;
210 bool m_fileWasRemoved
;
212 // Remember the search history
213 QStringList m_searchHistory
;
219 KAction
*m_firstPage
;
221 KAction
*m_historyBack
;
222 KAction
*m_historyNext
;
223 KAction
*m_addBookmark
;
224 KAction
*m_prevBookmark
;
225 KAction
*m_nextBookmark
;
227 KAction
*m_selectAll
;
231 KAction
*m_saveCopyAs
;
232 KAction
*m_printPreview
;
233 KAction
*m_showProperties
;
234 KAction
*m_showEmbeddedFiles
;
236 QAction
*m_exportAsText
;
237 KAction
*m_showPresentation
;
238 KToggleAction
* m_showMenuBarAction
;
239 KToggleAction
* m_showLeftPanel
;
240 KToggleFullScreenAction
* m_showFullScreenAction
;
241 KAction
*m_aboutBackend
;
243 QMenu
*m_exportAsMenu
;
245 bool m_actionsSearched
;
246 BrowserExtension
*m_bExtension
;
248 QList
<Okular::ExportFormat
> m_exportFormats
;
249 QList
<QAction
*> m_bookmarkActions
;
250 bool m_cliPresentation
;
251 QString m_addBookmarkText
;
252 QIcon m_addBookmarkIcon
;
258 KXMLGUIClient
*m_generatorGuiClient
;
259 FileKeeper
*m_keeper
;
262 void slotGeneratorPreferences();
267 /* kate: replace-tabs on; indent-width 4; */