mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 09:32:12 +01:00
[StatusBarIcons] Added JavaScript icon to manage JavaScript settings.
This commit is contained in:
parent
5e929d764f
commit
9725f53bbf
|
@ -85,9 +85,6 @@ public:
|
|||
|
||||
void showNavigationBar(QWidget* bar);
|
||||
|
||||
WebTab* weTab();
|
||||
WebTab* weTab(int index);
|
||||
|
||||
TabBar* getTabBar() const;
|
||||
ClosedTabsManager* closedTabsManager() const;
|
||||
QList<WebTab*> allTabs(bool withPinned = true);
|
||||
|
@ -134,6 +131,9 @@ private slots:
|
|||
void tabMoved(int before, int after);
|
||||
|
||||
private:
|
||||
WebTab* weTab();
|
||||
WebTab* weTab(int index);
|
||||
|
||||
inline bool validIndex(int index) const { return index >= 0 && index < count(); }
|
||||
|
||||
void tabInserted(int index);
|
||||
|
|
|
@ -4,11 +4,13 @@ TARGET = $$qtLibraryTarget(StatusBarIcons)
|
|||
|
||||
SOURCES += statusbariconsplugin.cpp \
|
||||
sbi_iconsmanager.cpp \
|
||||
sbi_imagesicon.cpp
|
||||
sbi_imagesicon.cpp \
|
||||
sbi_javascripticon.cpp
|
||||
|
||||
HEADERS += statusbariconsplugin.h \
|
||||
sbi_iconsmanager.h \
|
||||
sbi_imagesicon.h
|
||||
sbi_imagesicon.h \
|
||||
sbi_javascripticon.h
|
||||
|
||||
RESOURCES += statusbaricons.qrc
|
||||
|
||||
|
|
BIN
src/plugins/StatusBarIcons/data/javascript.png
Normal file
BIN
src/plugins/StatusBarIcons/data/javascript.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 680 B |
|
@ -17,6 +17,7 @@
|
|||
* ============================================================ */
|
||||
#include "sbi_iconsmanager.h"
|
||||
#include "sbi_imagesicon.h"
|
||||
#include "sbi_javascripticon.h"
|
||||
#include "qupzilla.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
@ -66,7 +67,6 @@ void SBI_IconsManager::destroyIcons()
|
|||
|
||||
void SBI_IconsManager::mainWindowCreated(QupZilla* window)
|
||||
{
|
||||
typedef QWidget SBI_JavaScriptIcon;
|
||||
typedef QWidget SBI_NetworkIcon;
|
||||
|
||||
if (m_showImagesIcon) {
|
||||
|
@ -76,7 +76,7 @@ void SBI_IconsManager::mainWindowCreated(QupZilla* window)
|
|||
}
|
||||
|
||||
if (m_showJavaScriptIcon) {
|
||||
SBI_JavaScriptIcon* w = new SBI_JavaScriptIcon;
|
||||
SBI_JavaScriptIcon* w = new SBI_JavaScriptIcon(window);
|
||||
window->statusBar()->addPermanentWidget(w);
|
||||
m_windows[window].append(w);
|
||||
}
|
||||
|
|
|
@ -57,7 +57,6 @@ void SBI_ImagesIcon::showMenu(const QPoint &point)
|
|||
boldFont.setBold(true);
|
||||
|
||||
QMenu menu;
|
||||
|
||||
menu.addAction(m_icon, tr("Current page settings"))->setFont(boldFont);
|
||||
|
||||
if (currentPageSettings()->testAttribute(QWebSettings::AutoLoadImages)) {
|
||||
|
@ -85,7 +84,7 @@ void SBI_ImagesIcon::toggleLoadingImages()
|
|||
|
||||
// We should reload page on disabling images
|
||||
if (current) {
|
||||
p_QupZilla->tabWidget()->weTab()->reload();
|
||||
p_QupZilla->weView()->reload();
|
||||
}
|
||||
|
||||
updateIcon();
|
||||
|
@ -105,13 +104,13 @@ void SBI_ImagesIcon::setGlobalLoadingImages(bool enable)
|
|||
|
||||
// We should reload page on disabling images
|
||||
if (!enable) {
|
||||
p_QupZilla->tabWidget()->weTab()->reload();
|
||||
p_QupZilla->weView()->reload();
|
||||
}
|
||||
}
|
||||
|
||||
QWebSettings* SBI_ImagesIcon::currentPageSettings()
|
||||
{
|
||||
return p_QupZilla->tabWidget()->weTab()->view()->page()->settings();
|
||||
return p_QupZilla->weView()->page()->settings();
|
||||
}
|
||||
|
||||
void SBI_ImagesIcon::updateIcon()
|
||||
|
|
95
src/plugins/StatusBarIcons/sbi_javascripticon.cpp
Normal file
95
src/plugins/StatusBarIcons/sbi_javascripticon.cpp
Normal file
|
@ -0,0 +1,95 @@
|
|||
/* ============================================================
|
||||
* StatusBarIcons - Extra icons in statusbar 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 "sbi_javascripticon.h"
|
||||
#include "qupzilla.h"
|
||||
#include "tabwidget.h"
|
||||
#include "tabbedwebview.h"
|
||||
#include "webpage.h"
|
||||
#include "jsoptions.h"
|
||||
|
||||
#include <QGraphicsColorizeEffect>
|
||||
#include <QWebSettings>
|
||||
#include <QMenu>
|
||||
|
||||
SBI_JavaScriptIcon::SBI_JavaScriptIcon(QupZilla* window)
|
||||
: ClickableLabel(window)
|
||||
, p_QupZilla(window)
|
||||
{
|
||||
setCursor(Qt::PointingHandCursor);
|
||||
setToolTip(tr("Modify JavaScript settings per-site and globally"));
|
||||
|
||||
m_icon = QIcon::fromTheme("application-x-javascript", QIcon(":sbi/data/javascript.png"));
|
||||
setPixmap(m_icon.pixmap(16));
|
||||
|
||||
connect(p_QupZilla->tabWidget(), SIGNAL(currentChanged(int)), this, SLOT(updateIcon()));
|
||||
connect(this, SIGNAL(clicked(QPoint)), this, SLOT(showMenu(QPoint)));
|
||||
}
|
||||
|
||||
void SBI_JavaScriptIcon::showMenu(const QPoint &point)
|
||||
{
|
||||
QFont boldFont = font();
|
||||
boldFont.setBold(true);
|
||||
|
||||
QMenu menu;
|
||||
menu.addAction(m_icon, tr("Current page settings"))->setFont(boldFont);
|
||||
|
||||
if (currentPageSettings()->testAttribute(QWebSettings::JavascriptEnabled)) {
|
||||
menu.addAction(tr("Disable JavaScript (temporarily)"), this, SLOT(toggleJavaScript()));
|
||||
}
|
||||
else {
|
||||
menu.addAction(tr("Enable JavaScript (temporarily)"), this, SLOT(toggleJavaScript()));
|
||||
}
|
||||
|
||||
menu.addSeparator();
|
||||
menu.addAction(m_icon, tr("Global settings"))->setFont(boldFont);
|
||||
menu.addAction(tr("Manage JavaScript settings"), this, SLOT(openJavaScriptSettings()));
|
||||
menu.exec(point);
|
||||
}
|
||||
|
||||
void SBI_JavaScriptIcon::updateIcon()
|
||||
{
|
||||
if (currentPageSettings()->testAttribute(QWebSettings::JavascriptEnabled)) {
|
||||
setGraphicsEffect(0);
|
||||
}
|
||||
else {
|
||||
QGraphicsColorizeEffect* effect = new QGraphicsColorizeEffect(this);
|
||||
effect->setColor(Qt::gray);
|
||||
setGraphicsEffect(effect);
|
||||
}
|
||||
}
|
||||
|
||||
void SBI_JavaScriptIcon::toggleJavaScript()
|
||||
{
|
||||
bool current = currentPageSettings()->testAttribute(QWebSettings::JavascriptEnabled);
|
||||
currentPageSettings()->setAttribute(QWebSettings::JavascriptEnabled, !current);
|
||||
|
||||
p_QupZilla->weView()->reload();
|
||||
|
||||
updateIcon();
|
||||
}
|
||||
|
||||
void SBI_JavaScriptIcon::openJavaScriptSettings()
|
||||
{
|
||||
JsOptions dialog(p_QupZilla);
|
||||
dialog.exec();
|
||||
}
|
||||
|
||||
QWebSettings* SBI_JavaScriptIcon::currentPageSettings()
|
||||
{
|
||||
return p_QupZilla->weView()->page()->settings();
|
||||
}
|
50
src/plugins/StatusBarIcons/sbi_javascripticon.h
Normal file
50
src/plugins/StatusBarIcons/sbi_javascripticon.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
/* ============================================================
|
||||
* StatusBarIcons - Extra icons in statusbar 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 SBI_JAVASCRIPTICON_H
|
||||
#define SBI_JAVASCRIPTICON_H
|
||||
|
||||
#include <QIcon>
|
||||
|
||||
#include "clickablelabel.h"
|
||||
|
||||
class QWebSettings;
|
||||
|
||||
class QupZilla;
|
||||
|
||||
class SBI_JavaScriptIcon : public ClickableLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SBI_JavaScriptIcon(QupZilla* window);
|
||||
|
||||
private slots:
|
||||
void showMenu(const QPoint &point);
|
||||
void updateIcon();
|
||||
|
||||
void toggleJavaScript();
|
||||
void openJavaScriptSettings();
|
||||
|
||||
private:
|
||||
QWebSettings* currentPageSettings();
|
||||
|
||||
QupZilla* p_QupZilla;
|
||||
QIcon m_icon;
|
||||
};
|
||||
|
||||
#endif // SBI_JAVASCRIPTICON_H
|
|
@ -2,5 +2,6 @@
|
|||
<qresource prefix="/sbi">
|
||||
<file>data/icon.png</file>
|
||||
<file>data/images.png</file>
|
||||
<file>data/javascript.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -34,7 +34,7 @@ PluginSpec StatusBarIconsPlugin::pluginSpec()
|
|||
spec.name = "StatusBar Icons";
|
||||
spec.info = "Icons in statusbar providing various actions";
|
||||
spec.description = "Adds additional icons to statusbar";
|
||||
spec.version = "0.1.0";
|
||||
spec.version = "0.1.5";
|
||||
spec.author = "David Rosca <nowrep@gmail.com>";
|
||||
spec.icon = QPixmap(":sbi/data/icon.png");
|
||||
spec.hasSettings = false;
|
||||
|
|
|
@ -4,34 +4,67 @@
|
|||
<context>
|
||||
<name>SBI_ImagesIcon</name>
|
||||
<message>
|
||||
<location filename="../sbi_imagesicon.cpp" line="37"/>
|
||||
<location filename="../sbi_imagesicon.cpp" line="36"/>
|
||||
<source>Modify images loading settings per-site and globally</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../sbi_imagesicon.cpp" line="57"/>
|
||||
<location filename="../sbi_imagesicon.cpp" line="60"/>
|
||||
<source>Current page settings</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../sbi_imagesicon.cpp" line="60"/>
|
||||
<location filename="../sbi_imagesicon.cpp" line="63"/>
|
||||
<source>Disable loading images (temporarily)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../sbi_imagesicon.cpp" line="63"/>
|
||||
<location filename="../sbi_imagesicon.cpp" line="66"/>
|
||||
<source>Enable loading images (temporarily)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../sbi_imagesicon.cpp" line="67"/>
|
||||
<location filename="../sbi_imagesicon.cpp" line="70"/>
|
||||
<source>Global settings</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../sbi_imagesicon.cpp" line="69"/>
|
||||
<location filename="../sbi_imagesicon.cpp" line="72"/>
|
||||
<source>Automatically load images</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SBI_JavaScriptIcon</name>
|
||||
<message>
|
||||
<location filename="../sbi_javascripticon.cpp" line="34"/>
|
||||
<source>Modify JavaScript settings per-site and globally</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../sbi_javascripticon.cpp" line="49"/>
|
||||
<source>Current page settings</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../sbi_javascripticon.cpp" line="52"/>
|
||||
<source>Disable JavaScript (temporarily)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../sbi_javascripticon.cpp" line="55"/>
|
||||
<source>Enable JavaScript (temporarily)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../sbi_javascripticon.cpp" line="59"/>
|
||||
<source>Global settings</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../sbi_javascripticon.cpp" line="60"/>
|
||||
<source>Manage JavaScript settings</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
|
Loading…
Reference in New Issue
Block a user