compile
[kdegraphics.git] / okular / core / action.h
blob6c2563f099f69e388ec1a8169cad6a2c174265cd
1 /***************************************************************************
2 * Copyright (C) 2004 by Enrico Ros <eros.kde@email.it> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 ***************************************************************************/
10 #ifndef _OKULAR_ACTION_H_
11 #define _OKULAR_ACTION_H_
13 #include <okular/core/global.h>
14 #include <okular/core/okular_export.h>
16 #include <QtCore/QString>
18 namespace Okular {
20 class ActionPrivate;
21 class GotoActionPrivate;
22 class ExecuteActionPrivate;
23 class BrowseActionPrivate;
24 class DocumentActionPrivate;
25 class SoundActionPrivate;
26 class ScriptActionPrivate;
27 class MovieActionPrivate;
28 class Sound;
29 class DocumentViewport;
31 /**
32 * @short Encapsulates data that describes an action.
34 * This is the base class for actions. It makes mandatory for inherited
35 * widgets to reimplement the 'actionType' method and return the type of
36 * the action described by the reimplemented class.
38 class OKULAR_EXPORT Action
40 public:
41 /**
42 * Describes the type of action.
44 enum ActionType {
45 Goto, ///< Goto a given page or external document
46 Execute, ///< Execute a command or external application
47 Browse, ///< Browse a given website
48 DocAction, ///< Start a custom action
49 Sound, ///< Play a sound
50 Movie, ///< Play a movie
51 Script ///< Executes a Script code
54 /**
55 * Destroys the action.
57 virtual ~Action();
59 /**
60 * Returns the type of the action. Every inherited class must return
61 * an unique identifier.
63 * @see ActionType
65 virtual ActionType actionType() const = 0;
67 /**
68 * Returns a i18n'ed tip of the action that is presented to
69 * the user.
71 virtual QString actionTip() const;
73 protected:
74 /// @cond PRIVATE
75 Action( ActionPrivate &dd );
76 Q_DECLARE_PRIVATE( Action )
77 ActionPrivate *d_ptr;
78 /// @endcond
80 private:
81 Q_DISABLE_COPY( Action )
85 /**
86 * The Goto action changes the viewport to another page
87 * or loads an external document.
89 class OKULAR_EXPORT GotoAction : public Action
91 public:
92 /**
93 * Creates a new goto action.
95 * @p fileName The name of an external file that shall be loaded.
96 * @p viewport The target viewport information of the current document.
98 GotoAction( const QString& fileName, const DocumentViewport & viewport );
101 * Destroys the goto action.
103 virtual ~GotoAction();
106 * Returns the action type.
108 ActionType actionType() const;
111 * Returns the action tip.
113 QString actionTip() const;
116 * Returns whether the goto action points to an external document.
118 bool isExternal() const;
121 * Returns the filename of the external document.
123 QString fileName() const;
126 * Returns the document viewport the goto action points to.
128 DocumentViewport destViewport() const;
130 private:
131 Q_DECLARE_PRIVATE( GotoAction )
132 Q_DISABLE_COPY( GotoAction )
136 * The Execute action executes an external application.
138 class OKULAR_EXPORT ExecuteAction : public Action
140 public:
142 * Creates a new execute action.
144 * @param fileName The file name of the application to execute.
145 * @param parameters The parameters of the application to execute.
147 ExecuteAction( const QString &fileName, const QString &parameters );
150 * Destroys the execute action.
152 virtual ~ExecuteAction();
155 * Returns the action type.
157 ActionType actionType() const;
160 * Returns the action tip.
162 QString actionTip() const;
165 * Returns the file name of the application to execute.
167 QString fileName() const;
170 * Returns the parameters of the application to execute.
172 QString parameters() const;
174 private:
175 Q_DECLARE_PRIVATE( ExecuteAction )
176 Q_DISABLE_COPY( ExecuteAction )
180 * The Browse action browses an url by opening a web browser or
181 * email client, depedning on the url protocol (e.g. http, mailto, etc.).
183 class OKULAR_EXPORT BrowseAction : public Action
185 public:
187 * Creates a new browse action.
189 * @param url The url to browse.
191 BrowseAction( const QString &url );
194 * Destroys the browse action.
196 virtual ~BrowseAction();
199 * Returns the action type.
201 ActionType actionType() const;
204 * Returns the action tip.
206 QString actionTip() const;
209 * Returns the url to browse.
211 QString url() const;
213 private:
214 Q_DECLARE_PRIVATE( BrowseAction )
215 Q_DISABLE_COPY( BrowseAction )
219 * The DocumentAction action contains an action that is performed on
220 * the current document.
222 class OKULAR_EXPORT DocumentAction : public Action
224 public:
226 * Describes the possible action types.
228 * WARNING KEEP IN SYNC WITH POPPLER!
230 enum DocumentActionType {
231 PageFirst = 1, ///< Jump to first page
232 PagePrev = 2, ///< Jump to previous page
233 PageNext = 3, ///< Jump to next page
234 PageLast = 4, ///< Jump to last page
235 HistoryBack = 5, ///< Go back in page history
236 HistoryForward = 6, ///< Go forward in page history
237 Quit = 7, ///< Quit application
238 Presentation = 8, ///< Start presentation
239 EndPresentation = 9, ///< End presentation
240 Find = 10, ///< Open find dialog
241 GoToPage = 11, ///< Goto page
242 Close = 12 ///< Close document
246 * Creates a new document action.
248 * @param documentActionType The type of document action.
250 explicit DocumentAction( enum DocumentActionType documentActionType );
253 * Destroys the document action.
255 virtual ~DocumentAction();
258 * Returns the action type.
260 ActionType actionType() const;
263 * Returns the action tip.
265 QString actionTip() const;
268 * Returns the type of action.
270 DocumentActionType documentActionType() const;
272 private:
273 Q_DECLARE_PRIVATE( DocumentAction )
274 Q_DISABLE_COPY( DocumentAction )
278 * The Sound action plays a sound on activation.
280 class OKULAR_EXPORT SoundAction : public Action
282 public:
284 * Creates a new sound action.
286 * @param volume The volume of the sound.
287 * @param synchronous Whether the sound shall be played synchronous.
288 * @param repeat Whether the sound shall be repeated.
289 * @param mix Whether the sound shall be mixed.
290 * @param sound The sound object which contains the sound data.
292 SoundAction( double volume, bool synchronous, bool repeat, bool mix, Okular::Sound *sound );
295 * Destroys the sound action.
297 virtual ~SoundAction();
300 * Returns the action type.
302 ActionType actionType() const;
305 * Returns the action tip.
307 QString actionTip() const;
310 * Returns the volume of the sound.
312 double volume() const;
315 * Returns whether the sound shall be played synchronous.
317 bool synchronous() const;
320 * Returns whether the sound shall be repeated.
322 bool repeat() const;
325 * Returns whether the sound shall be mixed.
327 bool mix() const;
330 * Returns the sound object which contains the sound data.
332 Okular::Sound *sound() const;
334 private:
335 Q_DECLARE_PRIVATE( SoundAction )
336 Q_DISABLE_COPY( SoundAction )
340 * The Script action executes a Script code.
342 * @since 0.7 (KDE 4.1)
344 class OKULAR_EXPORT ScriptAction : public Action
346 public:
348 * Creates a new Script action.
350 * @param script The code to execute.
352 ScriptAction( enum ScriptType type, const QString &script );
355 * Destroys the browse action.
357 virtual ~ScriptAction();
360 * Returns the action type.
362 ActionType actionType() const;
365 * Returns the action tip.
367 QString actionTip() const;
370 * Returns the type of action.
372 ScriptType scriptType() const;
375 * Returns the code.
377 QString script() const;
379 private:
380 Q_DECLARE_PRIVATE( ScriptAction )
381 Q_DISABLE_COPY( ScriptAction )
384 #if 0
386 * The Movie action plays a video on activation.
388 class MovieAction : public Action
390 public:
392 * Creates a new movie action.
394 MovieAction();
397 * Destroys the movie action.
399 virtual ~MovieAction();
402 * Returns the action type.
404 ActionType actionType() const;
407 * Returns the action tip.
409 QString actionTip() const;
411 private:
412 Q_DECLARE_PRIVATE( MovieAction )
413 Q_DISABLE_COPY( MovieAction )
415 #endif
419 #endif