From 9a05e4f42f3989733457118a03d3bba93a0e2033 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 15 Nov 2010 00:25:08 +0100 Subject: Fix wrong default filenames due to a ":" in it websvn:1182549 for reference --- src/webpage.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/webpage.cpp b/src/webpage.cpp index 2347b6d8..f08aebd6 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; -- cgit v1.2.1 From 49060cbec9ac93f0993fa315e2939516a398d349 Mon Sep 17 00:00:00 2001 From: Rohan Garg Date: Wed, 17 Nov 2010 01:09:21 +0530 Subject: Add a Clear Button to URL bar to clear it --- src/urlbar/urlbar.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp index 1f4a0367..e108ed2f 100644 --- a/src/urlbar/urlbar.cpp +++ b/src/urlbar/urlbar.cpp @@ -100,6 +100,8 @@ UrlBar::UrlBar(QWidget *parent) // disable completion object (we have our own :) ) setCompletionObject(0); + setClearButtonShown(true); + _tab = qobject_cast(parent); connect(_tab, SIGNAL(loadProgressing()), this, SLOT(update())); -- cgit v1.2.1 From 9e233aabd0cd92fa58057fcad88c0fdc86dce776 Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Wed, 17 Nov 2010 14:24:15 +0100 Subject: Revert "Add a Clear Button to URL bar to clear it" This reverts the controversial commit 49060cbec9ac93f0993fa315e2939516a398d349 for the "clear url bar" feature. reverted after discussion with Rohan on IRC. --- src/urlbar/urlbar.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp index e108ed2f..1f4a0367 100644 --- a/src/urlbar/urlbar.cpp +++ b/src/urlbar/urlbar.cpp @@ -100,8 +100,6 @@ UrlBar::UrlBar(QWidget *parent) // disable completion object (we have our own :) ) setCompletionObject(0); - setClearButtonShown(true); - _tab = qobject_cast(parent); connect(_tab, SIGNAL(loadProgressing()), this, SLOT(update())); -- cgit v1.2.1 From 89d4696eae6bb7b9824f4c0687fbf27b2551a0e0 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 7 Nov 2010 23:34:43 +0100 Subject: API clean up urlBar --> currentUrlBar --- src/application.cpp | 2 +- src/mainview.cpp | 10 +++++----- src/mainview.h | 13 +++++++------ src/mainwindow.cpp | 4 ++-- src/protocolhandler.cpp | 2 +- src/webview.cpp | 2 +- 6 files changed, 17 insertions(+), 16 deletions(-) (limited to 'src') 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/mainview.cpp b/src/mainview.cpp index beaf4e21..26248da5 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -169,9 +169,9 @@ TabBar *MainView::tabBar() const } -UrlBar *MainView::urlBar() const +UrlBar *MainView::currentUrlBar() const { - return _widgetBar->urlBar(m_currentTabIndex); + return webTab(currentIndex())->urlBar(); } @@ -355,7 +355,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())); @@ -363,7 +363,7 @@ void MainView::newTab() default: break; } - urlBar()->setFocus(); + currentUrlBar()->setFocus(); } @@ -450,7 +450,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())); diff --git a/src/mainview.h b/src/mainview.h index 29162dd1..3ee688e2 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -69,11 +69,12 @@ public: ~MainView(); inline StackedUrlBar *widgetBar() const { return _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 @@ -97,7 +98,7 @@ public: inline QList recentlyClosedTabs() { return m_recentlyClosedTabs; } -signals: +Q_SIGNALS: // tab widget signals void tabsChanged(); void lastTabClosed(); @@ -110,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 @@ -143,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..5f508506 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -591,8 +591,8 @@ void MainWindow::openLocation() { setWidgetsVisible(true); } - m_view->urlBar()->selectAll(); - m_view->urlBar()->setFocus(); + m_view->currentUrlBar()->selectAll(); + m_view->currentUrlBar()->setFocus(); } 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(_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/webview.cpp b/src/webview.cpp index 8be744ad..978181a5 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -413,7 +413,7 @@ void WebView::mouseMoveEvent(QMouseEvent *event) } else { - if(!w->mainView()->urlBar()->hasFocus()) + if(!w->mainView()->currentUrlBar()->hasFocus()) w->setWidgetsVisible(false); } } -- cgit v1.2.1 From fe21365ffafb922a6b24959f3d1096e4c6171427 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 19 Nov 2010 01:32:04 +0100 Subject: Print && Find actions for the parts :) - handle print & find with different signals in mainwindow - show right tab title (moving titleChanged signal from view to tab) --- src/findbar.cpp | 9 +++++++++ src/mainview.cpp | 8 ++++---- src/mainwindow.cpp | 34 ++++++++++++++++++++++++++++++++++ src/mainwindow.h | 13 ++++++++----- src/webpage.cpp | 35 ++++++++++++----------------------- src/webtab.cpp | 32 ++++++++++++++++++++++++++++++++ src/webtab.h | 15 ++++++++++++--- 7 files changed, 111 insertions(+), 35 deletions(-) (limited to 'src') 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 @@ -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 26248da5..903ec12b 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -314,7 +314,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())); @@ -584,8 +584,8 @@ void MainView::webViewTitleChanged(const QString &title) QString tabTitle = viewTitle; tabTitle.replace('&', "&&"); - WebView *view = qobject_cast(sender()); - int index = indexOf(view->parentWidget()); + WebTab *tab = qobject_cast(sender()); + int index = indexOf(tab); if (-1 != index) { setTabText(index, tabTitle); @@ -594,7 +594,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/mainwindow.cpp b/src/mainwindow.cpp index 5f508506..f662d7aa 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -72,6 +72,9 @@ #include #include +#include +#include + // Qt Includes #include @@ -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/webpage.cpp b/src/webpage.cpp index f08aebd6..67a33047 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -229,7 +229,13 @@ WebPage::~WebPage() bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type) { - _isOnRekonqPage = false; + if(_isOnRekonqPage) + { + WebView *view = qobject_cast(parent()); + WebTab *tab = qobject_cast(view->parent()); + _isOnRekonqPage = false; + tab->setPart(0, KUrl()); // re-enable the view page + } _loadingUrl = request.url(); KIO::AccessManager *manager = qobject_cast(networkAccessManager()); @@ -439,32 +445,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(mimeType, view(), this, QString()); + if (pa) { - QString p = replyUrl.pathOrUrl(); - - // A part can handle this. Embed it! - QString html; - html += ""; - html += ""; - html += ""; - html += p; - html += ""; - html += ""; - html += ""; - html += ""; - html += ""; - html += ""; - html += ""; - - mainFrame()->setHtml(html); _isOnRekonqPage = true; - + WebView *view = qobject_cast(parent()); WebTab *tab = qobject_cast(view->parent()); + tab->setPart(pa,replyUrl); + UrlBar *bar = tab->urlBar(); bar->setQUrl(replyUrl); diff --git a/src/webtab.cpp b/src/webtab.cpp index 0a55060b..b4f070a9 100644 --- a/src/webtab.cpp +++ b/src/webtab.cpp @@ -51,6 +51,7 @@ WebTab::WebTab(QWidget *parent) , _view(new WebView(this)) , _bar(new UrlBar(this)) , _progress(0) + , _part(0) { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); @@ -74,6 +75,7 @@ WebTab::WebTab(QWidget *parent) connect(_view, SIGNAL(loadProgress(int)), this, SLOT(updateProgress(int))); connect(_view, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool))); + connect(_view, SIGNAL(titleChanged(const QString &)), this, SIGNAL(titleChanged(const QString &))); } @@ -81,13 +83,18 @@ WebTab::~WebTab() { _walletBar.clear(); _previewSelectorBar.clear(); + + delete _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.. + _part = p; + qobject_cast(layout())->insertWidget(1, p->widget()); + p->openUrl(u); + _view->hide(); + + emit titleChanged(u.url()); + return; + } + + if(!_part) + return; + + // Part NO more exists. Let's clean up from webtab + _view->show(); + qobject_cast(layout())->removeWidget(_part->widget()); + delete _part; + _part = 0; +} diff --git a/src/webtab.h b/src/webtab.h index 3fd4f793..abab5d73 100644 --- a/src/webtab.h +++ b/src/webtab.h @@ -35,6 +35,9 @@ // Local Includes #include "webview.h" +// KDE Includes +#include + // Qt Includes #include @@ -65,16 +68,20 @@ public: bool hasRSSInfo(); bool isPageLoading(); -private slots: + KParts::ReadOnlyPart *part() { return _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 *_view; UrlBar *_bar; @@ -83,6 +90,8 @@ private: QWeakPointer _walletBar; QWeakPointer _previewSelectorBar; + + KParts::ReadOnlyPart *_part; }; #endif -- cgit v1.2.1