summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2009-12-15 17:01:04 +0100
committerAndrea Diamantini <adjam7@gmail.com>2009-12-15 17:01:04 +0100
commit1be07ceabb90b9ca510dd6ff3f2f3bdb6e448543 (patch)
tree8897b7fd209889561a5047f4fdc9edd95f61ee38 /src
parentMerge commit 'refs/merge-requests/71' of git://gitorious.org/rekonq/mainline ... (diff)
parentfactor out WebTab class from WebView (diff)
downloadrekonq-1be07ceabb90b9ca510dd6ff3f2f3bdb6e448543.tar.xz
I tried a bit, but this is not working pretty well :(
We are actually creating two widget for request. I'll merge it anyway to let you fix it :) Merge commit 'refs/merge-requests/72' of git://gitorious.org/rekonq/mainline into m72 Conflicts: src/mainview.cpp src/webview.cpp
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/application.cpp18
-rw-r--r--src/bookmarks/bookmarksmanager.cpp3
-rw-r--r--src/mainview.cpp172
-rw-r--r--src/mainview.h10
-rw-r--r--src/mainwindow.cpp38
-rw-r--r--src/mainwindow.h4
-rw-r--r--src/sessionmanager.cpp3
-rw-r--r--src/settings/settingsdialog.cpp8
-rw-r--r--src/tabbar.cpp6
-rw-r--r--src/walletwidget.cpp2
-rw-r--r--src/webinspectordock.cpp7
-rw-r--r--src/webpage.cpp8
-rw-r--r--src/webtab.cpp170
-rw-r--r--src/webtab.h70
-rw-r--r--src/webview.cpp55
-rw-r--r--src/webview.h25
17 files changed, 362 insertions, 238 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 7f95a1d2..e3527a41 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -18,6 +18,7 @@ SET( rekonq_KDEINIT_SRCS
webpluginfactory.cpp
websnap.cpp
webview.cpp
+ webtab.cpp
clicktoflash.cpp
networkaccessmanager.cpp
webinspectordock.cpp
diff --git a/src/application.cpp b/src/application.cpp
index cf77be57..cacdcb5a 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -38,7 +38,7 @@
#include "historymanager.h"
#include "bookmarksmanager.h"
#include "mainview.h"
-#include "webview.h"
+#include "webtab.h"
#include "urlbar.h"
#include "sessionmanager.h"
#include "adblockmanager.h"
@@ -290,7 +290,7 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type)
}
// first, create the webview(s) to not let hangs UI..
- WebView *webView = 0;
+ WebTab *webView = 0;
MainWindow *w = 0;
if(type == Rekonq::NewWindow)
w = newMainWindow();
@@ -300,18 +300,18 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type)
switch(type)
{
case Rekonq::SettingOpenTab:
- webView = w->mainView()->newWebView(!ReKonfig::openTabsBack(),
- ReKonfig::openTabsNearCurrent());
+ webView = w->mainView()->newWebTab(!ReKonfig::openTabsBack(),
+ ReKonfig::openTabsNearCurrent());
break;
case Rekonq::NewCurrentTab:
- webView = w->mainView()->newWebView(true);
+ webView = w->mainView()->newWebTab(true);
break;
case Rekonq::NewBackTab:
- webView = w->mainView()->newWebView(false, ReKonfig::openTabsNearCurrent());
+ webView = w->mainView()->newWebTab(false, ReKonfig::openTabsNearCurrent());
break;
case Rekonq::NewWindow:
case Rekonq::CurrentTab:
- webView = w->mainView()->currentWebView();
+ webView = w->mainView()->currentWebTab();
break;
};
@@ -358,7 +358,7 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type)
if (webView)
{
webView->setFocus();
- webView->load(loadingUrl);
+ webView->view()->load(loadingUrl);
}
}
@@ -372,7 +372,7 @@ void Application::loadUrl(const QString& urlString, const Rekonq::OpenType& typ
MainWindow *Application::newMainWindow()
{
MainWindow *w = new MainWindow();
- w->mainView()->newWebView(); // remember using newWebView and NOT newTab here!!
+ w->mainView()->newWebTab(); // remember using newWebView and NOT newTab here!!
m_mainWindows.prepend(w);
w->show();
diff --git a/src/bookmarks/bookmarksmanager.cpp b/src/bookmarks/bookmarksmanager.cpp
index 1c881e08..6442192a 100644
--- a/src/bookmarks/bookmarksmanager.cpp
+++ b/src/bookmarks/bookmarksmanager.cpp
@@ -32,6 +32,7 @@
// Local Includes
#include "mainwindow.h"
+#include "webtab.h"
#include "webview.h"
// KDE Includes
@@ -88,7 +89,7 @@ QString BookmarkOwner::currentUrl() const
QString BookmarkOwner::currentTitle() const
{
- return Application::instance()->mainWindow()->currentTab()->title();
+ return Application::instance()->mainWindow()->currentTab()->view()->title();
}
diff --git a/src/mainview.cpp b/src/mainview.cpp
index cf1aa7fd..9f5b433e 100644
--- a/src/mainview.cpp
+++ b/src/mainview.cpp
@@ -34,9 +34,9 @@
#include "rekonq.h"
// Local Includes
+#include "webtab.h"
#include "tabbar.h"
#include "urlbar.h"
-#include "walletwidget.h"
#include "sessionmanager.h"
// KDE Includes
@@ -49,7 +49,6 @@
#include <KStandardDirs>
#include <KPassivePopup>
#include <KLocalizedString>
-#include <kwebwallet.h>
// Qt Includes
#include <QtCore/QTimer>
@@ -176,15 +175,9 @@ UrlBar *MainView::urlBar() const
}
-WebView *MainView::currentWebView() const
-{
- return webView(currentIndex());
-}
-
-
-int MainView::webViewIndex(WebView *webView) const
+WebTab *MainView::currentWebTab() const
{
- return indexOf(webView->parentWidget());
+ return webTab(currentIndex());
}
@@ -220,16 +213,16 @@ void MainView::updateTabBar()
void MainView::webReload()
{
- WebView *webView = currentWebView();
- QAction *action = webView->page()->action(QWebPage::Reload);
+ WebTab *webTab = currentWebTab();
+ QAction *action = webTab->view()->page()->action(QWebPage::Reload);
action->trigger();
}
void MainView::webStop()
{
- WebView *webView = currentWebView();
- QAction *action = webView->page()->action(QWebPage::Stop);
+ WebTab *webTab = currentWebTab();
+ QAction *action = webTab->view()->page()->action(QWebPage::Stop);
action->trigger();
}
@@ -253,7 +246,7 @@ void MainView::reloadTab(int index)
if (index < 0 || index >= count())
return;
- webView(index)->reload();
+ webTab(index)->view()->reload();
}
@@ -261,12 +254,12 @@ void MainView::reloadTab(int index)
void MainView::currentChanged(int index)
{
// retrieve the webview related to the index
- WebView *webView = this->webView(index);
- if (!webView)
+ WebTab *webTab = this->webTab(index);
+ if (!webTab)
return;
// retrieve the old webview (that where we move from)
- WebView *oldWebView = this->webView(m_currentTabIndex);
+ WebView *oldWebView = this->webTab(m_currentTabIndex)->view();
// set current index
m_currentTabIndex = index;
@@ -286,19 +279,19 @@ void MainView::currentChanged(int index)
}
// connecting webview with urlbar
- connect(webView, SIGNAL(loadProgress(int)), urlBar(), SLOT(updateProgress(int)));
- connect(webView, SIGNAL(loadFinished(bool)), urlBar(), SLOT(loadFinished(bool)));
- connect(webView, SIGNAL(urlChanged(const QUrl &)), urlBar(), SLOT(setUrl(const QUrl &)));
+ connect(webTab->view(), SIGNAL(loadProgress(int)), urlBar(), SLOT(updateProgress(int)));
+ connect(webTab->view(), SIGNAL(loadFinished(bool)), urlBar(), SLOT(loadFinished(bool)));
+ connect(webTab->view(), SIGNAL(urlChanged(const QUrl &)), urlBar(), SLOT(setUrl(const QUrl &)));
- connect(webView->page(), SIGNAL(statusBarMessage(const QString&)),
+ connect(webTab->view()->page(), SIGNAL(statusBarMessage(const QString&)),
this, SIGNAL(showStatusBarMessage(const QString&)));
- connect(webView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)),
+ connect(webTab->view()->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)),
this, SIGNAL(linkHovered(const QString&)));
- emit setCurrentTitle(webView->title());
- urlBar()->setUrl(webView->url());
- urlBar()->setProgress(webView->progress());
- emit showStatusBarMessage(webView->lastStatusBarText());
+ emit setCurrentTitle(webTab->view()->title());
+ urlBar()->setUrl(webTab->view()->url());
+ urlBar()->setProgress(webTab->progress());
+ emit showStatusBarMessage(webTab->lastStatusBarText());
// notify UI to eventually switch stop/reload button
if(urlBar()->isLoading())
@@ -307,22 +300,15 @@ void MainView::currentChanged(int index)
emit browserTabLoading(false);
// set focus to the current webview
- webView->setFocus();
+ webTab->setFocus();
}
-WebView *MainView::webView(int index) const
+WebTab *MainView::webTab(int index) const
{
- if( this->widget(index)
- && this->widget(index)->layout()
- && this->widget(index)->layout()->itemAt(1) //TODO: find why it crashes when closetab without that.
- )
+ if (WebTab *webTab = qobject_cast<WebTab*>(this->widget(index)))
{
- QWidget *widget = this->widget(index)->layout()->itemAt(1)->widget();
- if (WebView *webView = qobject_cast<WebView*>(widget))
- {
- return webView;
- }
+ return webTab;
}
kDebug() << "WebView with index " << index << "not found. Returning NULL." ;
@@ -330,80 +316,42 @@ WebView *MainView::webView(int index) const
}
-WebView *MainView::newWebView(bool focused, bool nearParent)
+WebTab *MainView::newWebTab(bool focused, bool nearParent)
{
- QWidget* w=new QWidget(this);
-
- QVBoxLayout* l=new QVBoxLayout(w);
- l->setMargin(0);
- l->setSpacing(0);
-
- QWidget* messageBar=new QWidget(w);
- l->addWidget(messageBar);
- messageBar->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum);
-
- QVBoxLayout* l2 = new QVBoxLayout(messageBar);
- l2->setMargin(0);
- l2->setSpacing(0);
+ WebTab* webTab = new WebTab(this);
- WebView *webView = new WebView(w);
- l->addWidget(webView);
- webView->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
-
- KWebWallet *wallet = webView->page()->wallet();
- if(wallet)
- {
- connect(wallet, SIGNAL(saveFormDataRequested(const QString &, const QUrl &)),
- this, SLOT(createWalletBar(const QString &, const QUrl &)));
- }
-
// connecting webview with mainview
- connect(webView, SIGNAL(loadStarted()), this, SLOT(webViewLoadStarted()));
- connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(webViewLoadFinished(bool)));
- connect(webView, SIGNAL(iconChanged()), this, SLOT(webViewIconChanged()));
- connect(webView, SIGNAL(titleChanged(const QString &)), this, SLOT(webViewTitleChanged(const QString &)));
- connect(webView, SIGNAL(urlChanged(const QUrl &)), this, SLOT(webViewUrlChanged(const QUrl &)));
+ connect(webTab->view(), SIGNAL(loadStarted()), this, SLOT(webViewLoadStarted()));
+ connect(webTab->view(), SIGNAL(loadFinished(bool)), this, SLOT(webViewLoadFinished(bool)));
+ connect(webTab->view(), SIGNAL(iconChanged()), this, SLOT(webViewIconChanged()));
+ connect(webTab->view(), SIGNAL(titleChanged(const QString &)), this, SLOT(webViewTitleChanged(const QString &)));
+ connect(webTab->view(), SIGNAL(urlChanged(const QUrl &)), this, SLOT(webViewUrlChanged(const QUrl &)));
// connecting webPage signals with mainview
- connect(webView->page(), SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested()));
- connect(webView->page(), SIGNAL(printRequested(QWebFrame *)), this, SIGNAL(printRequested(QWebFrame *)));
+ connect(webTab->view()->page(), SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested()));
+ connect(webTab->view()->page(), SIGNAL(printRequested(QWebFrame *)), this, SIGNAL(printRequested(QWebFrame *)));
if (nearParent)
- insertTab(currentIndex() + 1, w, i18n("(Untitled)"));
+ insertTab(currentIndex() + 1, webTab, i18n("(Untitled)"));
else
- addTab(w, i18n("(Untitled)"));
+ addTab(webTab, i18n("(Untitled)"));
updateTabBar();
if (focused)
{
- setCurrentWidget(w);
+ setCurrentWidget(webTab);
}
emit tabsChanged();
- return webView;
+ return webTab;
}
-void MainView::createWalletBar(const QString &key, const QUrl &url)
-{
- KWebWallet *wallet = currentWebView()->page()->wallet();
- QWidget *messageBar=this->widget(currentIndex())->layout()->itemAt(0)->widget();
-
- WalletWidget *walletBar = new WalletWidget(messageBar);
- walletBar->onSaveFormData(key,url);
- messageBar->layout()->addWidget(walletBar);
-
- connect(walletBar, SIGNAL(saveFormDataAccepted(const QString &)),
- wallet, SLOT(acceptSaveFormDataRequest(const QString &)));
- connect(walletBar, SIGNAL(saveFormDataRejected(const QString &)),
- wallet, SLOT(rejectSaveFormDataRequest(const QString &)));
-}
-
void MainView::newTab()
{
- WebView *w = newWebView();
+ WebTab *w = newWebTab();
switch(ReKonfig::newTabsBehaviour())
{
@@ -414,7 +362,7 @@ void MainView::newTab()
urlBar()->setUrl(KUrl(""));
break;
case 2: // homepage
- w->load( QUrl(ReKonfig::homePage()) );
+ w->view()->load( QUrl(ReKonfig::homePage()) );
break;
default:
break;
@@ -427,7 +375,7 @@ void MainView::reloadAllTabs()
{
for (int i = 0; i < count(); ++i)
{
- webView(i)->reload();
+ webTab(i)->view()->reload();
}
}
@@ -435,8 +383,8 @@ void MainView::reloadAllTabs()
void MainView::windowCloseRequested()
{
WebPage *webPage = qobject_cast<WebPage*>(sender());
- WebView *webView = qobject_cast<WebView*>(webPage->view());
- int index = webViewIndex(webView);
+ WebTab *webView = qobject_cast<WebTab*>(webPage->view());
+ int index = indexOf(webView->parentWidget());
if (index >= 0)
{
@@ -481,14 +429,14 @@ void MainView::cloneTab(int index)
if (index < 0 || index >= count())
return;
- WebView *tab = newWebView();
- KUrl url = webView(index)->url();
+ WebTab *tab = newWebTab();
+ KUrl url = webTab(index)->url();
// workaround against bug in webkit:
// only set url if it is not empty
// otherwise the current working directory will be used
if (!url.isEmpty())
- tab->setUrl(url);
+ tab->view()->setUrl(url);
updateTabBar();
}
@@ -507,9 +455,9 @@ void MainView::closeTab(int index)
return;
bool hasFocus = false;
- if (WebView *tab = webView(index))
+ if (WebTab *tab = webTab(index))
{
- if (tab->isModified())
+ if (tab->view()->isModified())
{
int risp = KMessageBox::questionYesNo(this,
i18n("This tab contains changes that have not been submitted.\n"
@@ -524,7 +472,7 @@ void MainView::closeTab(int index)
//store close tab except homepage
if (!tab->url().prettyUrl().startsWith( QLatin1String("about:") ) && !tab->url().isEmpty())
{
- QString title = tab->title();
+ QString title = tab->view()->title();
QString url = tab->url().prettyUrl();
HistoryItem item(url, QDateTime::currentDateTime(), title);
m_recentlyClosedTabs.removeAll(item);
@@ -532,7 +480,7 @@ void MainView::closeTab(int index)
}
}
- QWidget *webView = this->webView(index);
+ QWidget *webView = this->webTab(index);
removeTab(index);
updateTabBar(); // UI operation: do it ASAP!!
webView->deleteLater(); // webView is scheduled for deletion.
@@ -541,15 +489,15 @@ void MainView::closeTab(int index)
if (hasFocus && count() > 0)
{
- currentWebView()->setFocus();
+ currentWebTab()->setFocus();
}
}
void MainView::webViewLoadStarted()
{
- WebView *webView = qobject_cast<WebView*>(sender());
- int index = webViewIndex(webView);
+ KWebView *webView = qobject_cast<KWebView*>(sender());
+ int index = indexOf(webView->parentWidget());
if (-1 != index)
{
QLabel *label = animatedLoading(index, true);
@@ -570,8 +518,8 @@ void MainView::webViewLoadStarted()
void MainView::webViewLoadFinished(bool ok)
{
- WebView *webView = qobject_cast<WebView*>(sender());
- int index = webViewIndex(webView);
+ KWebView *webView = qobject_cast<KWebView*>(sender());
+ int index = indexOf(webView->parentWidget());
if (-1 != index)
{
@@ -599,8 +547,8 @@ void MainView::webViewLoadFinished(bool ok)
void MainView::webViewIconChanged()
{
- WebView *webView = qobject_cast<WebView*>(sender());
- int index = webViewIndex(webView);
+ KWebView *webView = qobject_cast<KWebView*>(sender());
+ int index = indexOf(webView->parentWidget());
if (-1 != index)
{
QIcon icon = Application::icon(webView->url());
@@ -622,8 +570,8 @@ void MainView::webViewTitleChanged(const QString &title)
{
tabTitle = i18n("(Untitled)");
}
- WebView *webView = qobject_cast<WebView*>(sender());
- int index = webViewIndex(webView);
+ KWebView *webView = qobject_cast<KWebView*>(sender());
+ int index = indexOf(webView->parentWidget());
if (-1 != index)
{
setTabText(index, tabTitle);
@@ -638,8 +586,8 @@ void MainView::webViewTitleChanged(const QString &title)
void MainView::webViewUrlChanged(const QUrl &url)
{
- WebView *webView = qobject_cast<WebView*>(sender());
- int index = webViewIndex(webView);
+ KWebView *webView = qobject_cast<KWebView*>(sender());
+ int index = indexOf(webView->parentWidget());
if (-1 != index)
{
m_tabBar->setTabData(index, url);
diff --git a/src/mainview.h b/src/mainview.h
index d16743b1..23db69c0 100644
--- a/src/mainview.h
+++ b/src/mainview.h
@@ -71,11 +71,10 @@ public:
public:
UrlBar *urlBar() const;
- WebView *webView(int index) const;
+ WebTab *webTab(int index) const;
TabBar *tabBar() const;
- WebView *currentWebView() const;
- int webViewIndex(WebView *webView) const;
+ WebTab *currentWebTab() const;
/**
* show and hide TabBar if user doesn't choose
@@ -95,7 +94,7 @@ public:
* @param nearParent decide if you wanna create new tab near current or not
* @return the webview embedded in the new tab
*/
- WebView *newWebView(bool focused = true, bool nearParent = false);
+ WebTab *newWebTab(bool focused = true, bool nearParent = false);
QList<HistoryItem> recentlyClosedTabs();
@@ -146,8 +145,7 @@ private slots:
void postLaunch();
- void createWalletBar(const QString &, const QUrl &);
-
+
protected:
virtual void resizeEvent(QResizeEvent *event);
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index e772baf1..b141401c 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -37,7 +37,7 @@
#include "settingsdialog.h"
#include "historymanager.h"
#include "bookmarksmanager.h"
-#include "webview.h"
+#include "webtab.h"
#include "mainview.h"
#include "findbar.h"
#include "sidepanel.h"
@@ -616,10 +616,10 @@ void MainWindow::preferences()
void MainWindow::updateActions()
{
QAction *historyBackAction = actionByName(KStandardAction::name(KStandardAction::Back));
- historyBackAction->setEnabled(currentTab()->history()->canGoBack());
+ historyBackAction->setEnabled(currentTab()->view()->history()->canGoBack());
QAction *historyForwardAction = actionByName(KStandardAction::name(KStandardAction::Forward));
- historyForwardAction->setEnabled(currentTab()->history()->canGoForward());
+ historyForwardAction->setEnabled(currentTab()->view()->history()->canGoForward());
}
@@ -746,7 +746,7 @@ void MainWindow::findNext()
if (m_findBar->matchCase())
options |= QWebPage::FindCaseSensitively;
- m_findBar->notifyMatch(currentTab()->findText(m_lastSearch, options));
+ m_findBar->notifyMatch(currentTab()->view()->findText(m_lastSearch, options));
}
@@ -759,7 +759,7 @@ void MainWindow::findPrevious()
if (m_findBar->matchCase())
options |= QWebPage::FindCaseSensitively;
- m_findBar->notifyMatch(currentTab()->findText(m_lastSearch, options));
+ m_findBar->notifyMatch(currentTab()->view()->findText(m_lastSearch, options));
}
@@ -767,7 +767,7 @@ void MainWindow::viewTextBigger()
{
if (!currentTab())
return;
- currentTab()->setTextSizeMultiplier(currentTab()->textSizeMultiplier() + 0.1);
+ currentTab()->view()->setTextSizeMultiplier(currentTab()->view()->textSizeMultiplier() + 0.1);
}
@@ -775,7 +775,7 @@ void MainWindow::viewTextNormal()
{
if (!currentTab())
return;
- currentTab()->setTextSizeMultiplier(1.0);
+ currentTab()->view()->setTextSizeMultiplier(1.0);
}
@@ -783,7 +783,7 @@ void MainWindow::viewTextSmaller()
{
if (!currentTab())
return;
- currentTab()->setTextSizeMultiplier(currentTab()->textSizeMultiplier() - 0.1);
+ currentTab()->view()->setTextSizeMultiplier(currentTab()->view()->textSizeMultiplier() - 0.1);
}
@@ -857,7 +857,7 @@ void MainWindow::viewPageSource()
void MainWindow::homePage()
{
- currentTab()->load( QUrl(ReKonfig::homePage()) );
+ currentTab()->view()->load( QUrl(ReKonfig::homePage()) );
}
@@ -868,9 +868,9 @@ MainView *MainWindow::mainView() const
-WebView *MainWindow::currentTab() const
+WebTab *MainWindow::currentTab() const
{
- return m_view->currentWebView();
+ return m_view->currentWebTab();
}
@@ -900,7 +900,7 @@ void MainWindow::browserLoading(bool v)
void MainWindow::openPrevious()
{
- QWebHistory *history = currentTab()->history();
+ QWebHistory *history = currentTab()->view()->history();
if (history->canGoBack())
history->goToItem(history->backItem());
}
@@ -908,7 +908,7 @@ void MainWindow::openPrevious()
void MainWindow::openNext()
{
- QWebHistory *history = currentTab()->history();
+ QWebHistory *history = currentTab()->view()->history();
if (history->canGoForward())
history->goToItem(history->forwardItem());
}
@@ -1041,21 +1041,21 @@ void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status)
m_popup->layout()->setMargin(margin);
// useful values
- bool scrollbarIsVisible = m_view->currentWebView()->page()->currentFrame()->scrollBarMaximum(Qt::Horizontal);
+ bool scrollbarIsVisible = m_view->currentWebTab()->page()->currentFrame()->scrollBarMaximum(Qt::Horizontal);
int scrollbarSize = 0;
if (scrollbarIsVisible)
{
//TODO: detect QStyle size
scrollbarSize = 17;
}
- QPoint webViewOrigin = m_view->currentWebView()->mapToGlobal(QPoint(0,0));
- int bottomLeftY=webViewOrigin.y() + m_view->currentWebView()->page()->viewportSize().height() - labelSize.height() - scrollbarSize;
+ QPoint webViewOrigin = m_view->currentWebTab()->mapToGlobal(QPoint(0,0));
+ int bottomLeftY=webViewOrigin.y() + m_view->currentWebTab()->page()->viewportSize().height() - labelSize.height() - scrollbarSize;
// setting popup in bottom-left position
int x = geometry().x();
int y = bottomLeftY;
- QPoint mousePos = m_view->currentWebView()->mapToGlobal(m_view->currentWebView()->mousePos());
+ QPoint mousePos = m_view->currentWebTab()->mapToGlobal(m_view->currentWebTab()->view()->mousePos());
if(QRect(webViewOrigin.x(),bottomLeftY,labelSize.width(),labelSize.height()).contains(mousePos))
{
// setting popup above the mouse
@@ -1121,7 +1121,7 @@ void MainWindow::aboutToShowBackMenu()
m_historyBackMenu->clear();
if (!currentTab())
return;
- QWebHistory *history = currentTab()->history();
+ QWebHistory *history = currentTab()->view()->history();
int historyCount = history->count();
// Limit history views in the menu to 8
@@ -1144,7 +1144,7 @@ void MainWindow::aboutToShowBackMenu()
void MainWindow::openActionUrl(QAction *action)
{
int offset = action->data().toInt();
- QWebHistory *history = currentTab()->history();
+ QWebHistory *history = currentTab()->view()->history();
if(!history->itemAt(offset).isValid())
{
diff --git a/src/mainwindow.h b/src/mainwindow.h
index f07a46da..5360d264 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -49,7 +49,7 @@ class FindBar;
class SidePanel;
class BookmarksPanel;
class WebInspectorDock;
-class WebView;
+class WebTab;
class MainView;
@@ -67,7 +67,7 @@ public:
~MainWindow();
MainView *mainView() const;
- WebView *currentTab() const;
+ WebTab *currentTab() const;
QAction *actionByName(const QString name);
virtual QSize sizeHint() const;
virtual KActionCollection *actionCollection () const;
diff --git a/src/sessionmanager.cpp b/src/sessionmanager.cpp
index 06bcb83a..f4e7cd3e 100644
--- a/src/sessionmanager.cpp
+++ b/src/sessionmanager.cpp
@@ -34,6 +34,7 @@
#include "application.h"
#include "mainwindow.h"
#include "mainview.h"
+#include "webtab.h"
// KDE Includes
#include <KStandardDirs>
@@ -76,7 +77,7 @@ void SessionManager::saveSession()
MainView *mv = w->mainView();
for (int i = 0 ; i < mv->count() ; i++)
{
- out << mv->webView(i)->url().toEncoded() << "\n";
+ out << mv->webTab(i)->url().toEncoded() << "\n";
}
}
sessionFile.close();
diff --git a/src/settings/settingsdialog.cpp b/src/settings/settingsdialog.cpp
index ee0c1794..e37481aa 100644
--- a/src/settings/settingsdialog.cpp
+++ b/src/settings/settingsdialog.cpp
@@ -36,7 +36,7 @@
// Local Includes
#include "application.h"
#include "mainwindow.h"
-#include "webview.h"
+#include "webtab.h"
//Ui Includes
#include "ui_settings_general.h"
@@ -235,9 +235,9 @@ bool SettingsDialog::hasChanged()
void SettingsDialog::setHomeToCurrentPage()
{
MainWindow *mw = static_cast<MainWindow*>(parent());
- WebView *webView = mw->currentTab();
- if (webView)
+ WebTab *webTab = mw->currentTab();
+ if (webTab)
{
- d->generalUi.kcfg_homePage->setText(webView->url().prettyUrl());
+ d->generalUi.kcfg_homePage->setText(webTab->url().prettyUrl());
}
}
diff --git a/src/tabbar.cpp b/src/tabbar.cpp
index 1246d669..ada879a3 100644
--- a/src/tabbar.cpp
+++ b/src/tabbar.cpp
@@ -36,7 +36,7 @@
#include "application.h"
#include "mainwindow.h"
#include "urlbar.h"
-#include "webview.h"
+#include "webtab.h"
#include "websnap.h"
#include "mainview.h"
@@ -144,8 +144,8 @@ void TabBar::showTabPreview(int tab)
{
MainView *mv = qobject_cast<MainView *>(parent());
- WebView *view = mv->webView(tab);
- WebView *currentView = mv->webView(currentIndex());
+ WebTab *view = mv->webTab(tab);
+ WebTab *currentView = mv->webTab(currentIndex());
// should fix bug #212219
if(!currentView)
diff --git a/src/walletwidget.cpp b/src/walletwidget.cpp
index 156a3ba5..c7100a4d 100644
--- a/src/walletwidget.cpp
+++ b/src/walletwidget.cpp
@@ -38,6 +38,7 @@
#include <QHBoxLayout>
#include <QString>
+
WalletWidget::WalletWidget(QWidget *parent)
: QWidget(parent)
, m_label( new QLabel(this) )
@@ -95,6 +96,7 @@ void WalletWidget::notNowRememberData()
destroy();
}
+
void WalletWidget::destroy()
{
if (parentWidget() && parentWidget()->layout())
diff --git a/src/webinspectordock.cpp b/src/webinspectordock.cpp
index f91df31a..2c17a607 100644
--- a/src/webinspectordock.cpp
+++ b/src/webinspectordock.cpp
@@ -28,6 +28,7 @@
#include "webinspectordock.moc"
// Local Includes
+#include "webtab.h"
#include "webview.h"
#include "webpage.h"
@@ -64,20 +65,20 @@ void WebInspectorDock::toggle(bool enable)
mainWindow()->actionByName("web_inspector")->setChecked(enable);
if (enable)
{
- mainWindow()->currentTab()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
+ mainWindow()->currentTab()->view()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
findChild<QWebInspector *>()->setPage(mainWindow()->currentTab()->page());
show();
}
else
{
hide();
- mainWindow()->currentTab()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, false);
+ mainWindow()->currentTab()->view()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, false);
}
}
void WebInspectorDock::changeCurrentPage()
{
- bool enable = mainWindow()->currentTab()->settings()->testAttribute(QWebSettings::DeveloperExtrasEnabled);
+ bool enable = mainWindow()->currentTab()->view()->settings()->testAttribute(QWebSettings::DeveloperExtrasEnabled);
toggle(enable);
}
diff --git a/src/webpage.cpp b/src/webpage.cpp
index 1f7738ea..3fc0aac4 100644
--- a/src/webpage.cpp
+++ b/src/webpage.cpp
@@ -39,7 +39,7 @@
#include "application.h"
#include "mainwindow.h"
#include "mainview.h"
-#include "webview.h"
+#include "webtab.h"
#include "webpluginfactory.h"
#include "networkaccessmanager.h"
@@ -126,14 +126,14 @@ WebPage *WebPage::createWindow(QWebPage::WebWindowType type)
if (type == QWebPage::WebModalDialog)
kDebug() << "Modal Dialog";
- WebView *w = 0;
+ WebTab *w = 0;
if(ReKonfig::openTabNoWindow())
{
- w = Application::instance()->mainWindow()->mainView()->newWebView(!ReKonfig::openTabsBack());
+ w = Application::instance()->mainWindow()->mainView()->newWebTab(!ReKonfig::openTabsBack());
}
else
{
- w = Application::instance()->newMainWindow()->mainView()->currentWebView();
+ w = Application::instance()->newMainWindow()->mainView()->currentWebTab();
}
return w->page();
}
diff --git a/src/webtab.cpp b/src/webtab.cpp
new file mode 100644
index 00000000..31dd1ca6
--- /dev/null
+++ b/src/webtab.cpp
@@ -0,0 +1,170 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2008-2009 by Andrea Diamantini <adjam7 at gmail dot com>
+* Copyright (C) 2009 by Lionel Chauvin <megabigbug@yahoo.fr>
+*
+*
+* 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 of
+* the License or (at your option) version 3 or any later version
+* accepted by the membership of KDE e.V. (or its successor approved
+* by the membership of KDE e.V.), which shall act as a proxy
+* defined in Section 14 of version 3 of the license.
+*
+* 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.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+* ============================================================ */
+
+
+// Self Includes
+#include "webtab.h"
+#include "webtab.moc"
+
+// Auto Includes
+#include "rekonq.h"
+
+// Local Includes
+#include "application.h"
+#include "mainwindow.h"
+#include "mainview.h"
+#include "webpage.h"
+#include "bookmarksmanager.h"
+#include "walletwidget.h"
+
+// KDE Includes
+#include <KService>
+#include <KUriFilterData>
+#include <KStandardShortcut>
+#include <KMenu>
+#include <KActionMenu>
+#include <KWebView>
+#include <kwebwallet.h>
+
+// Qt Includes
+#include <QContextMenuEvent>
+#include <QWheelEvent>
+#include <QMouseEvent>
+#include <QClipboard>
+#include <QKeyEvent>
+#include <QAction>
+#include <QVBoxLayout>
+
+
+WebTab::WebTab(QWidget* parent)
+ : QWidget(parent)
+ , m_view( new WebView(parent) )
+ , m_progress(0)
+{
+ QVBoxLayout* l = new QVBoxLayout(this);
+ l->setMargin(0);
+
+ QWidget* messageBar = new QWidget(this);
+ l->addWidget(messageBar);
+ messageBar->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum);
+
+ QVBoxLayout* l2 = new QVBoxLayout(messageBar);
+ l2->setMargin(0);
+ l2->setSpacing(0);
+
+ l->addWidget(m_view);
+ m_view->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
+
+ KWebWallet *wallet = page()->wallet();
+
+ if(wallet)
+ {
+ connect(wallet, SIGNAL(saveFormDataRequested(const QString &, const QUrl &)),
+ this, SLOT(createWalletBar(const QString &, const QUrl &)));
+ }
+
+ connect(page(), SIGNAL(statusBarMessage(const QString&)), this, SLOT(setStatusBarText(const QString&)));
+
+ connect(m_view, SIGNAL(loadProgress(int)), this, SLOT(updateProgress(int)));
+ connect(m_view, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool)));
+
+ connect(m_view, SIGNAL(linkMiddleOrCtrlClicked(const KUrl &)), this, SLOT(loadInNewTab(const KUrl &)) );
+}
+
+
+WebTab::~WebTab()
+{
+}
+
+
+WebView *WebTab::view()
+{
+ return m_view;
+}
+
+
+WebPage *WebTab::page()
+{
+ return m_view->page();
+}
+
+
+KUrl WebTab::url() const
+{
+ return KUrl(m_view->url());
+}
+
+
+int WebTab::progress()
+{
+ return m_progress;
+}
+
+
+QString WebTab::lastStatusBarText() const
+{
+ return m_statusBarText;
+}
+
+
+void WebTab::setStatusBarText(const QString &string)
+{
+ m_statusBarText = string;
+}
+
+
+void WebTab::updateProgress(int p)
+{
+ m_progress = p;
+}
+
+
+void WebTab::loadFinished(bool)
+{
+ m_progress = 0;
+}
+
+
+void WebTab::loadInNewTab(const KUrl &url)
+{
+ Application::instance()->loadUrl(url, Rekonq::NewCurrentTab);
+}
+
+
+void WebTab::createWalletBar(const QString &key, const QUrl &url)
+{
+ KWebWallet *wallet = page()->wallet();
+ QWidget *messageBar = layout()->itemAt(0)->widget();
+
+ WalletWidget *walletBar = new WalletWidget(messageBar);
+ walletBar->onSaveFormData(key,url);
+ messageBar->layout()->addWidget(walletBar);
+
+ connect(walletBar, SIGNAL(saveFormDataAccepted(const QString &)),
+ wallet, SLOT(acceptSaveFormDataRequest(const QString &)));
+ connect(walletBar, SIGNAL(saveFormDataRejected(const QString &)),
+ wallet, SLOT(rejectSaveFormDataRequest(const QString &)));
+}
diff --git a/src/webtab.h b/src/webtab.h
new file mode 100644
index 00000000..2eb8d733
--- /dev/null
+++ b/src/webtab.h
@@ -0,0 +1,70 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2008-2009 by Andrea Diamantini <adjam7 at gmail dot com>
+* Copyright (C) 2009 by Lionel Chauvin <megabigbug@yahoo.fr>
+*
+*
+* 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 of
+* the License or (at your option) version 3 or any later version
+* accepted by the membership of KDE e.V. (or its successor approved
+* by the membership of KDE e.V.), which shall act as a proxy
+* defined in Section 14 of version 3 of the license.
+*
+* 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.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+* ============================================================ */
+
+
+#ifndef WEBTAB_H
+#define WEBTAB_H
+
+
+// KDE Includes
+#include <KUrl>
+#include <KWebView>
+
+// Forward Declarations
+class WebPage;
+class WebView;
+
+
+class WebTab : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit WebTab(QWidget *parent = 0);
+ ~WebTab();
+
+ WebView *view();
+ WebPage *page();
+ KUrl url() const;
+ QString lastStatusBarText() const;
+ int progress();
+
+private slots:
+ void setStatusBarText(const QString &string);
+ void updateProgress(int progress);
+ void loadFinished(bool);
+
+ void loadInNewTab(const KUrl &url);
+
+ void createWalletBar(const QString &, const QUrl &);
+
+private:
+ WebView *const m_view;
+ int m_progress;
+ QString m_statusBarText;
+};
+
+#endif
diff --git a/src/webview.cpp b/src/webview.cpp
index a1033fb6..0ba04bc2 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -59,17 +59,10 @@
WebView::WebView(QWidget* parent)
: KWebView(parent, false)
, m_page( new WebPage(this) )
- , m_progress(0)
, m_mousePos(QPoint(0,0))
{
setPage(m_page);
- connect(m_page, SIGNAL(statusBarMessage(const QString&)), this, SLOT(setStatusBarText(const QString&)));
-
- connect(this, SIGNAL(loadProgress(int)), this, SLOT(updateProgress(int)));
- connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool)));
- connect(this, SIGNAL(linkMiddleOrCtrlClicked(const KUrl &)), this, SLOT(loadInNewTab(const KUrl &)) );
-
// download system
connect(this, SIGNAL(linkShiftClicked(const KUrl &)), m_page, SLOT(downloadUrl(const KUrl &)));
connect(m_page, SIGNAL(downloadRequested(const QNetworkRequest &)), m_page, SLOT(downloadRequest(const QNetworkRequest &)));
@@ -81,36 +74,6 @@ WebView::~WebView()
}
-WebPage *WebView::page()
-{
- return m_page;
-}
-
-
-KUrl WebView::url() const
-{
- return KUrl(QWebView::url());
-}
-
-
-int WebView::progress()
-{
- return m_progress;
-}
-
-
-QString WebView::lastStatusBarText() const
-{
- return m_statusBarText;
-}
-
-
-void WebView::setStatusBarText(const QString &string)
-{
- m_statusBarText = string;
-}
-
-
void WebView::contextMenuEvent(QContextMenuEvent *event)
{
QWebHitTestResult result = page()->mainFrame()->hitTestContent(event->pos());
@@ -356,18 +319,6 @@ void WebView::search()
}
-void WebView::updateProgress(int p)
-{
- m_progress = p;
-}
-
-
-void WebView::loadFinished(bool)
-{
- m_progress = 0;
-}
-
-
void WebView::printFrame()
{
Application::instance()->mainWindow()->printRequested(page()->currentFrame());
@@ -422,9 +373,3 @@ void WebView::keyPressEvent(QKeyEvent *event)
KWebView::keyPressEvent(event);
}
-
-
-void WebView::loadInNewTab(const KUrl &url)
-{
- Application::instance()->loadUrl(url, Rekonq::NewCurrentTab);
-}
diff --git a/src/webview.h b/src/webview.h
index 2b3b97a4..60c8c9fc 100644
--- a/src/webview.h
+++ b/src/webview.h
@@ -30,9 +30,6 @@
// KDE Includes
-#include <KUrl>
-
-// Qt Includes
#include <KWebView>
// Forward Declarations
@@ -44,39 +41,29 @@ class WebView : public KWebView
Q_OBJECT
public:
- explicit WebView(QWidget *parent = 0);
+ explicit WebView(QWidget *parent);
~WebView();
-
- WebPage *page();
- KUrl url() const;
- QString lastStatusBarText() const;
- int progress();
+
+ WebPage *page() { return m_page; }
QPoint mousePos();
-
+
protected:
void contextMenuEvent(QContextMenuEvent *event);
void mousePressEvent(QMouseEvent *event);// need to be ported
void mouseMoveEvent(QMouseEvent *event);
void keyPressEvent(QKeyEvent *event);
-
+
private slots:
- void setStatusBarText(const QString &string);
void search();
- void updateProgress(int progress);
- void loadFinished(bool);
void printFrame();
- void viewImage(Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
void openLinkInNewWindow();
void openLinkInNewTab();
+ void viewImage(Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
- void loadInNewTab(const KUrl &url);
-
private:
WebPage *const m_page;
- int m_progress;
- QString m_statusBarText;
QPoint m_mousePos;
};