2004-12-10 16:04:45 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2004 by Enrico Ros <eros.kde@email.it> *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
2007-04-20 12:37:12 +00:00
|
|
|
#ifndef _OKULAR_ACTION_H_
|
|
|
|
#define _OKULAR_ACTION_H_
|
2004-12-10 16:04:45 +00:00
|
|
|
|
2007-01-03 14:30:48 +00:00
|
|
|
#include <okular/core/okular_export.h>
|
2006-05-08 20:12:04 +00:00
|
|
|
|
2006-09-21 08:45:36 +00:00
|
|
|
#include <QtCore/QString>
|
|
|
|
|
|
|
|
namespace Okular {
|
|
|
|
|
2007-05-02 21:59:44 +00:00
|
|
|
class ActionPrivate;
|
2007-05-02 22:50:27 +00:00
|
|
|
class GotoActionPrivate;
|
|
|
|
class ExecuteActionPrivate;
|
|
|
|
class BrowseActionPrivate;
|
|
|
|
class DocumentActionPrivate;
|
|
|
|
class SoundActionPrivate;
|
|
|
|
class MovieActionPrivate;
|
2006-10-09 18:02:59 +00:00
|
|
|
class Sound;
|
2007-01-03 14:30:48 +00:00
|
|
|
class DocumentViewport;
|
2006-10-09 18:02:59 +00:00
|
|
|
|
2004-12-10 16:04:45 +00:00
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* @short Encapsulates data that describes an action.
|
2005-01-10 13:43:44 +00:00
|
|
|
*
|
2007-04-20 12:58:15 +00:00
|
|
|
* This is the base class for actions. It makes mandatory for inherited
|
2007-04-20 12:37:12 +00:00
|
|
|
* widgets to reimplement the 'actionType' method and return the type of
|
2007-04-20 12:58:15 +00:00
|
|
|
* the action described by the reimplemented class.
|
2004-12-10 16:04:45 +00:00
|
|
|
*/
|
2007-04-20 12:37:12 +00:00
|
|
|
class OKULAR_EXPORT Action
|
2004-12-10 16:04:45 +00:00
|
|
|
{
|
|
|
|
public:
|
2006-11-27 08:08:39 +00:00
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* Describes the type of action.
|
2006-11-27 08:08:39 +00:00
|
|
|
*/
|
2007-04-20 12:37:12 +00:00
|
|
|
enum ActionType {
|
2006-11-27 08:08:39 +00:00
|
|
|
Goto, ///< Goto a given page or external document
|
|
|
|
Execute, ///< Execute a command or external application
|
|
|
|
Browse, ///< Browse a given website
|
2007-05-02 22:50:27 +00:00
|
|
|
DocAction, ///< Start a custom action
|
2006-11-27 08:08:39 +00:00
|
|
|
Sound, ///< Play a sound
|
|
|
|
Movie ///< Play a movie
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* Destroys the action.
|
2006-11-27 08:08:39 +00:00
|
|
|
*/
|
2007-04-20 12:37:12 +00:00
|
|
|
virtual ~Action();
|
2006-11-27 08:08:39 +00:00
|
|
|
|
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* Returns the type of the action. Every inherited class must return
|
2006-11-27 08:08:39 +00:00
|
|
|
* an unique identifier.
|
|
|
|
*
|
2007-04-20 12:37:12 +00:00
|
|
|
* @see ActionType
|
2006-11-27 08:08:39 +00:00
|
|
|
*/
|
2007-04-20 12:37:12 +00:00
|
|
|
virtual ActionType actionType() const = 0;
|
2004-12-10 16:04:45 +00:00
|
|
|
|
2006-11-27 08:08:39 +00:00
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* Returns a i18n'ed tip of the action that is presented to
|
2006-11-27 08:08:39 +00:00
|
|
|
* the user.
|
|
|
|
*/
|
2007-04-20 12:37:12 +00:00
|
|
|
virtual QString actionTip() const;
|
2007-01-03 14:30:48 +00:00
|
|
|
|
2007-05-02 21:59:44 +00:00
|
|
|
protected:
|
2007-09-01 22:48:28 +00:00
|
|
|
/// @cond PRIVATE
|
2007-05-02 21:59:44 +00:00
|
|
|
Action( ActionPrivate &dd );
|
|
|
|
Q_DECLARE_PRIVATE( Action )
|
|
|
|
ActionPrivate *d_ptr;
|
2007-09-01 22:48:28 +00:00
|
|
|
/// @endcond
|
2007-01-03 14:30:48 +00:00
|
|
|
|
2007-05-02 21:59:44 +00:00
|
|
|
private:
|
2007-04-20 12:37:12 +00:00
|
|
|
Q_DISABLE_COPY( Action )
|
2004-12-10 16:04:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-11-27 08:08:39 +00:00
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* The Goto action changes the viewport to another page
|
2006-11-27 08:08:39 +00:00
|
|
|
* or loads an external document.
|
|
|
|
*/
|
2007-05-02 22:50:27 +00:00
|
|
|
class OKULAR_EXPORT GotoAction : public Action
|
2004-12-10 16:04:45 +00:00
|
|
|
{
|
|
|
|
public:
|
2006-11-27 08:08:39 +00:00
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* Creates a new goto action.
|
2006-11-27 08:08:39 +00:00
|
|
|
*
|
|
|
|
* @p fileName The name of an external file that shall be loaded.
|
|
|
|
* @p viewport The target viewport information of the current document.
|
|
|
|
*/
|
2007-05-02 22:50:27 +00:00
|
|
|
GotoAction( const QString& fileName, const DocumentViewport & viewport );
|
2006-11-27 08:08:39 +00:00
|
|
|
|
2007-01-03 14:30:48 +00:00
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* Destroys the goto action.
|
2007-01-03 14:30:48 +00:00
|
|
|
*/
|
2007-05-02 22:50:27 +00:00
|
|
|
virtual ~GotoAction();
|
2007-01-03 14:30:48 +00:00
|
|
|
|
2006-11-27 08:08:39 +00:00
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* Returns the action type.
|
2006-11-27 08:08:39 +00:00
|
|
|
*/
|
2007-04-20 12:37:12 +00:00
|
|
|
ActionType actionType() const;
|
2006-11-27 08:08:39 +00:00
|
|
|
|
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* Returns the action tip.
|
2006-11-27 08:08:39 +00:00
|
|
|
*/
|
2007-04-20 12:37:12 +00:00
|
|
|
QString actionTip() const;
|
2004-12-10 16:04:45 +00:00
|
|
|
|
2006-11-27 08:08:39 +00:00
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* Returns whether the goto action points to an external document.
|
2006-11-27 08:08:39 +00:00
|
|
|
*/
|
|
|
|
bool isExternal() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the filename of the external document.
|
|
|
|
*/
|
|
|
|
QString fileName() const;
|
|
|
|
|
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* Returns the document viewport the goto action points to.
|
2006-11-27 08:08:39 +00:00
|
|
|
*/
|
|
|
|
DocumentViewport destViewport() const;
|
|
|
|
|
2004-12-10 16:04:45 +00:00
|
|
|
private:
|
2007-05-02 22:50:27 +00:00
|
|
|
Q_DECLARE_PRIVATE( GotoAction )
|
|
|
|
Q_DISABLE_COPY( GotoAction )
|
2004-12-10 16:04:45 +00:00
|
|
|
};
|
|
|
|
|
2006-12-04 09:31:53 +00:00
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* The Execute action executes an external application.
|
2006-12-04 09:31:53 +00:00
|
|
|
*/
|
2007-05-02 22:50:27 +00:00
|
|
|
class OKULAR_EXPORT ExecuteAction : public Action
|
2004-12-10 16:04:45 +00:00
|
|
|
{
|
|
|
|
public:
|
2006-12-04 09:31:53 +00:00
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* Creates a new execute action.
|
2006-12-04 09:31:53 +00:00
|
|
|
*
|
|
|
|
* @param fileName The file name of the application to execute.
|
|
|
|
* @param parameters The parameters of the application to execute.
|
|
|
|
*/
|
2007-05-02 22:50:27 +00:00
|
|
|
ExecuteAction( const QString &fileName, const QString ¶meters );
|
2004-12-10 16:04:45 +00:00
|
|
|
|
2007-01-03 14:30:48 +00:00
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* Destroys the execute action.
|
2007-01-03 14:30:48 +00:00
|
|
|
*/
|
2007-05-02 22:50:27 +00:00
|
|
|
virtual ~ExecuteAction();
|
2007-01-03 14:30:48 +00:00
|
|
|
|
2006-12-04 09:31:53 +00:00
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* Returns the action type.
|
2006-12-04 09:31:53 +00:00
|
|
|
*/
|
2007-04-20 12:37:12 +00:00
|
|
|
ActionType actionType() const;
|
2006-12-04 09:31:53 +00:00
|
|
|
|
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* Returns the action tip.
|
2006-12-04 09:31:53 +00:00
|
|
|
*/
|
2007-04-20 12:37:12 +00:00
|
|
|
QString actionTip() const;
|
2004-12-10 16:04:45 +00:00
|
|
|
|
2006-12-04 09:31:53 +00:00
|
|
|
/**
|
|
|
|
* Returns the file name of the application to execute.
|
|
|
|
*/
|
|
|
|
QString fileName() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the parameters of the application to execute.
|
|
|
|
*/
|
|
|
|
QString parameters() const;
|
|
|
|
|
2004-12-10 16:04:45 +00:00
|
|
|
private:
|
2007-05-02 22:50:27 +00:00
|
|
|
Q_DECLARE_PRIVATE( ExecuteAction )
|
|
|
|
Q_DISABLE_COPY( ExecuteAction )
|
2004-12-10 16:04:45 +00:00
|
|
|
};
|
|
|
|
|
2006-12-04 09:31:53 +00:00
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* The Browse action browses an url by opening a web browser or
|
2006-12-04 09:31:53 +00:00
|
|
|
* email client, depedning on the url protocol (e.g. http, mailto, etc.).
|
|
|
|
*/
|
2007-05-02 22:50:27 +00:00
|
|
|
class OKULAR_EXPORT BrowseAction : public Action
|
2004-12-10 16:04:45 +00:00
|
|
|
{
|
|
|
|
public:
|
2006-12-04 09:31:53 +00:00
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* Creates a new browse action.
|
2006-12-04 09:31:53 +00:00
|
|
|
*
|
|
|
|
* @param url The url to browse.
|
|
|
|
*/
|
2007-05-02 22:50:27 +00:00
|
|
|
BrowseAction( const QString &url );
|
2004-12-10 16:04:45 +00:00
|
|
|
|
2007-01-03 14:30:48 +00:00
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* Destroys the browse action.
|
2007-01-03 14:30:48 +00:00
|
|
|
*/
|
2007-05-02 22:50:27 +00:00
|
|
|
virtual ~BrowseAction();
|
2007-01-03 14:30:48 +00:00
|
|
|
|
2006-12-04 09:31:53 +00:00
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* Returns the action type.
|
2006-12-04 09:31:53 +00:00
|
|
|
*/
|
2007-04-20 12:37:12 +00:00
|
|
|
ActionType actionType() const;
|
2006-12-04 09:31:53 +00:00
|
|
|
|
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* Returns the action tip.
|
2006-12-04 09:31:53 +00:00
|
|
|
*/
|
2007-04-20 12:37:12 +00:00
|
|
|
QString actionTip() const;
|
2004-12-10 16:04:45 +00:00
|
|
|
|
2006-12-04 09:31:53 +00:00
|
|
|
/**
|
|
|
|
* Returns the url to browse.
|
|
|
|
*/
|
|
|
|
QString url() const;
|
|
|
|
|
2004-12-10 16:04:45 +00:00
|
|
|
private:
|
2007-05-02 22:50:27 +00:00
|
|
|
Q_DECLARE_PRIVATE( BrowseAction )
|
|
|
|
Q_DISABLE_COPY( BrowseAction )
|
2004-12-10 16:04:45 +00:00
|
|
|
};
|
|
|
|
|
2006-12-04 09:31:53 +00:00
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* The DocumentAction action contains an action that is performed on
|
2006-12-04 09:31:53 +00:00
|
|
|
* the current document.
|
|
|
|
*/
|
2007-05-02 22:50:27 +00:00
|
|
|
class OKULAR_EXPORT DocumentAction : public Action
|
2004-12-10 16:04:45 +00:00
|
|
|
{
|
|
|
|
public:
|
2006-12-04 09:31:53 +00:00
|
|
|
/**
|
|
|
|
* Describes the possible action types.
|
|
|
|
*
|
|
|
|
* WARNING KEEP IN SYNC WITH POPPLER!
|
|
|
|
*/
|
2007-04-20 12:37:12 +00:00
|
|
|
enum DocumentActionType {
|
2006-12-04 09:31:53 +00:00
|
|
|
PageFirst = 1, ///< Jump to first page
|
|
|
|
PagePrev = 2, ///< Jump to previous page
|
|
|
|
PageNext = 3, ///< Jump to next page
|
|
|
|
PageLast = 4, ///< Jump to last page
|
|
|
|
HistoryBack = 5, ///< Go back in page history
|
|
|
|
HistoryForward = 6, ///< Go forward in page history
|
|
|
|
Quit = 7, ///< Quit application
|
|
|
|
Presentation = 8, ///< Start presentation
|
|
|
|
EndPresentation = 9, ///< End presentation
|
|
|
|
Find = 10, ///< Open find dialog
|
|
|
|
GoToPage = 11, ///< Goto page
|
|
|
|
Close = 12 ///< Close document
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* Creates a new document action.
|
2006-12-04 09:31:53 +00:00
|
|
|
*
|
2007-05-27 09:53:45 +00:00
|
|
|
* @param documentActionType The type of document action.
|
2006-12-04 09:31:53 +00:00
|
|
|
*/
|
2007-05-02 22:50:27 +00:00
|
|
|
explicit DocumentAction( enum DocumentActionType documentActionType );
|
2006-12-04 09:31:53 +00:00
|
|
|
|
2007-01-03 14:30:48 +00:00
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* Destroys the document action.
|
2007-01-03 14:30:48 +00:00
|
|
|
*/
|
2007-05-02 22:50:27 +00:00
|
|
|
virtual ~DocumentAction();
|
2007-01-03 14:30:48 +00:00
|
|
|
|
2006-12-04 09:31:53 +00:00
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* Returns the action type.
|
2006-12-04 09:31:53 +00:00
|
|
|
*/
|
2007-04-20 12:37:12 +00:00
|
|
|
ActionType actionType() const;
|
2006-12-04 09:31:53 +00:00
|
|
|
|
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* Returns the action tip.
|
2006-12-04 09:31:53 +00:00
|
|
|
*/
|
2007-04-20 12:37:12 +00:00
|
|
|
QString actionTip() const;
|
2004-12-10 16:04:45 +00:00
|
|
|
|
2006-12-04 09:31:53 +00:00
|
|
|
/**
|
|
|
|
* Returns the type of action.
|
|
|
|
*/
|
2007-04-20 12:37:12 +00:00
|
|
|
DocumentActionType documentActionType() const;
|
2006-12-04 09:31:53 +00:00
|
|
|
|
2004-12-10 16:04:45 +00:00
|
|
|
private:
|
2007-05-02 22:50:27 +00:00
|
|
|
Q_DECLARE_PRIVATE( DocumentAction )
|
|
|
|
Q_DISABLE_COPY( DocumentAction )
|
2004-12-10 16:04:45 +00:00
|
|
|
};
|
|
|
|
|
2006-12-04 09:31:53 +00:00
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* The Sound action plays a sound on activation.
|
2006-12-04 09:31:53 +00:00
|
|
|
*/
|
2007-05-02 22:50:27 +00:00
|
|
|
class OKULAR_EXPORT SoundAction : public Action
|
2006-10-09 18:02:59 +00:00
|
|
|
{
|
|
|
|
public:
|
2006-12-04 09:31:53 +00:00
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* Creates a new sound action.
|
2006-12-04 09:31:53 +00:00
|
|
|
*
|
|
|
|
* @param volume The volume of the sound.
|
|
|
|
* @param synchronous Whether the sound shall be played synchronous.
|
|
|
|
* @param repeat Whether the sound shall be repeated.
|
|
|
|
* @param mix Whether the sound shall be mixed.
|
|
|
|
* @param sound The sound object which contains the sound data.
|
|
|
|
*/
|
2007-05-02 22:50:27 +00:00
|
|
|
SoundAction( double volume, bool synchronous, bool repeat, bool mix, Okular::Sound *sound );
|
2006-12-04 09:31:53 +00:00
|
|
|
|
2007-01-03 14:30:48 +00:00
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* Destroys the sound action.
|
2007-01-03 14:30:48 +00:00
|
|
|
*/
|
2007-05-02 22:50:27 +00:00
|
|
|
virtual ~SoundAction();
|
2007-01-03 14:30:48 +00:00
|
|
|
|
2006-12-04 09:31:53 +00:00
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* Returns the action type.
|
2006-12-04 09:31:53 +00:00
|
|
|
*/
|
2007-04-20 12:37:12 +00:00
|
|
|
ActionType actionType() const;
|
2006-12-04 09:31:53 +00:00
|
|
|
|
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* Returns the action tip.
|
2006-12-04 09:31:53 +00:00
|
|
|
*/
|
2007-04-20 12:37:12 +00:00
|
|
|
QString actionTip() const;
|
2006-12-04 09:31:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the volume of the sound.
|
|
|
|
*/
|
|
|
|
double volume() const;
|
2006-10-09 18:02:59 +00:00
|
|
|
|
2006-12-04 09:31:53 +00:00
|
|
|
/**
|
|
|
|
* Returns whether the sound shall be played synchronous.
|
|
|
|
*/
|
|
|
|
bool synchronous() const;
|
2006-10-09 18:02:59 +00:00
|
|
|
|
2006-12-04 09:31:53 +00:00
|
|
|
/**
|
|
|
|
* Returns whether the sound shall be repeated.
|
|
|
|
*/
|
|
|
|
bool repeat() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether the sound shall be mixed.
|
|
|
|
*/
|
|
|
|
bool mix() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the sound object which contains the sound data.
|
|
|
|
*/
|
|
|
|
Okular::Sound *sound() const;
|
2006-10-09 18:02:59 +00:00
|
|
|
|
|
|
|
private:
|
2007-05-02 22:50:27 +00:00
|
|
|
Q_DECLARE_PRIVATE( SoundAction )
|
|
|
|
Q_DISABLE_COPY( SoundAction )
|
2006-10-09 18:02:59 +00:00
|
|
|
};
|
|
|
|
|
2007-08-29 11:59:54 +00:00
|
|
|
#if 0
|
2006-12-04 09:31:53 +00:00
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* The Movie action plays a video on activation.
|
2006-12-04 09:31:53 +00:00
|
|
|
*/
|
2007-05-02 22:50:27 +00:00
|
|
|
class MovieAction : public Action
|
2004-12-10 16:04:45 +00:00
|
|
|
{
|
|
|
|
public:
|
2006-12-04 09:31:53 +00:00
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* Creates a new movie action.
|
2006-12-04 09:31:53 +00:00
|
|
|
*/
|
2007-05-02 22:50:27 +00:00
|
|
|
MovieAction();
|
2006-12-04 09:31:53 +00:00
|
|
|
|
2007-01-03 14:30:48 +00:00
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* Destroys the movie action.
|
2007-01-03 14:30:48 +00:00
|
|
|
*/
|
2007-05-02 22:50:27 +00:00
|
|
|
virtual ~MovieAction();
|
2007-01-03 14:30:48 +00:00
|
|
|
|
2006-12-04 09:31:53 +00:00
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* Returns the action type.
|
2006-12-04 09:31:53 +00:00
|
|
|
*/
|
2007-04-20 12:37:12 +00:00
|
|
|
ActionType actionType() const;
|
2006-12-04 09:31:53 +00:00
|
|
|
|
|
|
|
/**
|
2007-04-20 12:58:15 +00:00
|
|
|
* Returns the action tip.
|
2006-12-04 09:31:53 +00:00
|
|
|
*/
|
2007-04-20 12:37:12 +00:00
|
|
|
QString actionTip() const;
|
2007-01-03 14:30:48 +00:00
|
|
|
|
|
|
|
private:
|
2007-05-02 22:50:27 +00:00
|
|
|
Q_DECLARE_PRIVATE( MovieAction )
|
|
|
|
Q_DISABLE_COPY( MovieAction )
|
2004-12-10 16:04:45 +00:00
|
|
|
};
|
2007-08-29 11:59:54 +00:00
|
|
|
#endif
|
2004-12-10 16:04:45 +00:00
|
|
|
|
2006-09-21 08:45:36 +00:00
|
|
|
}
|
|
|
|
|
2004-12-10 16:04:45 +00:00
|
|
|
#endif
|