File indexing completed on 2024-05-12 04:33:32

0001 /*
0002     SPDX-FileCopyrightText: 2008 Pino Toscano <pino@kde.org>
0003     SPDX-FileCopyrightText: 2008 Harri Porten <porten@kde.org>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef OKULAR_SCRIPT_JS_APP_P_H
0009 #define OKULAR_SCRIPT_JS_APP_P_H
0010 
0011 #include <QJSValue>
0012 #include <QObject>
0013 #include <QPoint>
0014 
0015 class QMenu;
0016 class QTimer;
0017 
0018 namespace Okular
0019 {
0020 class DocumentPrivate;
0021 
0022 class JSApp : public QObject
0023 {
0024     Q_OBJECT
0025     Q_PROPERTY(int formsVersion READ formsVersion CONSTANT)
0026     Q_PROPERTY(QString language READ language CONSTANT)
0027     Q_PROPERTY(int numPlugIns READ numPlugIns CONSTANT)
0028     Q_PROPERTY(QString platform READ platform CONSTANT)
0029     Q_PROPERTY(QJSValue plugIns READ plugIns CONSTANT)
0030     Q_PROPERTY(QStringList printColorProfiles READ printColorProfiles CONSTANT)
0031     Q_PROPERTY(QStringList printerNames READ printerNames CONSTANT)
0032     Q_PROPERTY(QString viewerType READ viewerType CONSTANT)
0033     Q_PROPERTY(QString viewerVariation READ viewerVariation CONSTANT)
0034     Q_PROPERTY(int viewerVersion READ viewerVersion CONSTANT)
0035 
0036 public:
0037     explicit JSApp(DocumentPrivate *doc, QTimer *watchdogTimer, QObject *parent = nullptr);
0038     ~JSApp() override;
0039     static void clearCachedFields();
0040 
0041     int formsVersion() const;
0042     QString language() const;
0043     int numPlugIns() const;
0044     QString platform() const;
0045     QJSValue plugIns() const;
0046     QStringList printColorProfiles() const;
0047     QStringList printerNames() const;
0048     QString viewerType() const;
0049     QString viewerVariation() const;
0050     int viewerVersion() const;
0051 
0052     Q_INVOKABLE int alert(const QJSValue &arguments);
0053     Q_INVOKABLE int alert(const QString &cMsg, int nIcon = 0, int nType = 0, const QString &cTitle = {}, const QJSValue &oDoc = {}, const QJSValue &oCheckbox = {});
0054     Q_INVOKABLE void beep(int nType = 4);
0055     Q_INVOKABLE QJSValue getNthPlugInName(int nIndex) const;
0056     Q_INVOKABLE void goBack();
0057     Q_INVOKABLE void goForward();
0058     Q_INVOKABLE QJSValue setInterval(const QString &cExpr, int nMilliseconds);
0059     Q_INVOKABLE void clearInterval(const QJSValue &oInterval);
0060     Q_INVOKABLE QJSValue setTimeOut(const QString &cExpr, int nMilliseconds);
0061     Q_INVOKABLE void clearTimeOut(const QJSValue &oTime);
0062     Q_INVOKABLE QJSValue okular_popUpMenuEx(const QJSValue &arguments);
0063 
0064 private:
0065     QJSValue wrapTimer(QTimer *timer) const;
0066     static bool createPopUpMenuTree(int depth, QMenu *rootMenu, const QJSValue &arguments);
0067 
0068     DocumentPrivate *m_doc = nullptr;
0069     QTimer *m_watchdogTimer = nullptr;
0070 };
0071 
0072 }
0073 
0074 #endif