From b1965dd44c3ecc25e567b43d3ae1c998bf25cd49 Mon Sep 17 00:00:00 2001 From: Julian Depetris Chauvin Date: Sun, 8 May 2011 18:19:08 -0300 Subject: [PATCH] Add a "Enable web plugins" option under Edit > Preferences > Network. It allows to listen to sound pronunciations from online dictionaries that rely on flash plugin such as howjsay.com and dictionary.com. Plugin must be installed for this option to work. See http://doc.trolltech.com/4.5/qtwebkit.html#netscape-plugin-support --- config.cc | 8 ++++++++ config.hh | 1 + mainwindow.cc | 8 ++++++++ mainwindow.hh | 1 + preferences.cc | 2 ++ preferences.ui | 12 ++++++++++++ 6 files changed, 32 insertions(+) diff --git a/config.cc b/config.cc index f87276a3..816b0726 100644 --- a/config.cc +++ b/config.cc @@ -110,6 +110,7 @@ Preferences::Preferences(): #endif checkForNewReleases( true ), disallowContentFromOtherSites( false ), + enableWebPlugins( false ), zoomFactor( 1 ), wordsZoomLevel( 0 ) { @@ -585,6 +586,9 @@ Class load() throw( exError ) if ( !preferences.namedItem( "disallowContentFromOtherSites" ).isNull() ) c.preferences.disallowContentFromOtherSites = ( preferences.namedItem( "disallowContentFromOtherSites" ).toElement().text() == "1" ); + + if ( !preferences.namedItem( "enableWebPlugins" ).isNull() ) + c.preferences.enableWebPlugins = ( preferences.namedItem( "enableWebPlugins" ).toElement().text() == "1" ); } c.lastMainGroupId = root.namedItem( "lastMainGroupId" ).toElement().text().toUInt(); @@ -1071,6 +1075,10 @@ void save( Class const & c ) throw( exError ) opt = dd.createElement( "disallowContentFromOtherSites" ); opt.appendChild( dd.createTextNode( c.preferences.disallowContentFromOtherSites ? "1" : "0" ) ); preferences.appendChild( opt ); + + opt = dd.createElement( "enableWebPlugins" ); + opt.appendChild( dd.createTextNode( c.preferences.enableWebPlugins ? "1" : "0" ) ); + preferences.appendChild( opt ); } { diff --git a/config.hh b/config.hh index 1b9b83e8..3fd01034 100644 --- a/config.hh +++ b/config.hh @@ -168,6 +168,7 @@ struct Preferences bool checkForNewReleases; bool disallowContentFromOtherSites; + bool enableWebPlugins; qreal zoomFactor; int wordsZoomLevel; diff --git a/mainwindow.cc b/mainwindow.cc index 52ec36db..6d91cee9 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -354,6 +354,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ): restoreState( cfg.mainWindowState, 1 ); applyProxySettings(); + applyWebSettings(); makeDictionaries(); @@ -594,6 +595,12 @@ void MainWindow::applyProxySettings() QNetworkProxy::setApplicationProxy( proxy ); } +void MainWindow::applyWebSettings() +{ + QWebSettings *defaultSettings = QWebSettings::globalSettings(); + defaultSettings->setAttribute(QWebSettings::PluginsEnabled, cfg.preferences.enableWebPlugins); +} + void MainWindow::makeDictionaries() { scanPopup.reset(); @@ -1042,6 +1049,7 @@ void MainWindow::editPreferences() updateTrayIcon(); applyProxySettings(); + applyWebSettings(); makeScanPopup(); setAutostart( cfg.preferences.autoStart ); diff --git a/mainwindow.hh b/mainwindow.hh index 23387cae..ce7fdb6b 100644 --- a/mainwindow.hh +++ b/mainwindow.hh @@ -109,6 +109,7 @@ private: void closeEvent( QCloseEvent * ); void applyProxySettings(); + void applyWebSettings(); void makeDictionaries(); void updateStatusLine(); void updateGroupList(); diff --git a/preferences.cc b/preferences.cc index d5cfb4c5..66d54b09 100644 --- a/preferences.cc +++ b/preferences.cc @@ -176,6 +176,7 @@ Preferences::Preferences( QWidget * parent, Config::Preferences const & p ): ui.checkForNewReleases->setChecked( p.checkForNewReleases ); ui.disallowContentFromOtherSites->setChecked( p.disallowContentFromOtherSites ); + ui.enableWebPlugins->setChecked( p.enableWebPlugins ); } Config::Preferences Preferences::getPreferences() @@ -242,6 +243,7 @@ Config::Preferences Preferences::getPreferences() p.checkForNewReleases = ui.checkForNewReleases->isChecked(); p.disallowContentFromOtherSites = ui.disallowContentFromOtherSites->isChecked(); + p.enableWebPlugins = ui.enableWebPlugins->isChecked(); return p; } diff --git a/preferences.ui b/preferences.ui index 48de096c..b9e18345 100644 --- a/preferences.ui +++ b/preferences.ui @@ -951,6 +951,18 @@ you are browsing. If some site breaks because of this, try disabling this. + + + + Enabling this would allow to listen to sound pronunciations from +online dictionaries that rely on Flash or other web plugins. +Plugin must be installed for this option to work. + + + Enable web plugins + + +