10#include <KLocalizedString>
16#include "sourcereference_p.h"
20class Okular::ActionPrivate
27 virtual ~ActionPrivate()
29 qDeleteAll(m_nextActions);
32 ActionPrivate(
const ActionPrivate &) =
delete;
33 ActionPrivate &operator=(
const ActionPrivate &) =
delete;
36 std::shared_ptr<const void> m_nativeHandle;
40Action::Action(ActionPrivate &dd)
70 return d->m_nextActions;
73void Action::setNativeHandle(std::shared_ptr<const void> handle)
76 d->m_nativeHandle = std::move(handle);
78const void *Action::nativeHandle()
const
81 return d->m_nativeHandle.get();
87 qDeleteAll(d->m_nextActions);
88 d->m_nextActions = actions;
93class Okular::GotoActionPrivate :
public Okular::ActionPrivate
98 , m_extFileName(fileName)
103 GotoActionPrivate(
const QString &fileName,
const QString &namedDestination)
105 , m_extFileName(fileName)
106 , m_dest(namedDestination)
116 :
Action(*new GotoActionPrivate(fileName, viewport))
121 :
Action(*new GotoActionPrivate(fileName, namedDestination))
137 return d->m_extFileName.isEmpty() ? (d->m_vp.isValid() ?
i18n(
"Go to page %1", d->m_vp.pageNumber + 1) :
QLatin1String(
"")) :
i18n(
"Open external file");
143 return !d->m_extFileName.isEmpty();
149 return d->m_extFileName;
166class Okular::ExecuteActionPrivate :
public Okular::ActionPrivate
169 ExecuteActionPrivate(
const QString &file,
const QString ¶meters)
172 , m_parameters(parameters)
181 :
Action(*new ExecuteActionPrivate(file, parameters))
197 return i18n(
"Execute '%1'...", d->m_fileName);
203 return d->m_fileName;
209 return d->m_parameters;
214class Okular::BrowseActionPrivate :
public Okular::ActionPrivate
217 explicit BrowseActionPrivate(
const QUrl &url)
227 :
Action(*new BrowseActionPrivate(url))
244 int row = 0, col = 0;
245 if (extractLilyPondSourceReference(d->m_url, &source, &row, &col)) {
246 return sourceReferenceToolTip(source, row, col);
248 return d->m_url.toDisplayString();
259class Okular::DocumentActionPrivate :
public Okular::ActionPrivate
264 , m_type(documentActionType)
272 :
Action(*new DocumentActionPrivate(documentActionType))
296 return i18n(
"First Page");
298 return i18n(
"Previous Page");
300 return i18n(
"Next Page");
302 return i18n(
"Last Page");
306 return i18n(
"Forward");
310 return i18n(
"Start Presentation");
312 return i18n(
"End Presentation");
314 return i18n(
"Find...");
316 return i18n(
"Go To Page...");
326class Okular::SoundActionPrivate :
public Okular::ActionPrivate
329 SoundActionPrivate(
double volume,
bool sync,
bool repeat,
bool mix,
Okular::Sound *sound)
339 ~SoundActionPrivate()
override
352 :
Action(*new SoundActionPrivate(volume, sync, repeat, mix, sound))
367 return i18n(
"Play sound...");
402class Okular::ScriptActionPrivate :
public Okular::ActionPrivate
417 :
Action(*new ScriptActionPrivate(type, script))
433 switch (d->m_scriptType) {
435 return i18n(
"JavaScript Script");
444 return d->m_scriptType;
455class Okular::MovieActionPrivate :
public Okular::ActionPrivate
460 , m_operation(operation)
461 , m_annotation(nullptr)
470 :
Action(*new MovieActionPrivate(operation))
485 return i18n(
"Play movie...");
491 return d->m_operation;
503 return d->m_annotation;
508class Okular::RenditionActionPrivate :
public Okular::ActionPrivate
513 , m_operation(operation)
515 , m_scriptType(scriptType)
517 , m_annotation(nullptr)
529 :
Action(*new RenditionActionPrivate(operation, movie, scriptType, script))
546 switch (d->m_operation) {
549 switch (d->m_scriptType) {
551 return i18n(
"JavaScript Script");
556 return i18n(
"Play movie");
558 return i18n(
"Stop movie");
560 return i18n(
"Pause movie");
562 return i18n(
"Resume movie");
569 return d->m_operation;
581 return d->m_scriptType;
599 return d->m_annotation;
602BackendOpaqueAction::BackendOpaqueAction()
603 :
Action(*new ActionPrivate())
Encapsulates data that describes an action.
ActionType
Describes the type of action.
@ Execute
Execute a command or external application.
@ Goto
Goto a given page or external document.
@ DocAction
Start a custom action.
@ BackendOpaque
Calls back to the backend with the action.
@ Browse
Browse a given website.
@ Script
Executes a Script code.
@ Rendition
Play a movie and/or execute a Script code.
The Browse action browses an url by opening a web browser or email client, depending on the url proto...
ActionType actionType() const override
Returns the action type.
~BrowseAction() override
Destroys the browse action.
BrowseAction(const QUrl &url)
Creates a new browse action.
QUrl url() const
Returns the url to browse.
QString actionTip() const override
Returns the action tip.
The DocumentAction action contains an action that is performed on the current document.
DocumentActionType documentActionType() const
Returns the type of action.
~DocumentAction() override
Destroys the document action.
ActionType actionType() const override
Returns the action type.
DocumentActionType
Describes the possible action types.
@ PageNext
Jump to next page.
@ Presentation
Start presentation.
@ PageLast
Jump to last page.
@ PageFirst
Jump to first page.
@ HistoryForward
Go forward in page history.
@ EndPresentation
End presentation.
@ PagePrev
Jump to previous page.
@ HistoryBack
Go back in page history.
DocumentAction(enum DocumentActionType documentActionType)
Creates a new document action.
QString actionTip() const override
Returns the action tip.
The Execute action executes an external application.
ActionType actionType() const override
Returns the action type.
QString fileName() const
Returns the file name of the application to execute.
QString actionTip() const override
Returns the action tip.
~ExecuteAction() override
Destroys the execute action.
ExecuteAction(const QString &fileName, const QString ¶meters)
Creates a new execute action.
QString parameters() const
Returns the parameters of the application to execute.
The Goto action changes the viewport to another page or loads an external document.
QString actionTip() const override
Returns the action tip.
ActionType actionType() const override
Returns the action type.
bool isExternal() const
Returns whether the goto action points to an external document.
QString destinationName() const
Returns the document named destination the goto action points to.
GotoAction(const QString &fileName, const DocumentViewport &viewport)
Creates a new goto action.
~GotoAction() override
Destroys the goto action.
QString fileName() const
Returns the filename of the external document.
DocumentViewport destViewport() const
Returns the document viewport the goto action points to.
The Movie action executes an operation on a video on activation.
QString actionTip() const override
Returns the action tip.
void setAnnotation(MovieAnnotation *annotation)
Sets the annotation that is associated with the movie action.
~MovieAction() override
Destroys the movie action.
MovieAnnotation * annotation() const
Returns the annotation or 0 if no annotation has been set.
MovieAction(OperationType operation)
Creates a new movie action.
OperationType operation() const
Returns the operation type.
ActionType actionType() const override
Returns the action type.
OperationType
Describes the possible operation types.
Contains information about a movie object.
The Rendition action executes an operation on a video or executes some JavaScript code on activation.
ScriptType scriptType() const
Returns the type of script.
QString actionTip() const override
Returns the action tip.
~RenditionAction() override
Destroys the rendition action.
ScreenAnnotation * annotation() const
Returns the annotation or 0 if no annotation has been set.
void setAnnotation(ScreenAnnotation *annotation)
Sets the annotation that is associated with the rendition action.
ActionType actionType() const override
Returns the action type.
RenditionAction(OperationType operation, Okular::Movie *movie, enum ScriptType scriptType, const QString &script)
Creates a new rendition action.
Okular::Movie * movie() const
Returns the movie object or 0 if no movie object was set on construction time.
OperationType
Describes the possible operation types.
@ Stop
Stop playing the video.
@ Resume
Resume playing the video.
@ None
Execute only the JavaScript.
@ Play
Start playing the video.
QString script() const
Returns the script code.
OperationType operation() const
Returns the operation type.
The Script action executes a Script code.
QString actionTip() const override
Returns the action tip.
ScriptType scriptType() const
Returns the type of action.
ScriptAction(enum ScriptType type, const QString &script)
Creates a new Script action.
~ScriptAction() override
Destroys the browse action.
ActionType actionType() const override
Returns the action type.
QString script() const
Returns the code.
The Sound action plays a sound on activation.
SoundAction(double volume, bool synchronous, bool repeat, bool mix, Okular::Sound *sound)
Creates a new sound action.
~SoundAction() override
Destroys the sound action.
bool mix() const
Returns whether the sound shall be mixed.
bool synchronous() const
Returns whether the sound shall be played synchronous.
ActionType actionType() const override
Returns the action type.
double volume() const
Returns the volume of the sound.
bool repeat() const
Returns whether the sound shall be repeated.
QString actionTip() const override
Returns the action tip.
Okular::Sound * sound() const
Returns the sound object which contains the sound data.
Contains information about a sound object.
QString i18n(const char *text, const TYPE &arg...)
ScriptType
Describes the possible script types.
@ JavaScript
JavaScript code.