summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/application.cpp77
-rw-r--r--src/application.h2
-rw-r--r--src/mainwindow.cpp75
-rw-r--r--src/mainwindow.h1
-rw-r--r--src/networkaccessmanager.cpp65
-rw-r--r--src/networkaccessmanager.h2
6 files changed, 118 insertions, 104 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;
+}
diff --git a/src/application.h b/src/application.h
index fe3c50c1..87d395eb 100644
--- a/src/application.h
+++ b/src/application.h
@@ -136,6 +136,8 @@ private slots:
void loadResolvedUrl(ThreadWeaver::Job *);
+ void updateConfiguration();
+
private:
static QWeakPointer<HistoryManager> s_historyManager;
static QWeakPointer<BookmarkProvider> s_bookmarkProvider;
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index fe00ee7e..03a6194a 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -113,9 +113,6 @@ MainWindow::MainWindow()
// enable window size "auto-save"
setAutoSaveSettings();
- // updating rekonq configuration
- updateConfiguration();
-
// creating a centralWidget containing panel, m_view and the hidden findbar
QWidget *centralWidget = new QWidget;
centralWidget->setContentsMargins(0, 0, 0, 0);
@@ -543,76 +540,6 @@ void MainWindow::setupPanels()
}
-
-void MainWindow::updateConfiguration()
-{
- // ============== General ==================
- m_view->updateTabBar();
-
- // ============== Tabs ==================
- if (ReKonfig::closeTabSelectPrevious())
- m_view->tabBar()->setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab);
- else
- m_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;
-}
-
-
void MainWindow::openLocation()
{
m_view->urlBar()->selectAll();
@@ -649,7 +576,7 @@ void MainWindow::preferences()
QPointer<SettingsDialog> s = new SettingsDialog(this);
// keep us informed when the user changes settings
- connect(s, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
+ connect(s, SIGNAL(settingsChanged(const QString&)), Application::instance(), SLOT(updateConfiguration()));
s->exec();
delete s;
diff --git a/src/mainwindow.h b/src/mainwindow.h
index d1509066..5c525e26 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -116,7 +116,6 @@ protected:
private slots:
void postLaunch();
- void updateConfiguration();
void browserLoading(bool);
void updateActions();
void updateWindowTitle(const QString &title = QString());
diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp
index 95b768d9..15a71317 100644
--- a/src/networkaccessmanager.cpp
+++ b/src/networkaccessmanager.cpp
@@ -36,54 +36,65 @@
// KDE Includes
#include <KDebug>
+#include <KLocale>
+#include <KProtocolManager>
+
+// Defines
+#define QL1S(x) QLatin1String(x)
NetworkAccessManager::NetworkAccessManager(QObject *parent)
: AccessManager(parent)
- , _parentPage( qobject_cast<WebPage *>(parent) )
{
+ QString c = KGlobal::locale()->country();
+ if(c == QL1S("C"))
+ c = QL1S("en_US");
+ if(c != QL1S("en_US"))
+ c.append( QL1S(", en_US") );
+
+ _acceptLanguage = c.toLatin1();
}
QNetworkReply *NetworkAccessManager::createRequest(Operation op, const QNetworkRequest &request, QIODevice *outgoingData)
{
+ WebPage *parentPage = qobject_cast<WebPage *>( parent() );
+
QNetworkReply *reply = 0;
QNetworkRequest req = request;
req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
- req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
-// if (!m_acceptLanguage.isEmpty())
-// req.setRawHeader("Accept-Language", m_acceptLanguage);
-
- switch(op)
+ req.setRawHeader("Accept-Language", _acceptLanguage);
+
+ KIO::CacheControl cc = KProtocolManager::cacheControl();
+ switch(cc)
{
- case QNetworkAccessManager::HeadOperation:
- kDebug() << "HEAD OPERATION";
- break;
-
- case QNetworkAccessManager::GetOperation:
- kDebug() << "GET OPERATION";
- reply = Application::adblockManager()->block(req, _parentPage);
- if (reply)
- return reply;
+ case KIO::CC_CacheOnly: // Fail request if not in cache.
+ req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysCache);
break;
-
- case QNetworkAccessManager::PutOperation:
- kDebug() << "PUT OPERATION";
- break;
-
- case QNetworkAccessManager::PostOperation:
- kDebug() << "POST OPERATION";
- break;
-
- case QNetworkAccessManager::DeleteOperation:
- kDebug() << "DELETE OPERATION";
+
+ case KIO::CC_Refresh: // Always validate cached entry with remote site.
+ req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork);
break;
+ case KIO::CC_Reload: // Always fetch from remote site
+ req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork);
+ break;
+
+ case KIO::CC_Cache: // Use cached entry if available.
+ case KIO::CC_Verify: // Validate cached entry with remote site if expired.
default:
- kDebug() << "UNKNOWN OPERATION";
+ req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
break;
}
+
+
+ if( op == QNetworkAccessManager::GetOperation )
+ {
+ reply = Application::adblockManager()->block(req, parentPage);
+ if (reply)
+ return reply;
+ }
return AccessManager::createRequest(op,req,outgoingData);
}
diff --git a/src/networkaccessmanager.h b/src/networkaccessmanager.h
index b2a111f8..cc7d800d 100644
--- a/src/networkaccessmanager.h
+++ b/src/networkaccessmanager.h
@@ -51,7 +51,7 @@ protected:
virtual QNetworkReply *createRequest(Operation op, const QNetworkRequest &request, QIODevice *outgoingData = 0);
private:
- WebPage *_parentPage;
+ QByteArray _acceptLanguage;
};
#endif // NETWORKACCESSMANAGER_H