2012-07-11 18:30:00 +02:00
|
|
|
/* ============================================================
|
|
|
|
* GreaseMonkey plugin for QupZilla
|
2014-01-11 16:11:42 +01:00
|
|
|
* Copyright (C) 2012-2014 David Rosca <nowrep@gmail.com>
|
2012-07-11 18:30:00 +02:00
|
|
|
*
|
|
|
|
* 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 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
* ============================================================ */
|
|
|
|
#ifndef GM_SCRIPT_H
|
|
|
|
#define GM_SCRIPT_H
|
|
|
|
|
|
|
|
#include "gm_urlmatcher.h"
|
|
|
|
|
|
|
|
#include <QObject>
|
2013-02-26 12:56:11 +01:00
|
|
|
#include <QVector>
|
2012-07-11 18:30:00 +02:00
|
|
|
#include <QUrl>
|
|
|
|
|
|
|
|
class QWebFrame;
|
|
|
|
|
|
|
|
class GM_Manager;
|
|
|
|
class GM_UrlMatcher;
|
|
|
|
|
2013-04-02 13:14:19 +02:00
|
|
|
class DelayedFileWatcher;
|
|
|
|
|
2013-01-30 14:12:09 +01:00
|
|
|
class GM_Script : public QObject
|
2012-07-11 18:30:00 +02:00
|
|
|
{
|
2013-01-30 14:12:09 +01:00
|
|
|
Q_OBJECT
|
2012-07-11 18:30:00 +02:00
|
|
|
public:
|
2013-01-30 14:12:09 +01:00
|
|
|
explicit GM_Script(GM_Manager* manager, const QString &filePath);
|
2012-07-11 18:30:00 +02:00
|
|
|
|
|
|
|
enum StartAt { DocumentStart, DocumentEnd };
|
|
|
|
|
|
|
|
bool isValid() const;
|
|
|
|
QString name() const;
|
|
|
|
QString nameSpace() const;
|
|
|
|
QString fullName() const;
|
|
|
|
|
|
|
|
QString description() const;
|
|
|
|
QString version() const;
|
|
|
|
|
|
|
|
QUrl downloadUrl() const;
|
|
|
|
StartAt startAt() const;
|
|
|
|
|
|
|
|
bool isEnabled() const;
|
|
|
|
void setEnabled(bool enable);
|
|
|
|
|
|
|
|
QStringList include() const;
|
|
|
|
QStringList exclude() const;
|
|
|
|
|
|
|
|
QString script() const;
|
|
|
|
QString fileName() const;
|
|
|
|
|
|
|
|
bool match(const QString &urlString);
|
|
|
|
|
2013-06-02 18:25:25 +02:00
|
|
|
signals:
|
|
|
|
void scriptChanged();
|
|
|
|
|
2013-01-30 14:12:09 +01:00
|
|
|
private slots:
|
|
|
|
void watchedFileChanged(const QString &file);
|
|
|
|
|
2012-07-11 18:30:00 +02:00
|
|
|
private:
|
2013-01-30 14:12:09 +01:00
|
|
|
void parseScript();
|
2012-07-11 18:30:00 +02:00
|
|
|
|
|
|
|
GM_Manager* m_manager;
|
2013-04-02 13:14:19 +02:00
|
|
|
DelayedFileWatcher* m_fileWatcher;
|
2012-07-11 18:30:00 +02:00
|
|
|
|
|
|
|
QString m_name;
|
|
|
|
QString m_namespace;
|
|
|
|
QString m_description;
|
|
|
|
QString m_version;
|
|
|
|
|
2013-02-26 12:56:11 +01:00
|
|
|
QVector<GM_UrlMatcher> m_include;
|
|
|
|
QVector<GM_UrlMatcher> m_exclude;
|
2012-07-11 18:30:00 +02:00
|
|
|
|
|
|
|
QUrl m_downloadUrl;
|
|
|
|
StartAt m_startAt;
|
|
|
|
|
|
|
|
QString m_script;
|
|
|
|
QString m_fileName;
|
|
|
|
bool m_enabled;
|
|
|
|
bool m_valid;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // GM_SCRIPT_H
|