summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/application.cpp42
-rw-r--r--src/bookmarks.cpp12
-rw-r--r--src/bookmarks.h7
-rw-r--r--src/cookiejar.cpp3
-rw-r--r--src/lineedit.cpp1
-rw-r--r--src/main.cpp2
-rw-r--r--src/mainview.cpp14
-rw-r--r--src/mainview.h2
-rw-r--r--src/mainwindow.cpp22
-rw-r--r--src/networkaccessmanager.cpp17
-rw-r--r--src/networkaccessmanager.h6
-rw-r--r--src/rekonq.kcfg10
-rw-r--r--src/settings.cpp13
-rw-r--r--src/settings.h3
-rw-r--r--src/settings_general.ui58
-rw-r--r--src/settings_privacy.ui87
-rw-r--r--src/urlbar.cpp17
-rw-r--r--src/urlbar.h3
-rw-r--r--src/webpage.cpp141
-rw-r--r--src/webpage.h14
-rw-r--r--src/webview.cpp2
22 files changed, 248 insertions, 229 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ce7b1f8d..45a2afb2 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -30,7 +30,6 @@ KDE4_ADD_UI_FILES( rekonq_SRCS
proxy.ui
settings_general.ui
settings_fonts.ui
- settings_privacy.ui
settings_proxy.ui
settings_webkit.ui
cleardata.ui
diff --git a/src/application.cpp b/src/application.cpp
index df47a119..812081de 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -201,31 +201,26 @@ KUrl Application::guessUrlFromString(const QString &string)
QString urlStr = string.trimmed();
QRegExp test(QLatin1String("^[a-zA-Z]+\\:.*"));
+ // Might be a file.
+ if (QFile::exists(urlStr))
+ {
+ QFileInfo info(urlStr);
+ return KUrl::fromPath(info.absoluteFilePath());
+ }
+
// Check if it looks like a qualified URL. Try parsing it and see.
- bool hasSchema = test.exactMatch(urlStr);
-
- if (hasSchema)
+ if (test.exactMatch(urlStr))
{
- QUrl qurl(urlStr, QUrl::TolerantMode);
- KUrl url(qurl);
-
+ KUrl url(urlStr);
+
if (url.isValid())
{
return url;
}
}
-
- // Might be a file.
- if (QFile::exists(urlStr))
- {
- QFileInfo info(urlStr);
- return KUrl::fromPath(info.absoluteFilePath());
- }
-
- // Might be a shorturl - try to detect the schema.
- if (!hasSchema)
+ else // Might be a shorturl - try to detect the schema.
{
- int dotIndex = urlStr.indexOf(QLatin1Char('.'));
+ int dotIndex = urlStr.indexOf(QLatin1Char(':'));
if (dotIndex != -1)
{
@@ -240,17 +235,10 @@ KUrl Application::guessUrlFromString(const QString &string)
}
}
}
-
+
// Fall back to QUrl's own tolerant parser.
- QUrl qurl = QUrl(string, QUrl::TolerantMode);
- KUrl url(qurl);
+ KUrl url = KUrl(urlStr);
- // finally for cases where the user just types in a hostname add http
- if (qurl.scheme().isEmpty())
- {
- qurl = QUrl(QLatin1String("http://") + string, QUrl::TolerantMode);
- url = KUrl(qurl);
- }
return url;
}
@@ -305,7 +293,7 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type)
return;
}
- WebView *webView;
+ WebView *webView = 0;
switch(type)
{
diff --git a/src/bookmarks.cpp b/src/bookmarks.cpp
index d5bd107e..a1f0e441 100644
--- a/src/bookmarks.cpp
+++ b/src/bookmarks.cpp
@@ -64,10 +64,10 @@ void BookmarkOwner::openBookmark(const KBookmark & bookmark,
Qt::MouseButtons mouseButtons,
Qt::KeyboardModifiers keyboardModifiers)
{
- Q_UNUSED(mouseButtons)
- Q_UNUSED(keyboardModifiers)
-
- emit openUrl(bookmark.url());
+ if (keyboardModifiers & Qt::ControlModifier || mouseButtons == Qt::MidButton)
+ emit openUrl(bookmark.url(), Rekonq::SettingOpenTab);
+ else
+ emit openUrl(bookmark.url(), Rekonq::CurrentTab);
}
@@ -183,7 +183,7 @@ BookmarkProvider::BookmarkProvider(QWidget *parent)
// setup menu
m_owner = new BookmarkOwner(this);
- connect(m_owner, SIGNAL(openUrl(const KUrl&)), this, SIGNAL(openUrl(const KUrl&)));
+ connect(m_owner, SIGNAL(openUrl(const KUrl&, const Rekonq::OpenType &)), this, SIGNAL(openUrl(const KUrl&, const Rekonq::OpenType &)));
m_bookmarkMenu = new BookmarkMenu(m_manager, m_owner, m_menu, m_actionCollection);
// setup toolbar
@@ -261,6 +261,8 @@ void BookmarkProvider::contextMenu(const QPoint &point)
if (!action)
return;
KMenu *menu = m_bookmarkMenu->viewContextMenu(action);
+ if (!menu)
+ return;
menu->popup(m_bookmarkToolBar->mapToGlobal(point));
}
diff --git a/src/bookmarks.h b/src/bookmarks.h
index 9db71ab5..13562f06 100644
--- a/src/bookmarks.h
+++ b/src/bookmarks.h
@@ -29,6 +29,9 @@
#ifndef BOOKMARKS_H
#define BOOKMARKS_H
+// Local Includes
+#include "application.h"
+
// Qt Includes
#include <QWidget>
@@ -115,7 +118,7 @@ signals:
* @param url the URL to load
*
*/
- void openUrl(const KUrl &);
+ void openUrl(const KUrl &, const Rekonq::OpenType &);
private:
@@ -206,7 +209,7 @@ signals:
*
* @param url the URL to load
*/
- void openUrl(const KUrl &url);
+ void openUrl(const KUrl &, const Rekonq::OpenType &);
public slots:
diff --git a/src/cookiejar.cpp b/src/cookiejar.cpp
index 7007bc61..5160d6ed 100644
--- a/src/cookiejar.cpp
+++ b/src/cookiejar.cpp
@@ -56,6 +56,7 @@ CookieJar::CookieJar(QObject* parent)
CookieJar::~CookieJar()
{
+ delete m_kcookiejar;
}
@@ -67,7 +68,6 @@ QList<QNetworkCookie> CookieJar::cookiesForUrl(const QUrl & url) const
if (reply.isValid())
{
cookieList << reply.value().toUtf8();
- //kDebug() << reply.value();
}
else
{
@@ -86,7 +86,6 @@ bool CookieJar::setCookiesFromUrl(const QList<QNetworkCookie> & cookieList, cons
cookieHeader = "Set-Cookie: ";
cookieHeader += cookie.toRawForm();
m_kcookiejar->call("addCookies", url.toString(), cookieHeader, m_windowId);
- //kDebug() << "url: " << url.host() << ", cookie: " << cookieHeader;
}
return !m_kcookiejar->lastError().isValid();
diff --git a/src/lineedit.cpp b/src/lineedit.cpp
index 186ac143..b691e090 100644
--- a/src/lineedit.cpp
+++ b/src/lineedit.cpp
@@ -45,6 +45,7 @@ LineEdit::LineEdit(QWidget* parent)
setMinimumWidth(200);
setFocusPolicy(Qt::WheelFocus);
setHandleSignals(true);
+ setClearButtonShown(true);
}
diff --git a/src/main.cpp b/src/main.cpp
index 2bf926ab..0758abfa 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -37,7 +37,7 @@ static const char description[] =
I18N_NOOP("WebKit based Web Browser for KDE");
-static const char version[] = "0.1.97";
+static const char version[] = "0.2.0";
int main(int argc, char **argv)
diff --git a/src/mainview.cpp b/src/mainview.cpp
index 5b08e17a..efabf0f1 100644
--- a/src/mainview.cpp
+++ b/src/mainview.cpp
@@ -327,6 +327,12 @@ void MainView::slotCurrentChanged(int index)
currentUrlBar()->setUrl(webView->url());
emit showStatusBarMessage(webView->lastStatusBarText());
+ // notify UI to eventually switch stop/reload button
+ if(currentUrlBar()->isLoading())
+ emit browserTabLoading(true);
+ else
+ emit browserTabLoading(false);
+
// set focus to the current webview
webView->setFocus();
}
@@ -361,6 +367,10 @@ WebView *MainView::webView(int index) const
}
+// FIXME (0.3 target, after OneUrlBar). Divide in 2 functions:
+// 1. the slot void newTab() to create a "new empty focused tab"
+// 2. the public method WebView *newWebView() to just create a new webview
+// without working with the focus and loading an url
WebView *MainView::newTab(bool focused)
{
// line edit
@@ -541,7 +551,7 @@ void MainView::webViewLoadStarted()
}
}
- emit browserLoading(true);
+ emit browserTabLoading(true);
if (index != currentIndex())
return;
@@ -564,7 +574,7 @@ void MainView::webViewLoadFinished(bool ok)
}
webViewIconChanged();
- emit browserLoading(false);
+ emit browserTabLoading(false);
// don't display messages for background tabs
if (index != currentIndex())
diff --git a/src/mainview.h b/src/mainview.h
index 982fd9eb..3e6b9efb 100644
--- a/src/mainview.h
+++ b/src/mainview.h
@@ -96,7 +96,7 @@ signals:
void setCurrentTitle(const QString &url);
void showStatusBarMessage(const QString &message, Rekonq::Notify status = Rekonq::Info);
void linkHovered(const QString &link);
- void browserLoading(bool);
+ void browserTabLoading(bool);
void printRequested(QWebFrame *frame);
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 7a45d945..3ac46a1b 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -176,13 +176,18 @@ void MainWindow::postLaunch()
connect(m_findBar, SIGNAL(searchString(const QString &)), this, SLOT(slotFind(const QString &)));
// bookmarks loading
- connect(Application::bookmarkProvider(), SIGNAL(openUrl(const KUrl&)), Application::instance(), SLOT(loadUrl(const KUrl&)));
+ connect(Application::bookmarkProvider(), SIGNAL(openUrl(const KUrl&, const Rekonq::OpenType&)),
+ Application::instance(), SLOT(loadUrl(const KUrl&, const Rekonq::OpenType&)));
// setting up toolbars to NOT have context menu enabled
setContextMenuPolicy(Qt::DefaultContextMenu);
// accept d'n'd
setAcceptDrops(true);
+
+ const qlonglong winId = window()->winId();
+ Application::cookieJar()->setWindowId(winId);
+ Application::networkAccessManager()->metaData().insert("window-id", QString::number(winId));
}
@@ -252,7 +257,7 @@ void MainWindow::setupActions()
m_stopReloadAction = new KAction(this);
actionCollection()->addAction(QLatin1String("stop_reload") , m_stopReloadAction);
m_stopReloadAction->setShortcutConfigurable(false);
- connect(m_view, SIGNAL(browserLoading(bool)), this, SLOT(slotBrowserLoading(bool)));
+ connect(m_view, SIGNAL(browserTabLoading(bool)), this, SLOT(slotBrowserLoading(bool)));
slotBrowserLoading(false); //first init for blank start page
// ============== Custom Actions
@@ -367,7 +372,7 @@ void MainWindow::setupTools()
void MainWindow::setupSidePanel()
{
// Setup history side panel
- m_sidePanel = new SidePanel(i18n("History"), this);
+ m_sidePanel = new SidePanel(i18n("History Panel"), this);
connect(m_sidePanel, SIGNAL(openUrl(const KUrl&)), Application::instance(), SLOT(loadUrl(const KUrl&)));
connect(m_sidePanel, SIGNAL(destroyed()), Application::instance(), SLOT(slotSaveConfiguration()));
@@ -375,7 +380,6 @@ void MainWindow::setupSidePanel()
// setup side panel actions
KAction* a = (KAction *) m_sidePanel->toggleViewAction();
- a->setText( i18n("History Panel") );
a->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_H)); // WARNING : is this the right shortcut ??
a->setIcon(KIcon("view-history"));
actionCollection()->addAction(QLatin1String("show_history_panel"), a);
@@ -451,7 +455,6 @@ void MainWindow::slotUpdateConfiguration()
// ====== load Settings on main classes
Application::networkAccessManager()->loadSettings();
-// FIXME (?) Application::cookieJar()->loadSettings();
Application::historyManager()->loadSettings();
}
@@ -908,12 +911,13 @@ void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status)
return;
}
- if(m_popup)
- delete m_popup;
+ KPassivePopup *popup_sav = m_popup;
m_popup = new KPassivePopup(this);
m_popup->setAutoDelete(true);
+ connect(Application::instance(), SIGNAL(focusChanged(QWidget*,QWidget*)), m_popup, SLOT(hide()));
+
QPixmap px;
QString pixPath;
@@ -953,6 +957,10 @@ void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status)
QPoint p(x,y);
m_popup->show(p);
+
+ if(popup_sav)
+ delete popup_sav;
+
}
diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp
index eefa0d8e..473fa770 100644
--- a/src/networkaccessmanager.cpp
+++ b/src/networkaccessmanager.cpp
@@ -202,3 +202,20 @@ void NetworkAccessManager::slotSSLErrors(QNetworkReply *reply, const QList<QSslE
reply->ignoreSslErrors();
}
#endif
+
+
+KIO::MetaData& NetworkAccessManager::metaData()
+{
+ return m_metaData;
+};
+
+
+QNetworkReply *NetworkAccessManager::createRequest(Operation op, const QNetworkRequest &req, QIODevice *outgoingData)
+{
+ // FIXME: rude hack. Waiting for a real POST behaviour fix ;)
+ if(op == PostOperation)
+ {
+ return QNetworkAccessManager::createRequest(op,req,outgoingData);
+ }
+ return AccessManager::createRequest(op,req,outgoingData);
+}
diff --git a/src/networkaccessmanager.h b/src/networkaccessmanager.h
index 1eea9a0d..a6c264f2 100644
--- a/src/networkaccessmanager.h
+++ b/src/networkaccessmanager.h
@@ -48,12 +48,15 @@ class NetworkAccessManager : public RekonqAccessManager
public:
NetworkAccessManager(QObject *parent = 0);
-
+ KIO::MetaData& metaData();
void resetDiskCache();
public slots:
void loadSettings();
+protected:
+ virtual QNetworkReply *createRequest(Operation op, const QNetworkRequest &req, QIODevice *outgoingData = 0);
+
private slots:
void authenticationRequired(QNetworkReply *reply, QAuthenticator *auth);
void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth);
@@ -64,6 +67,7 @@ private slots:
private:
QNetworkDiskCache *m_diskCache;
+ KIO::MetaData m_metaData;
};
#endif // NETWORKACCESSMANAGER_H
diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg
index 50fa6621..ec2b9a3b 100644
--- a/src/rekonq.kcfg
+++ b/src/rekonq.kcfg
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
-<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
- http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
- <kcfgfile name="rekonqrc"/>
+<!DOCTYPE kcfg SYSTEM "http://www.kde.org/standards/kcfg/1.0/kcfg.dtd">
+<kcfg>
<!-- Includes -->
<include>QtWebKit</include>
<include>KUrl</include>
+<kcfgfile name="rekonqrc"/>
+
+
<!-- General Settings -->
<group name="General">
<entry name="homePage" type="String">
diff --git a/src/settings.cpp b/src/settings.cpp
index e0f9e8e7..51281379 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -43,7 +43,6 @@
//Ui Includes
#include "ui_settings_general.h"
#include "ui_settings_fonts.h"
-#include "ui_settings_privacy.h"
#include "ui_settings_proxy.h"
#include "ui_settings_webkit.h"
@@ -65,7 +64,6 @@ class Private
private:
Ui::general generalUi;
Ui::fonts fontsUi;
- Ui::privacy privacyUi;
Ui::proxy proxyUi;
Ui::webkit webkitUi;
KCModuleProxy *ebrowsingModule;
@@ -94,12 +92,6 @@ Private::Private(SettingsDialog *parent)
pageItem = parent->addPage(widget , i18n("Fonts"));
pageItem->setIcon(KIcon("preferences-desktop-font"));
- widget = new QWidget;
- privacyUi.setupUi(widget);
- widget->layout()->setMargin(0);
- pageItem = parent->addPage(widget , i18n("History"));
- pageItem->setIcon(KIcon("view-history"));
-
KCModuleInfo cookiesInfo("cookies.desktop");
cookiesModule = new KCModuleProxy(cookiesInfo,parent);
pageItem = parent->addPage(cookiesModule, i18n(cookiesInfo.moduleName().toLocal8Bit()));
@@ -129,7 +121,7 @@ Private::Private(SettingsDialog *parent)
pageItem = parent->addPage(ebrowsingModule, i18n(ebrowsingInfo.moduleName().toLocal8Bit()));
pageItem->setIcon(KIcon(ebrowsingInfo.icon()));
- parent->setMinimumSize(800,550);
+ parent->setMinimumSize(800,500);
}
@@ -154,7 +146,8 @@ SettingsDialog::SettingsDialog(QWidget *parent)
connect(d->cookiesModule, SIGNAL(changed(bool)), this, SLOT(updateButtons()));
connect(this, SIGNAL(applyClicked()), this, SLOT(saveSettings()));
-
+ connect(this, SIGNAL(okClicked()), this, SLOT(saveSettings()));
+
setWebSettingsToolTips();
}
diff --git a/src/settings.h b/src/settings.h
index 3b476ec1..0be89173 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -43,7 +43,8 @@ class SettingsDialog : public KConfigDialog
public:
SettingsDialog(QWidget *parent = 0);
~SettingsDialog();
- virtual bool hasChanged ();
+
+ virtual bool hasChanged();
private:
Private* const d;
diff --git a/src/settings_general.ui b/src/settings_general.ui
index 90136755..d40dff99 100644
--- a/src/settings_general.ui
+++ b/src/settings_general.ui
@@ -107,6 +107,59 @@
</widget>
</item>
<item>
+ <widget class="QGroupBox" name="groupBox_4">
+ <property name="title">
+ <string>History</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Remove history items:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="KComboBox" name="kcfg_expireHistory">
+ <item>
+ <property name="text">
+ <string>After one day</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>After one week</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>After two weeks</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>After one month</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>After one year</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Manually</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@@ -127,6 +180,11 @@
<extends>QLineEdit</extends>
<header>klineedit.h</header>
</customwidget>
+ <customwidget>
+ <class>KComboBox</class>
+ <extends>QComboBox</extends>
+ <header>kcombobox.h</header>
+ </customwidget>
</customwidgets>
<resources/>
<connections/>
diff --git a/src/settings_privacy.ui b/src/settings_privacy.ui
deleted file mode 100644
index a716dc8d..00000000
--- a/src/settings_privacy.ui
+++ /dev/null
@@ -1,87 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>privacy</class>
- <widget class="QWidget" name="privacy">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>461</width>
- <height>313</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Privacy</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QGroupBox" name="groupBox_2">
- <property name="title">
- <string>History</string>
- </property>
- <layout class="QGridLayout" name="gridLayout_2">
- <item row="0" column="0">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>Remove history items:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KComboBox" name="kcfg_expireHistory">
- <item>
- <property name="text">
- <string>After one day</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>After one week</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>After two weeks</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>After one month</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>After one year</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Manually</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>136</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/src/urlbar.cpp b/src/urlbar.cpp
index 28c63b78..94f248e3 100644
--- a/src/urlbar.cpp
+++ b/src/urlbar.cpp
@@ -225,7 +225,7 @@ void UrlBar::paintEvent(QPaintEvent *event)
painter.setPen(Qt::transparent);
QRect backgroundRect = lineEdit()->frameGeometry();
- int mid = backgroundRect.width() / 100 * m_progress;
+ int mid = backgroundRect.width() * m_progress / 100;
QRect progressRect(backgroundRect.x(), backgroundRect.y(), mid, backgroundRect.height());
painter.drawRect(progressRect);
painter.end();
@@ -244,10 +244,7 @@ void UrlBar::focusOutEvent(QFocusEvent *event)
QSize UrlBar::sizeHint() const
{
- QSize size(lineEdit()->sizeHint());
- // make it (more or less) the same height with search bar (at least on oxygen)
-// size.setHeight(size.height() + 2);
- return size;
+ return lineEdit()->sizeHint();
}
@@ -266,9 +263,19 @@ QLinearGradient UrlBar::generateGradient(const QColor &color, int height)
return gradient;
}
+
void UrlBar::setBackgroundColor(QColor c)
{
s_defaultBaseColor=c;
repaint();
}
+
+bool UrlBar::isLoading()
+{
+ if(m_progress == 0)
+ {
+ return false;
+ }
+ return true;
+}
diff --git a/src/urlbar.h b/src/urlbar.h
index 42ac9af7..50ba40f7 100644
--- a/src/urlbar.h
+++ b/src/urlbar.h
@@ -58,7 +58,8 @@ public:
KUrl url() const;
QSize sizeHint() const;
void setBackgroundColor(QColor);
-
+ bool isLoading();
+
signals:
void activated(const KUrl&);
diff --git a/src/webpage.cpp b/src/webpage.cpp
index 160294e2..c81d93da 100644
--- a/src/webpage.cpp
+++ b/src/webpage.cpp
@@ -48,7 +48,7 @@
#include <KStandardDirs>
#include <KUrl>
#include <KDebug>
-
+#include <KToolInvocation>
#include <KDE/KParts/BrowserRun>
#include <KDE/KMimeTypeTrader>
@@ -72,6 +72,7 @@ WebPage::WebPage(QObject *parent)
: QWebPage(parent)
, m_keyboardModifiers(Qt::NoModifier)
, m_pressedButtons(Qt::NoButton)
+ , m_requestedUrl()
{
setForwardUnsupportedContent(true);
@@ -83,8 +84,21 @@ WebPage::WebPage(QObject *parent)
}
+WebPage::~WebPage()
+{
+}
+
+
bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type)
{
+ m_requestedUrl = request.url();
+
+ if (m_requestedUrl.scheme() == QLatin1String("mailto"))
+ {
+ KToolInvocation::invokeMailer(m_requestedUrl);
+ return false;
+ }
+
if (m_keyboardModifiers & Qt::ControlModifier || m_pressedButtons == Qt::MidButton)
{
Application::instance()->loadUrl(request.url(), Rekonq::SettingOpenTab);
@@ -118,52 +132,77 @@ WebPage *WebPage::newWindow(WebWindowType type)
}
-// FIXME: dear slot, you need to handle unsupported content a bit better..
void WebPage::slotHandleUnsupportedContent(QNetworkReply *reply)
{
-
- const KUrl url(reply->request().url());
- kDebug() << "title:" << url;
- kDebug() << "error:" << reply->errorString();
-
- QString filename = url.fileName();
- QString mimetype = reply->header(QNetworkRequest::ContentTypeHeader).toString();
- KService::Ptr offer = KMimeTypeTrader::self()->preferredService(mimetype);
-
- KParts::BrowserRun::AskSaveResult res = KParts::BrowserRun::askSave(
- url,
- offer,
- mimetype,
- filename
- );
- switch (res)
+ if (reply->error() == QNetworkReply::NoError)
{
- case KParts::BrowserRun::Save:
- slotDownloadRequested(reply->request());
- return;
- case KParts::BrowserRun::Cancel:
- return;
- default: // non extant case
- break;
- }
+ const KUrl url(reply->request().url());
+ QString filename = url.fileName();
+ QString mimetype = reply->header(QNetworkRequest::ContentTypeHeader).toString();
+ KService::Ptr offer = KMimeTypeTrader::self()->preferredService(mimetype);
- KUrl::List list;
- list.append(url);
- KRun::run(*offer,url,0);
+ if( offer.isNull() ) // no service can handle this. We can just download it..
+ {
+ slotDownloadRequested(reply->request());
+ }
+ else
+ {
+ switch ( KParts::BrowserRun::askSave( url, offer, mimetype, filename ) )
+ {
+ case KParts::BrowserRun::Save:
+ slotDownloadRequested(reply->request());
+ return;
+ case KParts::BrowserRun::Cancel:
+ return;
+ default: // non extant case
+ break;
+ }
+ // case KParts::BrowserRun::Open
+ KUrl::List list;
+ list.append(url);
+ KRun::run(*offer,url,0);
+ }
+ }
return;
}
void WebPage::manageNetworkErrors(QNetworkReply* reply)
{
- if(reply->error() == QNetworkReply::NoError)
+ if( reply->error() == QNetworkReply::NoError )
return;
-
- viewErrorPage(reply);
+
+ if( reply->url() != m_requestedUrl ) // prevent favicon loading
+ return;
+
+ if( reply->error() == QNetworkReply::ContentNotFoundError )
+ {
+ QList<QWebFrame*> frames;
+ frames.append(mainFrame());
+ while (!frames.isEmpty())
+ {
+ QWebFrame *firstFrame = frames.takeFirst();
+
+ if (firstFrame->url() == reply->url())
+ {
+ firstFrame->setHtml(errorPage(reply), reply->url());
+ return;
+ }
+ QList<QWebFrame *> children = firstFrame->childFrames();
+ foreach(QWebFrame *frame, children)
+ {
+ frames.append(frame);
+ }
+ }
+ }
+ else
+ {
+ mainFrame()->setHtml(errorPage(reply), reply->url());
+ }
}
-void WebPage::viewErrorPage(QNetworkReply *reply)
+QString WebPage::errorPage(QNetworkReply *reply)
{
// display "not found" page
QString notfoundFilePath = KStandardDirs::locate("data", "rekonq/htmls/notfound.html");
@@ -172,35 +211,18 @@ void WebPage::viewErrorPage(QNetworkReply *reply)
if (!isOpened)
{
kWarning() << "Couldn't open the notfound.html file";
- return;
+ return QString("");
}
QString title = i18n("Error loading page: ") + reply->url().toString();
QString imagePath = KIconLoader::global()->iconPath("rekonq", KIconLoader::NoGroup, false);
QString html = QString(QLatin1String(file.readAll()))
- .arg(title)
- .arg("file://" + imagePath)
- .arg(reply->errorString())
- .arg(reply->url().toString());
-
- // test
- QList<QWebFrame*> frames;
- frames.append(mainFrame());
- while (!frames.isEmpty())
- {
- QWebFrame *firstFrame = frames.takeFirst();
- if (firstFrame->url() == reply->url())
- {
- firstFrame->setHtml(html, reply->url());
- return;
- }
- QList<QWebFrame *> children = firstFrame->childFrames();
- foreach(QWebFrame *frame, children)
- {
- frames.append(frame);
- }
- }
+ .arg(title)
+ .arg("file://" + imagePath)
+ .arg(reply->errorString())
+ .arg(reply->url().toString());
+ return html;
}
@@ -237,6 +259,7 @@ QObject *WebPage::createPlugin(const QString &classId, const QUrl &url, const QS
}
+// TODO FIXME: sometimes url.fileName() fails to retrieve url file name
void WebPage::slotDownloadRequested(const QNetworkRequest &request)
{
const KUrl url(request.url());
@@ -250,9 +273,3 @@ void WebPage::slotDownloadRequested(const QNetworkRequest &request)
job->addMetaData("cache", "cache"); // Use entry from cache if available.
job->uiDelegate()->setAutoErrorHandlingEnabled(true);
}
-
-
-QString WebPage::chooseFile(QWebFrame *frame, const QString &suggestedFile)
-{
- return KFileDialog::getOpenFileName(suggestedFile, QString(), frame->page()->view());
-}
diff --git a/src/webpage.h b/src/webpage.h
index d21fc44d..d1642966 100644
--- a/src/webpage.h
+++ b/src/webpage.h
@@ -36,11 +36,12 @@
// Qt Includes
#include <QWebPage>
+#include <QUrl>
// Forward Declarations
class QWebFrame;
class QNetworkReply;
-
+class QUrl;
class WebPage : public QWebPage
{
@@ -48,7 +49,8 @@ class WebPage : public QWebPage
public:
explicit WebPage(QObject *parent = 0);
-
+ ~WebPage();
+
public slots:
void manageNetworkErrors(QNetworkReply* reply);
@@ -60,9 +62,6 @@ protected:
const QNetworkRequest &request,
NavigationType type);
- QString chooseFile(QWebFrame *frame,
- const QString &suggestedFile);
-
void javaScriptAlert(QWebFrame *frame,
const QString &msg);
@@ -84,12 +83,13 @@ protected Q_SLOTS:
private:
friend class WebView;
-
- void viewErrorPage(QNetworkReply *);
+ QString errorPage(QNetworkReply *);
// keyboard/mouse modifiers
Qt::KeyboardModifiers m_keyboardModifiers;
Qt::MouseButtons m_pressedButtons;
+
+ QUrl m_requestedUrl;
};
#endif
diff --git a/src/webview.cpp b/src/webview.cpp
index dca8b6fb..75dc0979 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -36,8 +36,6 @@
#include "application.h"
#include "mainwindow.h"
#include "mainview.h"
-#include "cookiejar.h"
-#include "networkaccessmanager.h"
#include "history.h"
#include "webpage.h"