diff --git a/resources/graphics/icons/mini-kfaenza/web-flash.png b/resources/graphics/icons/mini-kfaenza/web-flash.png
new file mode 100644
index 000000000..a1dbd06b4
Binary files /dev/null and b/resources/graphics/icons/mini-kfaenza/web-flash.png differ
diff --git a/resources/graphics/icons/mini-kfaenza/web-javascript.png b/resources/graphics/icons/mini-kfaenza/web-javascript.png
new file mode 100644
index 000000000..03bf3b2d4
Binary files /dev/null and b/resources/graphics/icons/mini-kfaenza/web-javascript.png differ
diff --git a/resources/text/CHANGELOG b/resources/text/CHANGELOG
index 85f73d58b..6b55bd1e9 100644
--- a/resources/text/CHANGELOG
+++ b/resources/text/CHANGELOG
@@ -8,6 +8,7 @@ Fixed:
Added:
+- User can enable/disable web browser javascript, external plugins and images auto-loading (bug #9).
- Custom counts of messages in feed list (issue #14) are now changeable.
- Feed list categories expand status is now persistent.
- System-wide external web browser can now be used.
diff --git a/src/core/webfactory.cpp b/src/core/webfactory.cpp
index cdfb12e06..bba6ea695 100644
--- a/src/core/webfactory.cpp
+++ b/src/core/webfactory.cpp
@@ -1,18 +1,67 @@
#include "core/webfactory.h"
+#include "core/defs.h"
+#include "core/settings.h"
+
#include
#include
+#include
QPointer WebFactory::s_instance;
WebFactory::WebFactory(QObject *parent) : QObject(parent) {
+ m_globalSettings = QWebSettings::globalSettings();
}
WebFactory::~WebFactory() {
qDebug("Destroying WebFactory instance.");
}
+void WebFactory::loadState() {
+ Settings *settings = Settings::instance();
+
+ switchJavascript(settings->value(APP_CFG_BROWSER, "enable_javascript", true).toBool(),
+ false);
+ switchImages(settings->value(APP_CFG_BROWSER, "enable_images", true).toBool(),
+ false);
+ switchPlugins(settings->value(APP_CFG_BROWSER, "enable_plugins", false).toBool(),
+ false);
+}
+
+void WebFactory::switchJavascript(bool enable, bool save_settings) {
+ if (save_settings) {
+ Settings::instance()->setValue(APP_CFG_BROWSER,
+ "enable_javascript",
+ enable);
+ }
+
+ m_globalSettings->setAttribute(QWebSettings::JavascriptEnabled, enable);
+ emit javascriptSwitched(enable);
+}
+
+void WebFactory::switchPlugins(bool enable, bool save_settings) {
+ if (save_settings) {
+ Settings::instance()->setValue(APP_CFG_BROWSER,
+ "enable_plugins",
+ enable);
+ }
+
+ m_globalSettings->setAttribute(QWebSettings::PluginsEnabled, enable);
+ emit pluginsSwitched(enable);
+}
+
+void WebFactory::switchImages(bool enable, bool save_settings) {
+ if (save_settings) {
+ Settings::instance()->setValue(APP_CFG_BROWSER,
+ "enable_images",
+ enable);
+ }
+
+ m_globalSettings->setAttribute(QWebSettings::AutoLoadImages, enable);
+ emit imagesLoadingSwitched(enable);
+}
+
WebFactory *WebFactory::instance() {
if (s_instance.isNull()) {
s_instance = new WebFactory(qApp);
@@ -21,6 +70,18 @@ WebFactory *WebFactory::instance() {
return s_instance;
}
+bool WebFactory::javascriptEnabled() const {
+ return m_globalSettings->testAttribute(QWebSettings::JavascriptEnabled);
+}
+
+bool WebFactory::pluginsEnabled() const {
+ return m_globalSettings->testAttribute(QWebSettings::PluginsEnabled);
+}
+
+bool WebFactory::autoloadImages() const {
+ return m_globalSettings->testAttribute(QWebSettings::AutoLoadImages);
+}
+
QString WebFactory::stripTags(QString text) {
return text.remove(QRegExp("<[^>]*>"));
}
diff --git a/src/core/webfactory.h b/src/core/webfactory.h
index c49206f75..a3f952459 100644
--- a/src/core/webfactory.h
+++ b/src/core/webfactory.h
@@ -6,6 +6,8 @@
#include
+class QWebSettings;
+
class WebFactory : public QObject {
Q_OBJECT
@@ -13,6 +15,11 @@ class WebFactory : public QObject {
// Destructor.
virtual ~WebFactory();
+ // Loads the web settings directly from
+ // application settings and notifies the rest of
+ // the world about current situation.
+ void loadState();
+
// Strips "<....>" (HTML, XML) tags from given text.
QString stripTags(QString text);
@@ -24,6 +31,16 @@ class WebFactory : public QObject {
// Singleton getter.
static WebFactory *instance();
+ public slots:
+ // Operations.
+ bool javascriptEnabled() const;
+ bool pluginsEnabled() const;
+ bool autoloadImages() const;
+
+ void switchJavascript(bool enable, bool save_settings = true);
+ void switchPlugins(bool enable, bool save_settings = true);
+ void switchImages(bool enable, bool save_settings = true);
+
signals:
void javascriptSwitched(bool enabled);
void pluginsSwitched(bool enabled);
@@ -37,6 +54,8 @@ class WebFactory : public QObject {
QMap generetaEscapes();
QMap generateDeescapes();
+ QWebSettings *m_globalSettings;
+
// Singleton.
static QPointer s_instance;
};
diff --git a/src/gui/formmain.cpp b/src/gui/formmain.cpp
index eaea0c32f..3f10478b0 100755
--- a/src/gui/formmain.cpp
+++ b/src/gui/formmain.cpp
@@ -21,6 +21,7 @@
#include "core/settings.h"
#include "core/systemfactory.h"
#include "core/databasefactory.h"
+#include "core/webfactory.h"
#include "gui/formabout.h"
#include "gui/formsettings.h"
#include "gui/feedsview.h"
@@ -71,8 +72,12 @@ FormMain::FormMain(QWidget *parent)
// Prepare tabs.
m_ui->m_tabWidget->initializeTabs();
+ // Setup some appearance of the window.
setupIcons();
loadSize();
+
+ // Initialize the web factory.
+ WebFactory::instance()->loadState();
}
FormMain::~FormMain() {
@@ -271,6 +276,10 @@ void FormMain::setupIcons() {
m_ui->m_actionCloseCurrentTab->setIcon(icon_theme_factory->fromTheme("list-remove"));
m_ui->m_actionCloseAllTabs->setIcon(icon_theme_factory->fromTheme("list-remove"));
m_ui->m_menuCurrentTab->setIcon(icon_theme_factory->fromTheme("list-current"));
+ m_ui->m_menuWebSettings->setIcon(icon_theme_factory->fromTheme("application-settings"));
+ m_ui->m_actionWebAutoloadImages->setIcon(icon_theme_factory->fromTheme("image-generic"));
+ m_ui->m_actionWebEnableExternalPlugins->setIcon(icon_theme_factory->fromTheme("web-flash"));
+ m_ui->m_actionWebEnableJavascript->setIcon(icon_theme_factory->fromTheme("web-javascript"));
// Feeds/messages.
m_ui->m_menuAddItem->setIcon(icon_theme_factory->fromTheme("item-new"));
@@ -381,6 +390,18 @@ void FormMain::createConnections() {
m_ui->m_tabWidget, SLOT(addEmptyBrowser()));
connect(m_ui->m_actionCloseAllTabs, SIGNAL(triggered()),
m_ui->m_tabWidget, SLOT(closeAllTabsExceptCurrent()));
+ connect(WebFactory::instance(), SIGNAL(imagesLoadingSwitched(bool)),
+ m_ui->m_actionWebAutoloadImages, SLOT(setChecked(bool)));
+ connect(WebFactory::instance(), SIGNAL(javascriptSwitched(bool)),
+ m_ui->m_actionWebEnableJavascript, SLOT(setChecked(bool)));
+ connect(WebFactory::instance(), SIGNAL(pluginsSwitched(bool)),
+ m_ui->m_actionWebEnableExternalPlugins, SLOT(setChecked(bool)));
+ connect(m_ui->m_actionWebAutoloadImages, SIGNAL(toggled(bool)),
+ WebFactory::instance(), SLOT(switchImages(bool)));
+ connect(m_ui->m_actionWebEnableExternalPlugins, SIGNAL(toggled(bool)),
+ WebFactory::instance(), SLOT(switchPlugins(bool)));
+ connect(m_ui->m_actionWebEnableJavascript, SIGNAL(toggled(bool)),
+ WebFactory::instance(), SLOT(switchJavascript(bool)));
}
void FormMain::loadWebBrowserMenu(int index) {
diff --git a/src/gui/formmain.ui b/src/gui/formmain.ui
index 56dd12054..4b7949e53 100644
--- a/src/gui/formmain.ui
+++ b/src/gui/formmain.ui
@@ -15,16 +15,7 @@
-
- 0
-
-
- 0
-
-
- 0
-
-
+
0
-
@@ -48,7 +39,7 @@
0
0
979
- 21
+ 20
+
+
diff --git a/src/gui/formsettings.cpp b/src/gui/formsettings.cpp
index 24a33193e..db532800a 100755
--- a/src/gui/formsettings.cpp
+++ b/src/gui/formsettings.cpp
@@ -22,6 +22,7 @@
#include "core/databasefactory.h"
#include "core/localization.h"
#include "core/systemfactory.h"
+#include "core/webfactory.h"
#include "core/feeddownloader.h"
#include "core/dynamicshortcuts.h"
#include "core/webbrowsernetworkaccessmanager.h"
@@ -362,6 +363,9 @@ void FormSettings::loadBrowser() {
m_ui->m_grpCustomExternalBrowser->setChecked(settings->value(APP_CFG_BROWSER,
"custom_external_browser",
false).toBool());
+ m_ui->m_checkAutoLoadImages->setChecked(WebFactory::instance()->autoloadImages());
+ m_ui->m_checkEnableJavascript->setChecked(WebFactory::instance()->javascriptEnabled());
+ m_ui->m_checkEnablePlugins->setChecked(WebFactory::instance()->pluginsEnabled());
}
void FormSettings::saveBrowser() {
@@ -384,6 +388,10 @@ void FormSettings::saveBrowser() {
"queue_tabs",
m_ui->m_checkQueueTabs->isChecked());
+ WebFactory::instance()->switchImages(m_ui->m_checkAutoLoadImages->isChecked());
+ WebFactory::instance()->switchJavascript(m_ui->m_checkEnableJavascript->isChecked());
+ WebFactory::instance()->switchPlugins(m_ui->m_checkEnablePlugins->isChecked());
+
settings->setValue(APP_CFG_BROWSER,
"external_browser_executable",
m_ui->m_txtExternalBrowserExecutable->text());
diff --git a/src/gui/formsettings.ui b/src/gui/formsettings.ui
index 34c67bbd7..78a555bb8 100644
--- a/src/gui/formsettings.ui
+++ b/src/gui/formsettings.ui
@@ -17,7 +17,7 @@
-
- 6
+ 0
@@ -286,8 +286,8 @@ Authors of this application are NOT responsible for lost data.
0
0
- 100
- 30
+ 564
+ 364
@@ -364,8 +364,8 @@ Authors of this application are NOT responsible for lost data.
0
0
- 209
- 245
+ 560
+ 336
@@ -643,15 +643,15 @@ Authors of this application are NOT responsible for lost data.
QFormLayout::AllNonFixedFieldsGrow
-
-
+
-
Mouse gestures work with middle mouse button. Possible gestures are:
<ul>
-<li>previous web page (drag mouse left)</li>
-<li>next web page (drag mouse right)</li>
-<li>reload current web page (drag mouse up)</li>
-<li>open new web browser tab (drag mouse down)</li>
+<li>previous web page (drag mouse left),</li>
+<li>next web page (drag mouse right),</li>
+<li>reload current web page (drag mouse up),</li>
+<li>open new web browser tab (drag mouse down).</li>
</ul>
@@ -662,7 +662,7 @@ Authors of this application are NOT responsible for lost data.
- -
+
-
Enable mouse gestures
@@ -706,6 +706,27 @@ Authors of this application are NOT responsible for lost data.
+ -
+
+
+ Enable JavaScript
+
+
+
+ -
+
+
+ Enable external plugins based on NPAPI
+
+
+
+ -
+
+
+ Auto-load images
+
+
+
@@ -1049,13 +1070,26 @@ Authors of this application are NOT responsible for lost data.
-
- Enter format for count of messages displayed next to each feed/category in feed list. Use "%all" and "%unread" placeholders.
+
true
+ -
+
+
+ Enter format for count of messages displayed next to each feed/category in feed list. Use "%all" and "%unread" strings which are placeholders for the actual count of all (or unread) messages.
+
+
+ Qt::AlignCenter
+
+
+ true
+
+
+