1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-19 10:16:34 +01:00

[GreaseMonkey] Added icon to statusbar.

Closes #741
This commit is contained in:
nowrep 2013-06-02 19:09:41 +02:00
parent 0d10301ea7
commit 7b736ed9df
10 changed files with 115 additions and 5 deletions

View File

@ -12,6 +12,7 @@ Version 1.5.0
* pagescreen can now save output into number of formats, including PDF
* proxy exceptions now supports wildcards (*, ?)
* cancel upload when trying to upload non-readable files
* GreaseMonkey: added icon in statusbar
* GreaseMonkey: added support for GM_Settings
* GreaseMonkey: fixed userscripts when first loading plugin
* oxygen: set rounded corners for tooltips

View File

@ -14,7 +14,8 @@ SOURCES += gm_plugin.cpp \
settings/gm_settingslistdelegate.cpp \
settings/gm_settingsscriptinfo.cpp \
settings/gm_settingslistwidget.cpp \
gm_jsobject.cpp
gm_jsobject.cpp \
gm_icon.cpp
HEADERS += gm_plugin.h \
gm_manager.h \
@ -27,7 +28,8 @@ HEADERS += gm_plugin.h \
settings/gm_settingslistdelegate.h \
settings/gm_settingsscriptinfo.h \
settings/gm_settingslistwidget.h \
gm_jsobject.h
gm_jsobject.h \
gm_icon.h
FORMS += \
gm_addscriptdialog.ui \

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,37 @@
/* ============================================================
* GreaseMonkey plugin for QupZilla
* Copyright (C) 2013 David Rosca <nowrep@gmail.com>
*
* 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/>.
* ============================================================ */
#include "gm_icon.h"
#include "gm_manager.h"
#include "qupzilla.h"
GM_Icon::GM_Icon(GM_Manager* manager, QupZilla* window)
: ClickableLabel(window)
, m_manager(manager)
, m_window(window)
{
setCursor(Qt::PointingHandCursor);
setPixmap(QPixmap(":gm/data/icon18.png"));
setToolTip(tr("Open GreaseMonkey settings"));
connect(this, SIGNAL(clicked(QPoint)), this, SLOT(openSettings()));
}
void GM_Icon::openSettings()
{
m_manager->showSettings(m_window);
}

View File

@ -0,0 +1,41 @@
/* ============================================================
* GreaseMonkey plugin for QupZilla
* Copyright (C) 2013 David Rosca <nowrep@gmail.com>
*
* 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_ICON_H
#define GM_ICON_H
#include "clickablelabel.h"
class QupZilla;
class GM_Manager;
class GM_Icon : public ClickableLabel
{
Q_OBJECT
public:
explicit GM_Icon(GM_Manager* manager, QupZilla* window);
private slots:
void openSettings();
private:
GM_Manager* m_manager;
QupZilla* m_window;
};
#endif // GM_ICON_H

View File

@ -19,8 +19,10 @@
#include "gm_script.h"
#include "gm_downloader.h"
#include "gm_jsobject.h"
#include "gm_icon.h"
#include "settings/gm_settings.h"
#include "qupzilla.h"
#include "webpage.h"
#include "qztools.h"
#include "mainapplication.h"
@ -30,7 +32,7 @@
#include <QDir>
#include <QWebFrame>
#include <QSettings>
#include <QDebug>
#include <QStatusBar>
GM_Manager::GM_Manager(const QString &sPath, QObject* parent)
: QObject(parent)
@ -261,3 +263,17 @@ bool GM_Manager::canRunOnScheme(const QString &scheme)
return (scheme == QLatin1String("http") || scheme == QLatin1String("https")
|| scheme == QLatin1String("data") || scheme == QLatin1String("ftp"));
}
void GM_Manager::mainWindowCreated(QupZilla* window)
{
GM_Icon* icon = new GM_Icon(this, window);
window->statusBar()->addPermanentWidget(icon);
m_windows[window] = icon;
}
void GM_Manager::mainWindowDeleted(QupZilla* window)
{
window->statusBar()->removeWidget(m_windows[window]);
delete m_windows[window];
}

View File

@ -21,13 +21,16 @@
#include <QObject>
#include <QStringList>
#include <QPointer>
#include <QHash>
class QUrl;
class QNetworkRequest;
class QupZilla;
class GM_Script;
class GM_JSObject;
class GM_Settings;
class GM_Icon;
class GM_Manager : public QObject
{
@ -61,6 +64,9 @@ signals:
void scriptsChanged();
public slots:
void mainWindowCreated(QupZilla* window);
void mainWindowDeleted(QupZilla* window);
void pageLoadStart();
private slots:
@ -75,6 +81,8 @@ private:
GM_JSObject* m_jsObject;
QList<GM_Script*> m_endScripts;
QList<GM_Script*> m_startScripts;
QHash<QupZilla*, GM_Icon*> m_windows;
};
#endif // GM_MANAGER_H

View File

@ -41,7 +41,7 @@ PluginSpec GM_Plugin::pluginSpec()
spec.name = "GreaseMonkey";
spec.info = "Userscripts for QupZilla";
spec.description = "Provides support for userscripts (www.userscripts.org)";
spec.version = "0.3.2";
spec.version = "0.4.1";
spec.author = "David Rosca <nowrep@gmail.com>";
spec.icon = QPixmap(":gm/data/icon.png");
spec.hasSettings = true;
@ -55,10 +55,14 @@ void GM_Plugin::init(InitState state, const QString &settingsPath)
m_settingsPath = settingsPath;
connect(mApp->plugins(), SIGNAL(webPageCreated(WebPage*)), this, SLOT(webPageCreated(WebPage*)));
connect(mApp->plugins(), SIGNAL(mainWindowCreated(QupZilla*)), m_manager, SLOT(mainWindowCreated(QupZilla*)));
connect(mApp->plugins(), SIGNAL(mainWindowDeleted(QupZilla*)), m_manager, SLOT(mainWindowDeleted(QupZilla*)));
// Make sure userscripts works also with already created WebPages
if (state == LateInitState) {
foreach (QupZilla* window, mApp->mainWindows()) {
m_manager->mainWindowCreated(window);
for (int i = 0; i < window->tabWidget()->count(); ++i) {
WebTab* tab = qobject_cast<WebTab*>(window->tabWidget()->widget(i));
if (tab) {

View File

@ -18,5 +18,6 @@
<file>locale/sr_RS@latin.qm</file>
<file>locale/uk_UA.qm</file>
<file>locale/fa_IR.qm</file>
<file>data/icon18.png</file>
</qresource>
</RCC>

View File

@ -1,6 +1,6 @@
/* ============================================================
* GreaseMonkey plugin for QupZilla
* Copyright (C) 2012 David Rosca <nowrep@gmail.com>
* Copyright (C) 2012-2013 David Rosca <nowrep@gmail.com>
*
* 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