diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2010-04-25 02:14:04 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2010-04-25 02:14:04 +0200 |
commit | 50d2f90b32782c0712a59eed16f7b0b2778dc7ab (patch) | |
tree | 7df91c77e152b6ce74d70ddd8f287d5b6521b476 /src/application.cpp | |
parent | Network Access Manager, first improvements (diff) | |
download | rekonq-50d2f90b32782c0712a59eed16f7b0b2778dc7ab.tar.xz |
Various changes
- moved updateCOnfiguration slot to Application class from MainWindow (its right place)
- loaded conf out of ctor (this will increase boot speed, but could in theory let rekonq fails on first load. We'll see..)
- set accept-language (raw) header. RFC 2626, section 14. Choose your preferred language.
- Try fixing CacheControl values (rekonq seems work quite well offline, now)
Diffstat (limited to 'src/application.cpp')
-rw-r--r-- | src/application.cpp | 77 |
1 files changed, 76 insertions, 1 deletions
diff --git a/src/application.cpp b/src/application.cpp index 45d115ae..b28055f7 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -44,6 +44,7 @@ #include "adblockmanager.h" #include "webview.h" #include "filterurljob.h" +#include "tabbar.h" // KDE Includes #include <KCmdLineArgs> @@ -182,7 +183,10 @@ Application *Application::instance() void Application::postLaunch() -{ +{ + // updating rekonq configuration + updateConfiguration(); + setWindowIcon(KIcon("rekonq")); // set Icon Database Path to store "favicons" associated with web sites @@ -392,3 +396,74 @@ void Application::newWindow() loadUrl( KUrl("about:home"), Rekonq::NewWindow ); mainWindow()->mainView()->urlBarWidget()->setFocus(); } + + +void Application::updateConfiguration() +{ + MainView *view = mainWindow()->mainView(); + + // ============== General ================== + view->updateTabBar(); + + // ============== Tabs ================== + if (ReKonfig::closeTabSelectPrevious()) + view->tabBar()->setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab); + else + view->tabBar()->setSelectionBehaviorOnRemove(QTabBar::SelectRightTab); + + // =========== Fonts ============== + QWebSettings *defaultSettings = QWebSettings::globalSettings(); + + int fnSize = ReKonfig::fontSize(); + int minFnSize = ReKonfig::minFontSize(); + + QFont standardFont = ReKonfig::standardFont(); + defaultSettings->setFontFamily(QWebSettings::StandardFont, standardFont.family()); + defaultSettings->setFontSize(QWebSettings::DefaultFontSize, fnSize); + defaultSettings->setFontSize(QWebSettings::MinimumFontSize, minFnSize); + + QFont fixedFont = ReKonfig::fixedFont(); + defaultSettings->setFontFamily(QWebSettings::FixedFont, fixedFont.family()); + defaultSettings->setFontSize(QWebSettings::DefaultFixedFontSize, fnSize); + + // ================ WebKit ============================ + defaultSettings->setAttribute(QWebSettings::AutoLoadImages, ReKonfig::autoLoadImages()); + defaultSettings->setAttribute(QWebSettings::DnsPrefetchEnabled, ReKonfig::dnsPrefetch()); + defaultSettings->setAttribute(QWebSettings::JavascriptEnabled, ReKonfig::javascriptEnabled()); + defaultSettings->setAttribute(QWebSettings::JavaEnabled, ReKonfig::javaEnabled()); + defaultSettings->setAttribute(QWebSettings::JavascriptCanOpenWindows, ReKonfig::javascriptCanOpenWindows()); + defaultSettings->setAttribute(QWebSettings::JavascriptCanAccessClipboard, ReKonfig::javascriptCanAccessClipboard()); + defaultSettings->setAttribute(QWebSettings::LinksIncludedInFocusChain, ReKonfig::linksIncludedInFocusChain()); + defaultSettings->setAttribute(QWebSettings::ZoomTextOnly, ReKonfig::zoomTextOnly()); + defaultSettings->setAttribute(QWebSettings::PrintElementBackgrounds, ReKonfig::printElementBackgrounds()); + + if(ReKonfig::pluginsEnabled() == 2) + defaultSettings->setAttribute(QWebSettings::PluginsEnabled, false); + else + defaultSettings->setAttribute(QWebSettings::PluginsEnabled, true); + + // ===== HTML 5 features WebKit support ====== + defaultSettings->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, ReKonfig::offlineStorageDatabaseEnabled()); + defaultSettings->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, ReKonfig::offlineWebApplicationCacheEnabled()); + defaultSettings->setAttribute(QWebSettings::LocalStorageEnabled, ReKonfig::localStorageEnabled()); + if(ReKonfig::localStorageEnabled()) + { + QString path = KStandardDirs::locateLocal("cache", QString("WebkitLocalStorage/rekonq"), true); + path.remove("rekonq"); + QWebSettings::setOfflineStoragePath(path); + QWebSettings::setOfflineStorageDefaultQuota(50000); + } + + // Applies user defined CSS to all open webpages. If there no longer is a + // user defined CSS removes it from all open webpages. + if(ReKonfig::userCSS().isEmpty()) + defaultSettings->setUserStyleSheetUrl( KUrl(KStandardDirs::locate("appdata" , "default.css")) ); + else + defaultSettings->setUserStyleSheetUrl(ReKonfig::userCSS()); + + // ====== load Settings on main classes + Application::historyManager()->loadSettings(); + Application::adblockManager()->loadSettings(); + + defaultSettings = 0; +} |