summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/application.cpp2
-rw-r--r--src/findbar.cpp9
-rw-r--r--src/mainview.cpp18
-rw-r--r--src/mainview.h12
-rw-r--r--src/mainwindow.cpp38
-rw-r--r--src/mainwindow.h13
-rw-r--r--src/protocolhandler.cpp2
-rw-r--r--src/webpage.cpp40
-rw-r--r--src/webtab.cpp32
-rw-r--r--src/webtab.h15
-rw-r--r--src/webview.cpp2
11 files changed, 131 insertions, 52 deletions
diff --git a/src/application.cpp b/src/application.cpp
index 2efb62c0..95aa9cf0 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -439,7 +439,7 @@ void Application::loadResolvedUrl(ThreadWeaver::Job *job)
void Application::newWindow()
{
loadUrl(KUrl("about:home"), Rekonq::NewWindow);
- mainWindow()->mainView()->urlBar()->setFocus();
+ mainWindow()->mainView()->currentUrlBar()->setFocus();
}
diff --git a/src/findbar.cpp b/src/findbar.cpp
index 3f7825da..158849f9 100644
--- a/src/findbar.cpp
+++ b/src/findbar.cpp
@@ -31,6 +31,8 @@
// Local Includes
#include "mainwindow.h"
+#include "webtab.h"
+#include "webpage.h"
// KDE Includes
#include <KApplication>
@@ -154,6 +156,13 @@ bool FindBar::highlightAllState() const
void FindBar::setVisible(bool visible)
{
+ if (visible && m_mainWindow->currentTab()->page()->isOnRekonqPage() && m_mainWindow->currentTab()->part() != 0)
+ {
+ // findNext is the slot containing part integration code
+ m_mainWindow->findNext();
+ return;
+ }
+
QWidget::setVisible(visible);
if (visible)
diff --git a/src/mainview.cpp b/src/mainview.cpp
index d080ad9a..1efcb0e4 100644
--- a/src/mainview.cpp
+++ b/src/mainview.cpp
@@ -161,9 +161,9 @@ TabBar *MainView::tabBar() const
}
-UrlBar *MainView::urlBar() const
+UrlBar *MainView::currentUrlBar() const
{
- return m_widgetBar->urlBar(m_currentTabIndex);
+ return webTab(currentIndex())->urlBar();
}
@@ -306,7 +306,7 @@ WebTab *MainView::newWebTab(bool focused)
// connecting webview with mainview
connect(tab->view(), SIGNAL(loadStarted()), this, SLOT(webViewLoadStarted()));
connect(tab->view(), SIGNAL(loadFinished(bool)), this, SLOT(webViewLoadFinished(bool)));
- connect(tab->view(), SIGNAL(titleChanged(const QString &)), this, SLOT(webViewTitleChanged(const QString &)));
+ connect(tab, SIGNAL(titleChanged(const QString &)), this, SLOT(webViewTitleChanged(const QString &)));
connect(tab->view(), SIGNAL(urlChanged(const QUrl &)), this, SLOT(webViewUrlChanged(const QUrl &)));
connect(tab->view(), SIGNAL(iconChanged()), this, SLOT(webViewIconChanged()));
@@ -347,7 +347,7 @@ void MainView::newTab()
w->load(KUrl("about:home"));
break;
case 1: // blank page
- urlBar()->clear();
+ currentUrlBar()->clear();
break;
case 2: // homepage
w->load(KUrl(ReKonfig::homePage()));
@@ -355,7 +355,7 @@ void MainView::newTab()
default:
break;
}
- urlBar()->setFocus();
+ currentUrlBar()->setFocus();
}
@@ -442,7 +442,7 @@ void MainView::closeTab(int index, bool del)
case 0: // new tab page
case 1: // blank page
w->load(KUrl("about:home"));
- urlBar()->setFocus();
+ currentUrlBar()->setFocus();
break;
case 2: // homepage
w->load(KUrl(ReKonfig::homePage()));
@@ -576,8 +576,8 @@ void MainView::webViewTitleChanged(const QString &title)
QString tabTitle = viewTitle;
tabTitle.replace('&', "&&");
- WebView *view = qobject_cast<WebView *>(sender());
- int index = indexOf(view->parentWidget());
+ WebTab *tab = qobject_cast<WebTab *>(sender());
+ int index = indexOf(tab);
if (-1 != index)
{
setTabText(index, tabTitle);
@@ -586,7 +586,7 @@ void MainView::webViewTitleChanged(const QString &title)
{
emit currentTitle(viewTitle);
}
- Application::historyManager()->updateHistoryEntry(view->url(), tabTitle);
+ Application::historyManager()->updateHistoryEntry(tab->url(), tabTitle);
}
diff --git a/src/mainview.h b/src/mainview.h
index 46e4133b..3cb34886 100644
--- a/src/mainview.h
+++ b/src/mainview.h
@@ -68,11 +68,13 @@ public:
MainView(MainWindow *parent);
inline StackedUrlBar *widgetBar() const { return m_widgetBar; }
- UrlBar *urlBar() const;
- WebTab *webTab(int index) const;
TabBar *tabBar() const;
+
WebTab *currentWebTab() const;
+ UrlBar *currentUrlBar() const;
+
+ WebTab *webTab(int index) const;
/**
* show and hide TabBar if user doesn't choose
@@ -96,7 +98,7 @@ public:
inline QList<HistoryItem> recentlyClosedTabs() { return m_recentlyClosedTabs; }
-signals:
+Q_SIGNALS:
// tab widget signals
void tabsChanged();
void lastTabClosed();
@@ -109,7 +111,7 @@ signals:
void printRequested(QWebFrame *frame);
-public slots:
+public Q_SLOTS:
/**
* Core browser slot. This create a new tab with a WebView inside
* for browsing and follows rekonq settings about opening there a
@@ -142,7 +144,7 @@ public slots:
void webReload();
void webStop();
-private slots:
+private Q_SLOTS:
void currentChanged(int index);
void webViewLoadStarted();
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index d5f82d97..f662d7aa 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -72,6 +72,9 @@
#include <KStandardDirs>
#include <KToggleFullScreenAction>
+#include <KParts/Part>
+#include <KParts/BrowserExtension>
+
// Qt Includes
#include <QtCore/QTimer>
@@ -591,8 +594,8 @@ void MainWindow::openLocation()
{
setWidgetsVisible(true);
}
- m_view->urlBar()->selectAll();
- m_view->urlBar()->setFocus();
+ m_view->currentUrlBar()->selectAll();
+ m_view->currentUrlBar()->setFocus();
}
@@ -707,6 +710,25 @@ void MainWindow::printRequested(QWebFrame *frame)
if (!currentTab())
return;
+ if(currentTab()->page()->isOnRekonqPage())
+ {
+ // trigger print part action instead of ours..
+ KParts::ReadOnlyPart *p = currentTab()->part();
+ if(p)
+ {
+ KParts::BrowserExtension *ext = p->browserExtension();
+ if(ext)
+ {
+ KParts::BrowserExtension::ActionSlotMap *actionSlotMap = KParts::BrowserExtension::actionSlotMapPtr();
+
+ connect(this, SIGNAL(triggerPartPrint()), ext, actionSlotMap->value("print"));
+ emit triggerPartPrint();
+
+ return;
+ }
+ }
+ }
+
QWebFrame *printFrame = 0;
if (frame == 0)
{
@@ -753,6 +775,18 @@ void MainWindow::findNext()
if (!currentTab())
return;
+ if(currentTab()->page()->isOnRekonqPage())
+ {
+ // trigger part find action
+ KParts::ReadOnlyPart *p = currentTab()->part();
+ if(p)
+ {
+ connect(this, SIGNAL(triggerPartFind()), p, SLOT(slotFind()));
+ emit triggerPartFind();
+ return;
+ }
+ }
+
if (m_findBar->isHidden())
{
QPoint previous_position = currentTab()->view()->page()->currentFrame()->scrollPosition();
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 0395db4d..33fd2021 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -84,7 +84,7 @@ private:
void setupToolbars();
void setupPanels();
-public slots:
+public Q_SLOTS:
void homePage(Qt::MouseButtons = Qt::LeftButton, Qt::KeyboardModifiers = Qt::NoModifier);
/**
@@ -108,12 +108,15 @@ public slots:
void findPrevious();
void updateHighlight();
-signals:
+Q_SIGNALS:
// switching tabs
void ctrlTabPressed();
void shiftCtrlTabPressed();
-
-protected slots:
+
+ void triggerPartPrint();
+ void triggerPartFind();
+
+protected Q_SLOTS:
void saveNewToolbarConfig();
protected:
@@ -126,7 +129,7 @@ protected:
bool queryClose();
-private slots:
+private Q_SLOTS:
void postLaunch();
void browserLoading(bool);
void updateWindowTitle(const QString &title = QString());
diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp
index a29ff366..00d97f54 100644
--- a/src/protocolhandler.cpp
+++ b/src/protocolhandler.cpp
@@ -271,7 +271,7 @@ void ProtocolHandler::showResults(const KFileItemList &list)
_frame->setHtml(html);
qobject_cast<WebPage *>(_frame->page())->setIsOnRekonqPage(true);
- Application::instance()->mainWindow()->mainView()->urlBar()->setQUrl(_url);
+ Application::instance()->mainWindow()->mainView()->currentUrlBar()->setQUrl(_url);
Application::instance()->mainWindow()->currentTab()->setFocus();
Application::historyManager()->addHistoryEntry(_url.prettyUrl());
}
diff --git a/src/webpage.cpp b/src/webpage.cpp
index 4bbed2f5..b04c5e89 100644
--- a/src/webpage.cpp
+++ b/src/webpage.cpp
@@ -109,11 +109,12 @@ static bool downloadResource (const KUrl& srcUrl, const KIO::MetaData& metaData
KUrl destUrl;
int result = KIO::R_OVERWRITE;
- const QUrl fileName ((suggestedName.isEmpty() ? srcUrl.fileName() : suggestedName));
+ const QString fileName ((suggestedName.isEmpty() ? srcUrl.fileName() : suggestedName));
do
{
- destUrl = KFileDialog::getSaveFileName(fileName, QString(), parent);
+ // follow bug:184202 fixes
+ destUrl = KFileDialog::getSaveFileName(KUrl::fromPath(fileName), QString(), parent);
if(destUrl.isEmpty())
return false;
@@ -229,7 +230,13 @@ WebPage::~WebPage()
bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type)
{
- _isOnRekonqPage = false;
+ if(_isOnRekonqPage)
+ {
+ WebView *view = qobject_cast<WebView *>(parent());
+ WebTab *tab = qobject_cast<WebTab *>(view->parent());
+ _isOnRekonqPage = false;
+ tab->setPart(0, KUrl()); // re-enable the view page
+ }
_loadingUrl = request.url();
KIO::AccessManager *manager = qobject_cast<KIO::AccessManager*>(networkAccessManager());
@@ -439,32 +446,15 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
}
// case KParts::BrowserRun::Embed
- KService::List partServices = KMimeTypeTrader::self()->query(mimeType, QL1S("KParts/ReadOnlyPart"));
- if (partServices.count() > 0)
+ KParts::ReadOnlyPart *pa = KMimeTypeTrader::createPartInstanceFromQuery<KParts::ReadOnlyPart>(mimeType, view(), this, QString());
+ if (pa)
{
- QString p = replyUrl.pathOrUrl();
-
- // A part can handle this. Embed it!
- QString html;
- html += "<html>";
- html += "<head>";
- html += "<title>";
- html += p;
- html += "</title>";
- html += "<style type=\"text/css\">";
- html += "* { border: 0; padding: 0; margin: 0; }";
- html += "</style>";
- html += "</head>";
- html += "<body>";
- html += "<object type=\"" + mimeType + "\" data=\"" + p + "\" width=\"100%\" height=\"100%\" />";
- html += "</body>";
- html += "</html>";
-
- mainFrame()->setHtml(html);
_isOnRekonqPage = true;
-
+
WebView *view = qobject_cast<WebView *>(parent());
WebTab *tab = qobject_cast<WebTab *>(view->parent());
+ tab->setPart(pa,replyUrl);
+
UrlBar *bar = tab->urlBar();
bar->setQUrl(replyUrl);
diff --git a/src/webtab.cpp b/src/webtab.cpp
index 0bc7503c..bac73fec 100644
--- a/src/webtab.cpp
+++ b/src/webtab.cpp
@@ -51,6 +51,7 @@ WebTab::WebTab(QWidget *parent)
, m_webView(new WebView(this))
, m_urlBar(new UrlBar(this))
, m_progress(0)
+ , m_part(0)
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
@@ -74,6 +75,7 @@ WebTab::WebTab(QWidget *parent)
connect(m_webView, SIGNAL(loadProgress(int)), this, SLOT(updateProgress(int)));
connect(m_webView, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool)));
+ connect(m_webView, SIGNAL(titleChanged(const QString &)), this, SIGNAL(titleChanged(const QString &)));
}
@@ -81,13 +83,18 @@ WebTab::~WebTab()
{
m_walletBar.clear();
m_previewSelectorBar.clear();
+
+ delete m_part;
}
KUrl WebTab::url()
{
if(page() && page()->isOnRekonqPage())
+ {
+ kDebug() << "REKONQ PAGE. URL = " << page()->loadingUrl();
return page()->loadingUrl();
+ }
return view()->url();
}
@@ -203,3 +210,28 @@ void WebTab::showRSSInfo(QPoint pos)
RSSWidget *widget = new RSSWidget(map, window());
widget->showAt(pos);
}
+
+
+void WebTab::setPart(KParts::ReadOnlyPart *p, const KUrl &u)
+{
+ if(p)
+ {
+ // Ok, part exists. Insert & show it..
+ m_part = p;
+ qobject_cast<QVBoxLayout *>(layout())->insertWidget(1, p->widget());
+ p->openUrl(u);
+ m_webView->hide();
+
+ emit titleChanged(u.url());
+ return;
+ }
+
+ if(!m_part)
+ return;
+
+ // Part NO more exists. Let's clean up from webtab
+ m_webView->show();
+ qobject_cast<QVBoxLayout *>(layout())->removeWidget(m_part->widget());
+ delete m_part;
+ m_part = 0;
+}
diff --git a/src/webtab.h b/src/webtab.h
index 04d0a6e3..12f528d9 100644
--- a/src/webtab.h
+++ b/src/webtab.h
@@ -35,6 +35,9 @@
// Local Includes
#include "webview.h"
+// KDE Includes
+#include <KParts/Part>
+
// Qt Includes
#include <QtGui/QWidget>
@@ -65,16 +68,20 @@ public:
bool hasRSSInfo();
bool isPageLoading();
-private slots:
+ KParts::ReadOnlyPart *part() { return m_part; }
+ void setPart(KParts::ReadOnlyPart *p, const KUrl &u);
+
+private Q_SLOTS:
void updateProgress(int progress);
void loadFinished(bool);
void createWalletBar(const QString &, const QUrl &);
void showRSSInfo(QPoint pos);
-signals:
+Q_SIGNALS:
void loadProgressing();
-
+ void titleChanged(const QString &);
+
private:
WebView *const m_webView;
UrlBar *const m_urlBar;
@@ -83,6 +90,8 @@ private:
QWeakPointer<WalletBar> m_walletBar;
QWeakPointer<PreviewSelectorBar> m_previewSelectorBar;
+
+ KParts::ReadOnlyPart *m_part;
};
#endif
diff --git a/src/webview.cpp b/src/webview.cpp
index 04677f55..7664805f 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -408,7 +408,7 @@ void WebView::mouseMoveEvent(QMouseEvent *event)
}
else
{
- if(!w->mainView()->urlBar()->hasFocus())
+ if(!w->mainView()->currentUrlBar()->hasFocus())
w->setWidgetsVisible(false);
}
}