File indexing completed on 2024-05-19 04:59:16
0001 /* ============================================================ 0002 * GreaseMonkey plugin for Falkon 0003 * Copyright (C) 2012-2018 David Rosca <nowrep@gmail.com> 0004 * 0005 * This program is free software: you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation, either version 3 of the License, or 0008 * (at your option) any later version. 0009 * 0010 * This program is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License 0016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0017 * ============================================================ */ 0018 #ifndef GM_SCRIPT_H 0019 #define GM_SCRIPT_H 0020 0021 #include <QObject> 0022 #include <QIcon> 0023 #include <QUrl> 0024 0025 class QWebEngineScript; 0026 0027 class GM_Manager; 0028 0029 class DelayedFileWatcher; 0030 0031 class GM_Script : public QObject 0032 { 0033 Q_OBJECT 0034 public: 0035 explicit GM_Script(GM_Manager* manager, const QString &filePath); 0036 0037 enum StartAt { DocumentStart, DocumentEnd, DocumentIdle }; 0038 0039 bool isValid() const; 0040 QString name() const; 0041 QString nameSpace() const; 0042 QString fullName() const; 0043 0044 QString description() const; 0045 QString version() const; 0046 0047 QIcon icon() const; 0048 QUrl iconUrl() const; 0049 0050 QUrl downloadUrl() const; 0051 QUrl updateUrl() const; 0052 0053 StartAt startAt() const; 0054 bool noFrames() const; 0055 0056 bool isEnabled() const; 0057 void setEnabled(bool enable); 0058 0059 QStringList include() const; 0060 QStringList exclude() const; 0061 QStringList require() const; 0062 0063 QString metaData() const; 0064 QString fileName() const; 0065 0066 QWebEngineScript webScript() const; 0067 0068 bool isUpdating(); 0069 void updateScript(); 0070 0071 Q_SIGNALS: 0072 void scriptChanged(); 0073 void updatingChanged(bool updating); 0074 0075 private Q_SLOTS: 0076 void watchedFileChanged(const QString &file); 0077 0078 private: 0079 void parseScript(); 0080 void reloadScript(); 0081 void downloadIcon(); 0082 void downloadRequires(); 0083 0084 GM_Manager* m_manager; 0085 DelayedFileWatcher* m_fileWatcher; 0086 0087 QString m_name; 0088 QString m_namespace; 0089 QString m_description; 0090 QString m_version; 0091 0092 QStringList m_include; 0093 QStringList m_exclude; 0094 QStringList m_require; 0095 0096 QIcon m_icon; 0097 QUrl m_iconUrl; 0098 QUrl m_downloadUrl; 0099 QUrl m_updateUrl; 0100 StartAt m_startAt; 0101 bool m_noframes; 0102 0103 QString m_script; 0104 QString m_fileName; 0105 bool m_enabled; 0106 bool m_valid; 0107 bool m_updating; 0108 }; 0109 0110 #endif // GM_SCRIPT_H