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>
38 class KToggleFullScreenAction
;
47 class PageViewTopMessage
;
48 class PresentationWidget
;
61 class BrowserExtension
;
64 * This is a "Part". It that does all the real work in a KPart
68 * @author Wilco Greven <greven@kde.org>
71 class Part
: public KParts::ReadOnlyPart
, public Okular::DocumentObserver
, public KDocumentViewer
74 Q_CLASSINFO("D-Bus Interface", "org.kde.okular")
75 Q_INTERFACES(KDocumentViewer
)
78 // Default constructor
79 Part(QWidget
* parentWidget
, QObject
* parent
, const QVariantList
& args
);
84 // inherited from DocumentObserver
85 uint
observerId() const { return PART_ID
; }
86 void notifySetup( const QVector
< Okular::Page
* > &pages
, int setupFlags
);
87 void notifyViewportChanged( bool smoothMove
);
88 void notifyPageChanged( int page
, int flags
);
90 bool openDocument(const KUrl
& url
, uint page
);
91 void startPresentation();
92 QStringList
supportedMimeTypes() const;
97 Q_SCRIPTABLE Q_NOREPLY
void goToPage(uint page
);
98 Q_SCRIPTABLE Q_NOREPLY
void openDocument( const QString
&doc
);
99 Q_SCRIPTABLE uint
pages();
100 Q_SCRIPTABLE uint
currentPage();
101 Q_SCRIPTABLE QString
currentDocument();
102 Q_SCRIPTABLE
void slotPreferences();
103 Q_SCRIPTABLE
void slotFind();
104 Q_SCRIPTABLE
void slotPrintPreview();
105 Q_SCRIPTABLE
void slotPreviousPage();
106 Q_SCRIPTABLE
void slotNextPage();
107 Q_SCRIPTABLE
void slotGotoFirst();
108 Q_SCRIPTABLE
void slotGotoLast();
109 Q_SCRIPTABLE
void slotTogglePresentation();
112 void enablePrintAction(bool enable
);
115 // reimplemented from KParts::ReadOnlyPart
117 bool openUrl(const KUrl
&url
);
121 // connected to actions
122 void openUrlFromDocument(const KUrl
&url
);
123 void openUrlFromBookmarks(const KUrl
&url
);
125 void slotHistoryBack();
126 void slotHistoryNext();
127 void slotAddBookmark();
128 void slotPreviousBookmark();
129 void slotNextBookmark();
131 void slotSaveFileAs();
132 void slotSaveCopyAs();
133 void slotGetNewStuff();
134 void slotNewConfig();
135 void slotNewGeneratorConfig();
136 void slotShowMenu(const Okular::Page
*page
, const QPoint
&point
);
137 void slotShowProperties();
138 void slotShowEmbeddedFiles();
139 void slotShowLeftPanel();
140 void slotShowPresentation();
141 void slotHidePresentation();
142 void slotExportAs(QAction
*);
143 bool slotImportPSFile();
144 void slotAboutBackend();
148 void slotShowFindBar();
149 void slotHideFindBar();
150 void setMimeTypes(KIO::Job
*job
);
151 void loadCancelled(const QString
&reason
);
152 void setWindowTitleFromDocument();
153 // can be connected to widget elements
154 void updateViewActions();
155 void updateBookmarksActions();
156 void enableTOC(bool enable
);
157 void slotRebuildBookmarkMenu();
160 // connected to Shell action (and browserExtension), not local one
162 void restoreDocument(const KConfigGroup
&group
);
163 void saveDocumentRestoreInfo(KConfigGroup
&group
);
164 void slotFileDirty( const QString
& );
165 void slotDoFileDirty();
166 void psTransformEnded(int, QProcess::ExitStatus
);
169 void setupPrint( QPrinter
&printer
);
170 void doPrint( QPrinter
&printer
);
171 bool handleCompressed( QString
&destpath
, const QString
&path
, const QString
&compressedMimetype
);
172 void rebuildBookmarkMenu( bool unplugActions
= true );
173 void updateAboutBackendAction();
174 void unsetDummyMode();
176 KTemporaryFile
*m_tempfile
;
179 Okular::Document
* m_document
;
180 QString m_temporaryLocalFile
;
184 SearchWidget
*m_searchWidget
;
186 PageViewTopMessage
* m_topMessage
;
187 PageViewTopMessage
* m_formsMessage
;
188 QPointer
<ThumbnailList
> m_thumbnailList
;
189 QPointer
<PageView
> m_pageView
;
191 QPointer
<MiniBar
> m_miniBar
;
192 QPointer
<PresentationWidget
> m_presentationWidget
;
193 QPointer
<ProgressWidget
> m_progressWidget
;
194 QPointer
<PageSizeLabel
> m_pageSizeLabel
;
196 // document watcher (and reloader) variables
197 KDirWatch
*m_watcher
;
198 QTimer
*m_dirtyHandler
;
199 Okular::DocumentViewport m_viewportDirty
;
200 bool m_wasPresentationOpen
;
201 int m_dirtyToolboxIndex
;
202 bool m_wasSidebarVisible
;
203 bool m_fileWasRemoved
;
205 // Remember the search history
206 QStringList m_searchHistory
;
212 QAction
*m_firstPage
;
214 QAction
*m_historyBack
;
215 QAction
*m_historyNext
;
216 QAction
*m_addBookmark
;
217 QAction
*m_prevBookmark
;
218 QAction
*m_nextBookmark
;
220 QAction
*m_selectAll
;
224 QAction
*m_saveCopyAs
;
225 QAction
*m_printPreview
;
226 QAction
*m_showProperties
;
227 QAction
*m_showEmbeddedFiles
;
229 QAction
*m_exportAsText
;
230 QAction
*m_showPresentation
;
231 KToggleAction
* m_showMenuBarAction
;
232 KToggleAction
* m_showLeftPanel
;
233 KToggleFullScreenAction
* m_showFullScreenAction
;
234 QAction
*m_aboutBackend
;
237 bool m_actionsSearched
;
238 BrowserExtension
*m_bExtension
;
240 QList
<Okular::ExportFormat
> m_exportFormats
;
241 QList
<QAction
*> m_bookmarkActions
;
242 bool m_cliPresentation
;
243 QString m_addBookmarkText
;
244 QIcon m_addBookmarkIcon
;
250 KXMLGUIClient
*m_generatorGuiClient
;
251 FileKeeper
*m_keeper
;
254 void slotGeneratorPreferences();
259 /* kate: replace-tabs on; indent-width 4; */