summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoradjam <adjam@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-05-28 10:06:17 +0000
committeradjam <adjam@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-05-28 10:06:17 +0000
commit796f0b4b7bc8201bad2e1bad78a82ccd6bf182ec (patch)
treed56b2d70aa5e5e8932c5ef6f2403b6263fffd030 /src
parentSVN_SILENT made messages (.desktop file) (diff)
parentcosmetic (diff)
downloadrekonq-796f0b4b7bc8201bad2e1bad78a82ccd6bf182ec.tar.xz
Merge branch 'master' into local-svn
git-svn-id: svn+ssh://svn.kde.org/home/kde/trunk/playground/network/rekonq@973966 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt8
-rw-r--r--src/bookmarks.cpp6
-rw-r--r--src/bookmarks.h5
-rw-r--r--src/findbar.cpp11
-rw-r--r--src/findbar.h2
-rw-r--r--src/main.cpp2
-rw-r--r--src/mainview.cpp91
-rw-r--r--src/mainview.h22
-rw-r--r--src/mainwindow.cpp46
-rw-r--r--src/mainwindow.h10
-rw-r--r--src/networkaccessmanager.cpp17
-rw-r--r--src/networkaccessmanager.h14
-rw-r--r--src/urlbar.cpp18
-rw-r--r--src/urlbar.h16
-rw-r--r--src/webpage.cpp192
-rw-r--r--src/webpage.h77
-rw-r--r--src/webview.cpp349
-rw-r--r--src/webview.h75
18 files changed, 487 insertions, 474 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a64cc747..064fc0e6 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -22,6 +22,7 @@ SET( rekonq_SRCS
panelhistory.cpp
lineedit.cpp
stackedurlbar.cpp
+ webpage.cpp
)
KDE4_ADD_UI_FILES( rekonq_SRCS
@@ -41,18 +42,19 @@ KDE4_ADD_KCFG_FILES( rekonq_SRCS rekonq.kcfgc )
### ------------------------------------------
-ADD_DEFINITIONS( ${KDE4_DEFINITIONS} )
+ADD_DEFINITIONS( ${KDE4_DEFINITIONS} ${KDEWEBKIT_DEFINITIONS} )
KDE4_ADD_EXECUTABLE( rekonq ${rekonq_SRCS} )
TARGET_LINK_LIBRARIES( rekonq
${QT_LIBRARIES}
${QT_QTNETWORK_LIBRARY}
- ${QT_QTWEBKIT_LIBRARY}
- ${QT_QTUITOOLS_LIBRARY}
+# ${QT_QTWEBKIT_LIBRARY}
+# ${QT_QTUITOOLS_LIBRARY}
${KDE4_KUTILS_LIBS}
${KDE4_KDEUI_LIBS}
${KDE4_KIO_LIBS}
+ ${KDEWEBKIT_LIBRARIES}
)
INSTALL( TARGETS rekonq ${INSTALL_TARGETS_DEFAULT_ARGS} )
diff --git a/src/bookmarks.cpp b/src/bookmarks.cpp
index eb500985..9490ed0f 100644
--- a/src/bookmarks.cpp
+++ b/src/bookmarks.cpp
@@ -66,6 +66,12 @@ void BookmarkOwner::openBookmark(const KBookmark & bookmark,
}
+bool BookmarkOwner::supportsTabs() const
+{
+ return true;
+}
+
+
QString BookmarkOwner::currentUrl() const
{
return Application::instance()->mainWindow()->currentTab()->url().url();
diff --git a/src/bookmarks.h b/src/bookmarks.h
index fef91413..8b4cf8e5 100644
--- a/src/bookmarks.h
+++ b/src/bookmarks.h
@@ -93,10 +93,7 @@ public:
/**
* This function returns whether the owner supports tabs.
*/
- virtual bool supportsTabs() const
- {
- return true;
- }
+ virtual bool supportsTabs() const;
/**
* Called if the user wants to open every bookmark in this folder in a new tab.
diff --git a/src/findbar.cpp b/src/findbar.cpp
index 0e312e04..283453a8 100644
--- a/src/findbar.cpp
+++ b/src/findbar.cpp
@@ -113,13 +113,14 @@ void FindBar::clear()
}
-void FindBar::showFindBar()
+void FindBar::show()
{
// show findbar if not visible
- if (!isVisible())
- {
- show();
- }
+ if (isVisible())
+ return;
+
+ QWidget::show();
+
// set focus to findbar if user select showFindBar shortcut
m_lineEdit->setFocus();
m_lineEdit->selectAll();
diff --git a/src/findbar.h b/src/findbar.h
index a8a78970..739a573e 100644
--- a/src/findbar.h
+++ b/src/findbar.h
@@ -50,7 +50,7 @@ public:
public slots:
void clear();
- void showFindBar();
+ void show();
protected Q_SLOTS:
void keyPressEvent(QKeyEvent* event);
diff --git a/src/main.cpp b/src/main.cpp
index 600961c5..38c30b53 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -29,7 +29,7 @@ static const char description[] =
I18N_NOOP("Webkit Based Browser for KDE");
-static const char version[] = "0.1";
+static const char version[] = "0.1.1";
int main(int argc, char **argv)
diff --git a/src/mainview.cpp b/src/mainview.cpp
index 8f3bf197..d8d1c2b5 100644
--- a/src/mainview.cpp
+++ b/src/mainview.cpp
@@ -58,9 +58,6 @@
#include <QtGui/QWidget>
#include <QtGui/QMouseEvent>
-#include <QtWebKit/QWebPage>
-
-
MainView::MainView(QWidget *parent)
: KTabWidget(parent)
@@ -108,6 +105,49 @@ void MainView::postLaunch()
m_recentlyClosedTabsAction->setEnabled(false);
}
+
+UrlBar *MainView::currentUrlBar() const
+{
+ return urlBar(-1);
+}
+
+
+TabBar *MainView::tabBar() const
+{
+ return m_tabBar;
+}
+
+
+StackedUrlBar *MainView::urlBarStack() const
+{
+ return m_urlBars;
+}
+
+
+WebView *MainView::currentWebView() const
+{
+ return webView(currentIndex());
+}
+
+
+int MainView::webViewIndex(WebView *webView) const
+{
+ return indexOf(webView);
+}
+
+
+KAction *MainView::recentlyClosedTabsAction() const
+{
+ return m_recentlyClosedTabsAction;
+}
+
+
+void MainView::setMakeBackTab(bool b)
+{
+ m_makeBackTab = b;
+}
+
+
void MainView::showTabBar()
{
if (ReKonfig::alwaysShowTabBar())
@@ -136,8 +176,7 @@ void MainView::showTabBar()
void MainView::slotWebReload()
{
WebView *webView = currentWebView();
- QWebPage *currentParent = webView->webPage();
- QAction *action = currentParent->action(QWebPage::Reload);
+ QAction *action = webView->page()->action(QWebPage::Reload);
action->trigger();
}
@@ -145,8 +184,7 @@ void MainView::slotWebReload()
void MainView::slotWebStop()
{
WebView *webView = currentWebView();
- QWebPage *currentParent = webView->webPage();
- QAction *action = currentParent->action(QWebPage::Stop);
+ QAction *action = webView->page()->action(QWebPage::Stop);
action->trigger();
}
@@ -154,8 +192,7 @@ void MainView::slotWebStop()
void MainView::slotWebBack()
{
WebView *webView = currentWebView();
- QWebPage *currentParent = webView->webPage();
- QAction *action = currentParent->action(QWebPage::Back);
+ QAction *action = webView->page()->action(QWebPage::Back);
action->trigger();
}
@@ -163,8 +200,7 @@ void MainView::slotWebBack()
void MainView::slotWebForward()
{
WebView *webView = currentWebView();
- QWebPage *currentParent = webView->webPage();
- QAction *action = currentParent->action(QWebPage::Forward);
+ QAction *action = webView->page()->action(QWebPage::Forward);
action->trigger();
}
@@ -172,8 +208,7 @@ void MainView::slotWebForward()
void MainView::slotWebUndo()
{
WebView *webView = currentWebView();
- QWebPage *currentParent = webView->webPage();
- QAction *action = currentParent->action(QWebPage::Undo);
+ QAction *action = webView->page()->action(QWebPage::Undo);
action->trigger();
}
@@ -181,8 +216,7 @@ void MainView::slotWebUndo()
void MainView::slotWebRedo()
{
WebView *webView = currentWebView();
- QWebPage *currentParent = webView->webPage();
- QAction *action = currentParent->action(QWebPage::Redo);
+ QAction *action = webView->page()->action(QWebPage::Redo);
action->trigger();
}
@@ -190,8 +224,7 @@ void MainView::slotWebRedo()
void MainView::slotWebCut()
{
WebView *webView = currentWebView();
- QWebPage *currentParent = webView->webPage();
- QAction *action = currentParent->action(QWebPage::Cut);
+ QAction *action = webView->page()->action(QWebPage::Cut);
action->trigger();
}
@@ -199,8 +232,7 @@ void MainView::slotWebCut()
void MainView::slotWebCopy()
{
WebView *webView = currentWebView();
- QWebPage *currentParent = webView->webPage();
- QAction *action = currentParent->action(QWebPage::Copy);
+ QAction *action = webView->page()->action(QWebPage::Copy);
action->trigger();
}
@@ -208,8 +240,7 @@ void MainView::slotWebCopy()
void MainView::slotWebPaste()
{
WebView *webView = currentWebView();
- QWebPage *currentParent = webView->webPage();
- QAction *action = currentParent->action(QWebPage::Paste);
+ QAction *action = webView->page()->action(QWebPage::Paste);
action->trigger();
}
@@ -333,16 +364,8 @@ WebView *MainView::newWebView(Rekonq::OpenType type)
// connecting webPage signals with mainview
connect(webView->page(), SIGNAL(windowCloseRequested()),
this, SLOT(windowCloseRequested()));
- connect(webView->page(), SIGNAL(geometryChangeRequested(const QRect &)),
- this, SIGNAL(geometryChangeRequested(const QRect &)));
connect(webView->page(), SIGNAL(printRequested(QWebFrame *)),
this, SIGNAL(printRequested(QWebFrame *)));
- connect(webView->page(), SIGNAL(menuBarVisibilityChangeRequested(bool)),
- this, SIGNAL(menuBarVisibilityChangeRequested(bool)));
- connect(webView->page(), SIGNAL(statusBarVisibilityChangeRequested(bool)),
- this, SIGNAL(statusBarVisibilityChangeRequested(bool)));
- connect(webView->page(), SIGNAL(toolBarVisibilityChangeRequested(bool)),
- this, SIGNAL(toolBarVisibilityChangeRequested(bool)));
addTab(webView, i18n("(Untitled)"));
@@ -460,10 +483,10 @@ void MainView::slotCloseTab(int index)
if (tab->isModified())
{
int risp = KMessageBox::questionYesNo(this ,
- i18n("You have modified this page and when closing it you would lose the modification.\n"
- "Do you really want to close this page?\n"),
- i18n("Do you really want to close this page?")
- );
+ i18n("You have modified this page and when closing it you would lose the modification.\n"
+ "Do you really want to close this page?\n"),
+ i18n("Do you really want to close this page?")
+ );
if (risp == KMessageBox::No)
return;
}
@@ -532,7 +555,7 @@ void MainView::webViewLoadProgress(int progress)
return;
}
- double totalBytes = static_cast<double>(webView->webPage()->totalBytes() / 1024);
+ double totalBytes = static_cast<double>(webView->page()->totalBytes() / 1024);
QString message = i18n("Loading %1% (%2 %3)...", progress, totalBytes, QLatin1String("kB"));
emit showStatusBarMessage(message);
diff --git a/src/mainview.h b/src/mainview.h
index 16d450d3..ff43576f 100644
--- a/src/mainview.h
+++ b/src/mainview.h
@@ -19,13 +19,12 @@
* ============================================================ */
-
-
#ifndef TABWIDGET_H
#define TABWIDGET_H
// Local Includes
#include "webview.h"
+#include "webpage.h"
#include "application.h"
// KDE Includes
@@ -65,17 +64,16 @@ public:
public:
UrlBar *urlBar(int index) const;
- UrlBar *currentUrlBar() const { return urlBar(-1); }
+ UrlBar *currentUrlBar() const;
WebView *webView(int index) const;
- QList<WebView *> tabs(); // ?
// inlines
- TabBar *tabBar() const { return m_tabBar; }
- StackedUrlBar *urlBarStack() const { return m_urlBars; }
- WebView *currentWebView() const { return webView(currentIndex()); }
- int webViewIndex(WebView *webView) const { return indexOf(webView); }
- KAction *recentlyClosedTabsAction() const { return m_recentlyClosedTabsAction; }
- void setMakeBackTab(bool b) { m_makeBackTab = b; }
+ TabBar *tabBar() const;
+ StackedUrlBar *urlBarStack() const;
+ WebView *currentWebView() const;
+ int webViewIndex(WebView *webView) const;
+ KAction *recentlyClosedTabsAction() const;
+ void setMakeBackTab(bool b);
/**
* show and hide TabBar if user doesn't choose
@@ -97,10 +95,6 @@ signals:
void linkHovered(const QString &link);
void loadProgress(int progress);
- void geometryChangeRequested(const QRect &geometry);
- void menuBarVisibilityChangeRequested(bool visible);
- void statusBarVisibilityChangeRequested(bool visible);
- void toolBarVisibilityChangeRequested(bool visible);
void printRequested(QWebFrame *frame);
public slots:
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 83ff514b..db5a768c 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -89,8 +89,8 @@
MainWindow::MainWindow()
: KXmlGuiWindow()
, m_view(new MainView(this))
- , m_findBar(new FindBar(this))
, m_searchBar(new SearchBar(this))
+ , m_findBar(new FindBar(this))
, m_sidePanel(0)
{
// updating rekonq configuration
@@ -143,6 +143,12 @@ MainWindow::~MainWindow()
}
+SidePanel *MainWindow::sidePanel()
+{
+ return m_sidePanel;
+}
+
+
void MainWindow::postLaunch()
{
// setup history menu: this has to be done AFTER setupGUI!!
@@ -153,11 +159,6 @@ void MainWindow::postLaunch()
connect(m_view, SIGNAL(loadProgress(int)), this, SLOT(slotLoadProgress(int)));
connect(m_view, SIGNAL(printRequested(QWebFrame *)), this, SLOT(printRequested(QWebFrame *)));
- // FIXME: these slots will be commented out until rekonq will have just ONE mainwindow
-// connect(m_view, SIGNAL(geometryChangeRequested(const QRect &)), this, SLOT(geometryChangeRequested(const QRect &)));
-// connect(m_view, SIGNAL(menuBarVisibilityChangeRequested(bool)), menuBar(), SLOT(setVisible(bool)));
-// connect(m_view, SIGNAL(statusBarVisibilityChangeRequested(bool)), statusBar(), SLOT(setVisible(bool)));
-
// status bar messages
connect(m_view, SIGNAL(showStatusBarMessage(const QString&)), statusBar(), SLOT(showMessage(const QString&)));
connect(m_view, SIGNAL(linkHovered(const QString&)), statusBar(), SLOT(showMessage(const QString&)));
@@ -221,7 +222,7 @@ void MainWindow::setupActions()
KStandardAction::printPreview(this, SLOT(slotFilePrintPreview()), actionCollection());
KStandardAction::print(this, SLOT(slotFilePrint()), actionCollection());
KStandardAction::quit(this , SLOT(close()), actionCollection());
- KStandardAction::find(this, SLOT(slotViewFindBar()) , actionCollection());
+ KStandardAction::find(m_findBar, SLOT(show()) , actionCollection());
KStandardAction::findNext(this, SLOT(slotFindNext()) , actionCollection());
KStandardAction::findPrev(this, SLOT(slotFindPrevious()) , actionCollection());
@@ -614,6 +615,7 @@ void MainWindow::slotPrivateBrowsing(bool enable)
}
}
+
void MainWindow::slotFind(const QString & search)
{
if (!currentTab())
@@ -623,12 +625,6 @@ void MainWindow::slotFind(const QString & search)
}
-void MainWindow::slotViewFindBar()
-{
- m_findBar->showFindBar();
-}
-
-
void MainWindow::slotFindNext()
{
if (!currentTab() && m_lastSearch.isEmpty())
@@ -780,10 +776,10 @@ void MainWindow::slotToggleInspector(bool enable)
if (enable)
{
int result = KMessageBox::questionYesNo(this,
- i18n("The web inspector will only work correctly for pages that were loaded after enabling.\n"
- "Do you want to reload all pages?"),
- i18n("Web Inspector")
- );
+ i18n("The web inspector will only work correctly for pages that were loaded after enabling.\n"
+ "Do you want to reload all pages?"),
+ i18n("Web Inspector")
+ );
if (result == KMessageBox::Yes)
{
@@ -910,12 +906,16 @@ bool MainWindow::queryClose()
int answer = KMessageBox::questionYesNoCancel(
this,
- i18np("Are you sure you want to close the window?\n" "You have 1 tab open","Are you sure you want to close the window?\n" "You have %1 tabs open" , m_view->count()),
- i18n("Are you sure you want to close the window?"),
- KStandardGuiItem::quit(),
- KGuiItem(i18n("C&lose Current Tab"), KIcon("tab-close")),
- KStandardGuiItem::cancel(),
- "confirmClosingMultipleTabs"
+ i18np( "Are you sure you want to close the window?\n"
+ "You have 1 tab open",
+ "Are you sure you want to close the window?\n"
+ "You have %1 tabs open",
+ m_view->count()),
+ i18n("Are you sure you want to close the window?"),
+ KStandardGuiItem::quit(),
+ KGuiItem(i18n("C&lose Current Tab"), KIcon("tab-close")),
+ KStandardGuiItem::cancel(),
+ "confirmClosingMultipleTabs"
);
switch (answer)
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 61d8f27b..7d0b2e5c 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -43,8 +43,8 @@ class KActionMenu;
class KIcon;
class KMenu;
-class FindBar;
class HistoryMenu;
+class FindBar;
class SidePanel;
class WebView;
@@ -73,10 +73,7 @@ private:
void setupHistoryMenu();
void setupToolBars();
void setupSidePanel();
- SidePanel *sidePanel()
- {
- return m_sidePanel;
- }
+ SidePanel *sidePanel();
public slots:
void slotHome();
@@ -121,7 +118,6 @@ private slots:
void slotViewTextSmaller();
void slotViewPageSource();
void slotViewFullScreen(bool enable);
- void slotViewFindBar();
// Tools Menu slots
void slotToggleInspector(bool enable);
@@ -132,8 +128,8 @@ private slots:
private:
MainView *m_view;
- FindBar *m_findBar;
SearchBar *m_searchBar;
+ FindBar *m_findBar;
SidePanel *m_sidePanel;
KMenu *m_historyBackMenu;
diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp
index 6f0e2a3e..7f05bf1c 100644
--- a/src/networkaccessmanager.cpp
+++ b/src/networkaccessmanager.cpp
@@ -40,6 +40,7 @@
// Qt Includes
#include <QtCore/QPointer>
+#include <QtCore/QIODevice>
#include <QtGui/QDialog>
#include <QtGui/QStyle>
@@ -48,11 +49,12 @@
#include <QtNetwork/QAuthenticator>
#include <QtNetwork/QNetworkProxy>
#include <QtNetwork/QNetworkReply>
+#include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QSslError>
NetworkAccessManager::NetworkAccessManager(QObject *parent)
- : QNetworkAccessManager(parent)
+ : AccessManager(parent)
{
connect(this, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)),
SLOT(authenticationRequired(QNetworkReply*, QAuthenticator*)));
@@ -61,7 +63,7 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent)
#ifndef QT_NO_OPENSSL
connect(this, SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)),
- SLOT(sslErrors(QNetworkReply*, const QList<QSslError>&)));
+ SLOT(slotSSLErrors(QNetworkReply*, const QList<QSslError>&)));
#endif
loadSettings();
@@ -75,9 +77,9 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent)
void NetworkAccessManager::loadSettings()
{
- QNetworkProxy proxy;
if (ReKonfig::isProxyEnabled())
{
+ QNetworkProxy proxy;
if (ReKonfig::proxyType() == 0)
{
proxy.setType(QNetworkProxy::Socks5Proxy);
@@ -90,8 +92,9 @@ void NetworkAccessManager::loadSettings()
proxy.setPort(ReKonfig::proxyPort());
proxy.setUser(ReKonfig::proxyUserName());
proxy.setPassword(ReKonfig::proxyPassword());
+
+ setProxy(proxy);
}
- setProxy(proxy);
}
@@ -157,7 +160,7 @@ void NetworkAccessManager::proxyAuthenticationRequired(const QNetworkProxy &prox
#ifndef QT_NO_OPENSSL
-void NetworkAccessManager::sslErrors(QNetworkReply *reply, const QList<QSslError> &error)
+void NetworkAccessManager::slotSSLErrors(QNetworkReply *reply, const QList<QSslError> &error)
{
MainWindow *mainWindow = Application::instance()->mainWindow();
@@ -165,7 +168,9 @@ void NetworkAccessManager::sslErrors(QNetworkReply *reply, const QList<QSslError
for (int i = 0; i < error.count(); ++i)
errorStrings += error.at(i).errorString();
QString errors = errorStrings.join(QLatin1String("\n"));
- int ret = KMessageBox::warningContinueCancel(mainWindow, i18n("SSL Errors:\n\n") + reply->url().toString() + "\n\n" + QString(errors) + "\n\n");
+ int ret = KMessageBox::warningContinueCancel(mainWindow,
+ i18n("SSL Errors:\n\n") + reply->url().toString() + "\n\n" + QString(errors) + "\n\n");
+
if (ret == KMessageBox::Yes)
reply->ignoreSslErrors();
}
diff --git a/src/networkaccessmanager.h b/src/networkaccessmanager.h
index 7da2f54f..8416d6a2 100644
--- a/src/networkaccessmanager.h
+++ b/src/networkaccessmanager.h
@@ -22,11 +22,15 @@
#ifndef NETWORKACCESSMANAGER_H
#define NETWORKACCESSMANAGER_H
-// Qt Includes
-#include <QtNetwork/QNetworkAccessManager>
+// KDE Includes
+#include <KIO/AccessManager>
+class QNetworkRequest;
+class QIODevice;
-class NetworkAccessManager : public QNetworkAccessManager
+using namespace KIO;
+
+class NetworkAccessManager : public AccessManager
{
Q_OBJECT
@@ -39,9 +43,11 @@ public slots:
private slots:
void authenticationRequired(QNetworkReply *reply, QAuthenticator *auth);
void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth);
+
#ifndef QT_NO_OPENSSL
- void sslErrors(QNetworkReply *reply, const QList<QSslError> &error);
+ void slotSSLErrors(QNetworkReply *reply, const QList<QSslError> &error);
#endif
+
};
#endif // NETWORKACCESSMANAGER_H
diff --git a/src/urlbar.cpp b/src/urlbar.cpp
index e2756aa6..e1971ced 100644
--- a/src/urlbar.cpp
+++ b/src/urlbar.cpp
@@ -81,6 +81,24 @@ UrlBar::~UrlBar()
}
+void UrlBar::selectAll() const
+{
+ lineEdit()->selectAll();
+}
+
+
+KUrl UrlBar::url() const
+{
+ return m_currentUrl;
+}
+
+
+KLineEdit *UrlBar::lineEdit() const
+{
+ return m_lineEdit;
+}
+
+
void UrlBar::setupLineEdit()
{
// Make m_lineEdit background transparent
diff --git a/src/urlbar.h b/src/urlbar.h
index d8fb9029..02d709bb 100644
--- a/src/urlbar.h
+++ b/src/urlbar.h
@@ -49,15 +49,8 @@ public:
UrlBar(QWidget *parent = 0);
~UrlBar();
- void selectAll() const
- {
- lineEdit()->selectAll();
- }
- KUrl url() const
- {
- return m_currentUrl;
- }
-
+ void selectAll() const;
+ KUrl url() const;
QSize sizeHint() const;
signals:
@@ -80,10 +73,7 @@ protected:
private:
void setupLineEdit();
- KLineEdit *lineEdit() const
- {
- return m_lineEdit;
- }
+ KLineEdit *lineEdit() const;
static QLinearGradient generateGradient(const QColor &color, int height);
diff --git a/src/webpage.cpp b/src/webpage.cpp
new file mode 100644
index 00000000..cfbc32cf
--- /dev/null
+++ b/src/webpage.cpp
@@ -0,0 +1,192 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2008 Benjamin C. Meyer <ben@meyerhome.net>
+* Copyright (C) 2009 by Andrea Diamantini <adjam7 at gmail dot com>
+*
+*
+* This program is free software; you can redistribute it
+* and/or modify it under the terms of the GNU General
+* Public License as published by the Free Software Foundation;
+* either version 2, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* ============================================================ */
+
+
+// Self Includes
+#include "webpage.h"
+#include "webpage.moc"
+
+// Auto Includes
+#include "rekonq.h"
+
+// Local Includes
+#include "application.h"
+#include "mainwindow.h"
+#include "mainview.h"
+#include "cookiejar.h"
+#include "networkaccessmanager.h"
+#include "download.h"
+#include "history.h"
+#include "webview.h"
+
+// KDE Includes
+#include <KStandardDirs>
+#include <KUrl>
+#include <KActionCollection>
+#include <KDebug>
+#include <KToolInvocation>
+
+#include <kdewebkit/kwebpage.h>
+#include <kdewebkit/kwebview.h>
+
+// Qt Includes
+#include <QtGui/QContextMenuEvent>
+#include <QtGui/QWheelEvent>
+#include <QtGui/QMouseEvent>
+#include <QtGui/QClipboard>
+#include <QtGui/QKeyEvent>
+
+#include <QtNetwork/QNetworkReply>
+#include <QtNetwork/QNetworkRequest>
+
+#include <QtWebKit/QWebFrame>
+#include <QtWebKit/QWebHitTestResult>
+#include <QtWebKit/QWebPage>
+#include <QtWebKit/QWebSettings>
+#include <QtWebKit/QWebView>
+
+
+WebPage::WebPage(QObject *parent)
+ : KWebPage(parent)
+{
+ setForwardUnsupportedContent(true);
+
+ setNetworkAccessManager(Application::networkAccessManager());
+ connect(networkAccessManager(), SIGNAL(finished(QNetworkReply*)), this, SLOT(manageNetworkErrors(QNetworkReply*)));
+}
+
+
+bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type)
+{
+
+ // TODO: implement ioslaves protocols
+ QString scheme = request.url().scheme();
+ if (scheme == QLatin1String("mailto"))
+ {
+ KToolInvocation::invokeMailer(request.url());
+ return false;
+ }
+
+ // create convenience fake api:// protocol for KDE apidox search and Qt docs
+ if (scheme == QLatin1String("api"))
+ {
+ QString path;
+ QString className = request.url().host().toLower();
+ if (className[0] == 'k')
+ {
+ path = QString("http://api.kde.org/new.classmapper.php?class=%1").arg(className);
+ }
+ else if (className[0] == 'q')
+ {
+ path = QString("http://doc.trolltech.com/4.5/%1.html").arg(className);
+ }
+ KUrl url(path);
+
+ Application::instance()->mainWindow()->loadUrl(url);
+ return false;
+ }
+
+ return QWebPage::acceptNavigationRequest(frame, request, type);
+}
+
+
+KWebPage *WebPage::createWindow(QWebPage::WebWindowType type)
+{
+ kDebug() << "creating window as new tab.. ";
+
+ // added to manage web modal dialogs
+ if (type == QWebPage::WebModalDialog)
+ {
+ // FIXME : need a "real" implementation..
+ kDebug() << "Modal Dialog ---------------------------------------";
+ }
+
+ WebView *w = Application::instance()->newWebView();
+ return w->page();
+}
+
+
+// FIXME: implement here (perhaps) mimetype discerning && file loading (KToolInvocation??)
+// void WebPage::slotHandleUnsupportedContent(QNetworkReply *reply)
+// {
+//
+// if (reply->error() == QNetworkReply::NoError)
+// {
+// return slotDownloadRequested(reply->request(), reply);
+// }
+//
+// viewErrorPage(reply);
+// }
+
+
+void WebPage::manageNetworkErrors(QNetworkReply* reply)
+{
+ if(reply->error() == QNetworkReply::NoError)
+ return;
+
+ viewErrorPage(reply);
+}
+
+
+void WebPage::viewErrorPage(QNetworkReply *reply)
+{
+ // display "not found" page
+ QString notfoundFilePath = KStandardDirs::locate("data", "rekonq/htmls/notfound.html");
+ QFile file(notfoundFilePath);
+ bool isOpened = file.open(QIODevice::ReadOnly);
+ if (!isOpened)
+ {
+ kWarning() << "Couldn't open the notfound.html file";
+ return;
+ }
+ 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);
+ }
+ }
+ if (m_loadingUrl == reply->url())
+ {
+ mainFrame()->setHtml(html, reply->url());
+ // Don't put error pages to the history.
+ Application::historyManager()->removeHistoryEntry(reply->url(), mainFrame()->title());
+ }
+}
diff --git a/src/webpage.h b/src/webpage.h
new file mode 100644
index 00000000..1f8777bd
--- /dev/null
+++ b/src/webpage.h
@@ -0,0 +1,77 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2007-2008 Trolltech ASA. All rights reserved
+* Copyright (C) 2008 Benjamin C. Meyer <ben@meyerhome.net>
+* Copyright (C) 2008-2009 by Andrea Diamantini <adjam7 at gmail dot com>
+* Copyright (C) 2009 by Paweł Prażak <pawelprazak at gmail dot com>
+*
+*
+* This program is free software; you can redistribute it
+* and/or modify it under the terms of the GNU General
+* Public License as published by the Free Software Foundation;
+* either version 2, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* ============================================================ */
+
+
+#ifndef WEBPAGE_H
+#define WEBPAGE_H
+
+// KDE Includes
+#include <KUrl>
+
+#include <kdewebkit/kwebpage.h>
+#include <kdewebkit/kwebview.h>
+
+// Qt Includes
+#include <QWebPage>
+
+// Forward Declarations
+class MainWindow;
+class Application;
+
+class KActionCollection;
+
+class QWebFrame;
+class QAuthenticator;
+class QMouseEvent;
+class QNetworkProxy;
+class QNetworkReply;
+
+class WebView;
+
+
+class WebPage : public KWebPage
+{
+ Q_OBJECT
+
+public:
+ explicit WebPage(QObject *parent = 0);
+
+public slots:
+ void manageNetworkErrors(QNetworkReply* reply);
+
+protected:
+ bool acceptNavigationRequest(QWebFrame *frame,
+ const QNetworkRequest &request,
+ NavigationType type);
+
+ KWebPage *createWindow(QWebPage::WebWindowType type);
+
+// protected Q_SLOTS:
+// virtual void slotHandleUnsupportedContent(QNetworkReply *reply);
+
+private:
+ void viewErrorPage(QNetworkReply *);
+
+ KUrl m_loadingUrl;
+};
+
+#endif
diff --git a/src/webview.cpp b/src/webview.cpp
index 01fd0d00..216c2bd1 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -36,6 +36,7 @@
#include "networkaccessmanager.h"
#include "download.h"
#include "history.h"
+#include "webpage.h"
// KDE Includes
#include <KStandardDirs>
@@ -44,6 +45,9 @@
#include <KDebug>
#include <KToolInvocation>
+#include <kdewebkit/kwebpage.h>
+#include <kdewebkit/kwebview.h>
+
// Qt Includes
#include <QtGui/QContextMenuEvent>
#include <QtGui/QWheelEvent>
@@ -60,248 +64,60 @@
#include <QtWebKit/QWebSettings>
#include <QtWebKit/QWebView>
-#include <QtUiTools/QUiLoader>
-
-WebPage::WebPage(QObject *parent)
- : QWebPage(parent)
- , m_keyboardModifiers(Qt::NoModifier)
- , m_pressedButtons(Qt::NoButton)
+WebView::WebView(QWidget* parent)
+ : KWebView(parent)
+ , m_page(new WebPage(this))
+ , m_progress(0)
{
- setNetworkAccessManager(Application::networkAccessManager());
+ setPage(m_page);
+ connect(page(), SIGNAL(statusBarMessage(const QString&)), this, SLOT(setStatusBarText(const QString&)));
+ connect(this, SIGNAL(loadProgress(int)), this, SLOT(setProgress(int)));
+ connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished()));
- setForwardUnsupportedContent(true);
- connect(this, SIGNAL(unsupportedContent(QNetworkReply *)), this, SLOT(handleUnsupportedContent(QNetworkReply *)));
+ connect(this, SIGNAL(openUrlInNewTab(const KUrl &)), this, SLOT(openLinkInNewTab(const KUrl &)));
}
-WebPage::~WebPage()
+void WebView::setNewPage()
{
+ setPage(new WebPage(this));
}
-bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type)
-{
- QString scheme = request.url().scheme();
- if (scheme == QLatin1String("mailto"))
- {
- KToolInvocation::invokeMailer(request.url());
- return false;
- }
-
- WebView *webView;
-
- switch (type)
- {
- // user activated a submit button for an HTML form.
- case QWebPage::NavigationTypeFormSubmitted:
- kDebug() << "NavigationTypeFormSubmitted";
- kDebug() << request.url();
- break;
-
- // An HTML form was submitted a second time.
- case QWebPage::NavigationTypeFormResubmitted:
- kDebug() << "NavigationTypeFormResubmitted";
- break;
-
- // A navigation to another document using a method not listed above.
- case QWebPage::NavigationTypeOther:
- kDebug() << "NavigationTypeOther";
- break;
-
- // user clicked on a link or pressed return on a focused link.
- case QWebPage::NavigationTypeLinkClicked:
- kDebug() << "NavigationTypeLinkClicked";
- break;
-
- // Navigation to a previously shown document in the back or forward history is requested.
- case QWebPage::NavigationTypeBackOrForward:
- kDebug() << "NavigationTypeBackOrForward";
- break;
-
- // user activated the reload action.
- case QWebPage::NavigationTypeReload:
- kDebug() << "NavigationTypeReload";
-
-#if QT_VERSION <= 040500
- // HACK Ported from Arora
- // A short term hack until QtWebKit can get a reload without cache QAction
- // *FYI* currently type is never NavigationTypeReload
- // See: https://bugs.webkit.org/show_bug.cgi?id=24283
- if (qApp->keyboardModifiers() & Qt::ShiftModifier)
- {
- kDebug() << "Arora hack";
- QNetworkRequest newRequest(request);
- newRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute,
- QNetworkRequest::AlwaysNetwork);
- mainFrame()->load(request);
- return false;
- }
-#endif
-
- break;
-
- // should be nothing..
- default:
- kDebug() << "Default NON extant case..";
- break;
- }
-
- if (m_keyboardModifiers & Qt::ControlModifier || m_pressedButtons == Qt::MidButton)
- {
- webView = Application::instance()->newWebView();
- webView->setFocus();
- webView->load(request);
- m_keyboardModifiers = Qt::NoModifier;
- m_pressedButtons = Qt::NoButton;
- return false;
- }
-
- if (frame == mainFrame())
- {
- m_loadingUrl = request.url();
- emit loadingUrl(m_loadingUrl);
- }
- else
- {
- // if frame doesn't exists (perhaps) we are pointing to a blank target..
- if (!frame)
- {
- webView = Application::instance()->newWebView();
- webView->setFocus();
- webView->load(request);
- return false;
- }
- }
-
- return QWebPage::acceptNavigationRequest(frame, request, type);
+KUrl WebView::url() const
+{
+ return KUrl(QWebView::url());
}
-QWebPage *WebPage::createWindow(QWebPage::WebWindowType type)
-{
- kDebug() << "creating window as new tab.. ";
-
- // added to manage web modal dialogs
- if (type == QWebPage::WebModalDialog)
- {
- // FIXME : need a "real" implementation..
- kDebug() << "Modal Dialog ---------------------------------------";
- }
-
- WebView *w = Application::instance()->newWebView();
- return w->page();
+QString WebView::lastStatusBarText() const
+{
+ return m_statusBarText;
}
-QObject *WebPage::createPlugin(const QString &classId, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues)
-{
- kDebug() << "creating PLUGIN for rekonq ";
- kDebug() << "classId = " << classId;
- kDebug() << "url = " << url;
- kDebug() << "Param Names = " << paramNames;
- kDebug() << "Param Values = " << paramValues;
-
- QUiLoader loader;
- return loader.createWidget(classId, view());
+int WebView::progress() const
+{
+ return m_progress;
}
-void WebPage::handleUnsupportedContent(QNetworkReply *reply)
+void WebView::load(const KUrl &url)
{
- // create convenience fake api:// protocol for KDE apidox search and Qt docs
- if (reply->url().scheme() == "api")
- {
- QString path;
- QString className = reply->url().host().toLower();
- if (className[0] == 'k')
- {
- path = QString("http://api.kde.org/new.classmapper.php?class=%1").arg(className);
- }
- else if (className[0] == 'q')
- {
- path = QString("http://doc.trolltech.com/4.5/%1.html").arg(className);
- }
- KUrl url(path);
-
- Application::instance()->mainWindow()->loadUrl(url);
- return;
- }
-
- if (reply->error() == QNetworkReply::NoError)
- {
- // st iframe unwanted download fix
- if (reply->header(QNetworkRequest::ContentTypeHeader).isValid())
- {
- KUrl srcUrl = reply->url();
- Application::downloadManager()->newDownload(srcUrl);
- }
- else
- {
- kDebug() << "invalid content type header";
- }
- return;
- }
-
- // display "not found" page
- QString notfoundFilePath = KStandardDirs::locate("data", "rekonq/htmls/notfound.html");
- QFile file(notfoundFilePath);
- bool isOpened = file.open(QIODevice::ReadOnly);
- if (!isOpened)
- {
- kWarning() << "Couldn't open the notfound.html file";
- return;
- }
- 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());
-
- 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);
- }
- }
- if (m_loadingUrl == reply->url())
- {
- mainFrame()->setHtml(html, reply->url());
- // Don't put error pages to the history.
- Application::historyManager()->removeHistoryEntry(reply->url(), mainFrame()->title());
- }
+ QWebView::load(url);
}
-// -----------------------------------------------------------------------------------------------------------------
+void WebView::setProgress(int progress)
+{
+ m_progress = progress;
+}
-WebView::WebView(QWidget* parent)
- : QWebView(parent)
- , m_page(new WebPage(this))
- , m_progress(0)
-{
- setPage(m_page);
- connect(page(), SIGNAL(statusBarMessage(const QString&)), this, SLOT(setStatusBarText(const QString&)));
- connect(this, SIGNAL(loadProgress(int)), this, SLOT(setProgress(int)));
- connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished()));
- connect(page(), SIGNAL(loadingUrl(const QUrl&)), this, SIGNAL(urlChanged(const QUrl &)));
- connect(page(), SIGNAL(downloadRequested(const QNetworkRequest &)), this, SLOT(downloadRequested(const QNetworkRequest &)));
- page()->setForwardUnsupportedContent(true);
+void WebView::setStatusBarText(const QString &string)
+{
+ m_statusBarText = string;
}
@@ -315,14 +131,13 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
addBookmarkAction->setData(QVariant());
KMenu menu(this);
- QAction *a;
// link actions
bool linkIsEmpty = result.linkUrl().isEmpty();
if (!linkIsEmpty)
{
- a = new KAction(KIcon("tab-new"), i18n("Open Link in New &Tab"), this);
- connect(a, SIGNAL(triggered()), this, SLOT(openLinkInNewTab()));
+ QAction *a = pageAction(QWebPage::OpenLinkInNewWindow);
+ a->setText(i18n("Open Link in New &Tab"));
menu.addAction(a);
}
else
@@ -335,10 +150,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
// Developer Extras actions
if (page()->settings()->testAttribute(QWebSettings::DeveloperExtrasEnabled))
{
- a = pageAction(QWebPage::InspectElement);
- a->setIcon(KIcon("tools-report-bug"));
- a->setText(i18n("&Inspect Element"));
- menu.addAction(a);
+ menu.addAction(pageAction(QWebPage::InspectElement));
menu.addSeparator();
}
@@ -347,28 +159,19 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
if (result.isContentSelected() && result.isContentEditable())
{
- a = pageAction(QWebPage::Cut);
- a->setIcon(KIcon("edit-cut"));
- a->setText(i18n("Cu&t"));
- menu.addAction(a);
+ menu.addAction(pageAction(QWebPage::Cut));
b = true;
}
if (result.isContentSelected())
{
- a = pageAction(QWebPage::Copy);
- a->setIcon(KIcon("edit-copy"));
- a->setText(i18n("&Copy"));
- menu.addAction(a);
+ menu.addAction(pageAction(QWebPage::Copy));
b = true;
}
if (result.isContentEditable())
{
- a = pageAction(QWebPage::Paste);
- a->setIcon(KIcon("edit-paste"));
- a->setText(i18n("&Paste"));
- menu.addAction(a);
+ menu.addAction(pageAction(QWebPage::Paste));
b = true;
}
@@ -380,31 +183,15 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
// save/copy link actions
if (!linkIsEmpty)
{
- a = pageAction(QWebPage::DownloadLinkToDisk);
- a->setIcon(KIcon("folder-downloads"));
- a->setText(i18n("&Save Link As..."));
- menu.addAction(a);
-
- a = pageAction(QWebPage::CopyLinkToClipboard);
- a->setIcon(KIcon("insert-link"));
- a->setText(i18n("&Copy Link Location"));
- menu.addAction(a);
-
+ menu.addAction(pageAction(QWebPage::DownloadLinkToDisk));
+ menu.addAction(pageAction(QWebPage::CopyLinkToClipboard));
menu.addSeparator();
if (!result.pixmap().isNull())
{
// TODO Add "View Image" && remove copy_this_image action
- a = pageAction(QWebPage::DownloadImageToDisk);
- a->setIcon(KIcon("folder-image"));
- a->setText(i18n("&Save Image As..."));
- menu.addAction(a);
-
- a = pageAction(QWebPage::CopyImageToClipboard);
- a->setIcon(KIcon("insert-image"));
- a->setText(i18n("&Copy This Image"));
- menu.addAction(a);
-
+ menu.addAction(pageAction(QWebPage::DownloadImageToDisk));
+ menu.addAction(pageAction(QWebPage::CopyImageToClipboard));
menu.addSeparator();
}
}
@@ -431,23 +218,10 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
}
-void WebView::wheelEvent(QWheelEvent *event)
-{
- if (QApplication::keyboardModifiers() & Qt::ControlModifier)
- {
- int numDegrees = event->delta() / 8;
- int numSteps = numDegrees / 15;
- setTextSizeMultiplier(textSizeMultiplier() + numSteps * 0.1);
- event->accept();
- return;
- }
- QWebView::wheelEvent(event);
-}
-
-
-void WebView::openLinkInNewTab()
+void WebView::openLinkInNewTab(const KUrl &url)
{
- pageAction(QWebPage::OpenLinkInNewWindow)->trigger();
+ WebView *that = Application::instance()->newWebView();
+ that->load(url);
}
@@ -462,37 +236,6 @@ void WebView::loadFinished()
}
-void WebView::mousePressEvent(QMouseEvent *event)
-{
- m_page->m_pressedButtons = event->buttons();
- m_page->m_keyboardModifiers = event->modifiers();
- QWebView::mousePressEvent(event);
-}
-
-
-void WebView::mouseReleaseEvent(QMouseEvent *event)
-{
- QWebView::mouseReleaseEvent(event);
- if (!event->isAccepted() && (m_page->m_pressedButtons & Qt::MidButton))
- {
- KUrl url(QApplication::clipboard()->text(QClipboard::Selection));
- if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty())
- {
- setUrl(url);
- }
- }
-}
-
-
-void WebView::downloadRequested(const QNetworkRequest &request)
-{
- KUrl srcUrl = request.url();
- QString path = ReKonfig::downloadDir() + QString("/") + srcUrl.fileName();
- KUrl destUrl = KUrl(path);
- Application::downloadManager()->newDownload(srcUrl);
-}
-
-
void WebView::keyPressEvent(QKeyEvent *event)
{
if ((event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_Tab))
diff --git a/src/webview.h b/src/webview.h
index eba02505..2ac018d7 100644
--- a/src/webview.h
+++ b/src/webview.h
@@ -27,8 +27,12 @@
// KDE Includes
#include <KUrl>
+#include <kdewebkit/kwebpage.h>
+#include <kdewebkit/kwebview.h>
+
// Qt Includes
#include <QWebPage>
+#include <QWebView>
// Forward Declarations
class MainWindow;
@@ -41,62 +45,22 @@ class QAuthenticator;
class QMouseEvent;
class QNetworkProxy;
class QNetworkReply;
-class QSslError;
+class WebPage;
-class WebPage : public QWebPage
+class WebView : public KWebView
{
Q_OBJECT
-signals:
- void loadingUrl(const QUrl &url); // WARNING has to be QUrl!!
-
public:
- WebPage(QObject *parent = 0);
- ~WebPage();
-
-protected:
- bool acceptNavigationRequest(QWebFrame *frame,
- const QNetworkRequest &request,
- NavigationType type);
-
- QWebPage *createWindow(QWebPage::WebWindowType type);
- QObject *createPlugin(const QString &classId,
- const QUrl &url,
- const QStringList &paramNames,
- const QStringList &paramValues);
-
-private slots:
- void handleUnsupportedContent(QNetworkReply *reply);
-
-private:
- friend class WebView;
-
- // set the webview mousepressedevent
- Qt::KeyboardModifiers m_keyboardModifiers;
- Qt::MouseButtons m_pressedButtons;
- KUrl m_loadingUrl;
-};
+ explicit WebView(QWidget *parent = 0);
+ KUrl url() const;
+ QString lastStatusBarText() const;
+ int progress() const;
-// ----------------------------------------------------------------------------------------------------
-
-// Qt Includes
-#include <QWebView>
-
-
-class WebView : public QWebView
-{
- Q_OBJECT
-
-public:
- WebView(QWidget *parent = 0);
-
- // inline
- WebPage *webPage() const { return m_page; }
- KUrl url() const { return KUrl(QWebView::url()); }
- QString lastStatusBarText() const { return m_statusBarText; }
- int progress() const { return m_progress; }
+public Q_SLOTS:
+ void load(const KUrl &url);
signals:
// switching tabs
@@ -104,10 +68,7 @@ signals:
void shiftCtrlTabPressed();
protected:
- void mousePressEvent(QMouseEvent *event);
- void mouseReleaseEvent(QMouseEvent *event);
void contextMenuEvent(QContextMenuEvent *event);
- void wheelEvent(QWheelEvent *event);
/**
* Filters (SHIFT + ) CTRL + TAB events and emit (shift)ctrlTabPressed()
@@ -115,12 +76,15 @@ protected:
*/
void keyPressEvent(QKeyEvent *event);
+ // to reimplement from KWebView
+ virtual void setNewPage();
+
private slots:
- void setProgress(int progress) { m_progress = progress; }
+ void setProgress(int progress);
void loadFinished();
- void setStatusBarText(const QString &string) { m_statusBarText = string; }
- void downloadRequested(const QNetworkRequest &request);
- void openLinkInNewTab();
+ void setStatusBarText(const QString &string);
+
+ void openLinkInNewTab(const KUrl &);
private:
WebPage *m_page;
@@ -130,4 +94,3 @@ private:
};
#endif
-