From fdbd70a77a8c294e0a578073c738f3bc4dfa6ab5 Mon Sep 17 00:00:00 2001 From: Alexandr Domrachev Date: Mon, 27 Apr 2009 17:05:43 +0000 Subject: Some changes ported for merge to mainline (bookmarks & links handling related) Added author: me :) Bookmark owner: openFolderinTabs implemented Links handling ported from Pawel branch Issue #1 fixed --- src/mainview.cpp | 83 ++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 57 insertions(+), 26 deletions(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 865ffab2..9449a9c5 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -81,9 +81,14 @@ MainView::MainView(QWidget *parent) m_recentlyClosedTabsAction->setEnabled(false); // -- - connect(this, SIGNAL(loadUrlPage(const KUrl &)), this, SLOT(loadUrlInCurrentTab(const KUrl &))); connect(this, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentChanged(int))); + connect(Application::instance(), SIGNAL(openUrl(const KUrl &, Rekonq::OpenType)), + this, SLOT(openUrl(const KUrl &, Rekonq::OpenType))); + // bookmarks loading + connect(Application::bookmarkProvider(), SIGNAL(openUrl(const KUrl &, Rekonq::OpenType)), + this, SLOT(openUrl(const KUrl &, Rekonq::OpenType))); + setTabsClosable(true); connect(m_tabBar, SIGNAL(tabCloseRequested(int)), this, SLOT(slotCloseTab(int))); } @@ -239,16 +244,18 @@ void MainView::slotCurrentChanged(int index) WebView *oldWebView = this->webView(m_urlBars->currentIndex()); if (oldWebView) { - disconnect(oldWebView, SIGNAL(statusBarMessage(const QString&)), + disconnect(oldWebView, SIGNAL(statusBarMessage(const QString&)), this, SIGNAL(showStatusBarMessage(const QString&))); - disconnect(oldWebView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), + disconnect(oldWebView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), this, SIGNAL(linkHovered(const QString&))); - disconnect(oldWebView, SIGNAL(loadProgress(int)), + disconnect(oldWebView, SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int))); } - connect(webView, SIGNAL(statusBarMessage(const QString&)), this, SIGNAL(showStatusBarMessage(const QString&))); - connect(webView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), this, SIGNAL(linkHovered(const QString&))); + connect(webView, SIGNAL(statusBarMessage(const QString &)), + this, SIGNAL(showStatusBarMessage(const QString &))); + connect(webView->page(), SIGNAL(linkHovered(const QString &, const QString &, const QString &)), + this, SIGNAL(linkHovered(const QString &))); connect(webView, SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int))); emit setCurrentTitle(webView->title()); @@ -294,17 +301,17 @@ WebView *MainView::newWebView(bool makeCurrent) { // line edit UrlBar *urlBar = new UrlBar; // Ownership of widget is passed on to the QStackedWidget (addWidget method). - connect(urlBar, SIGNAL(activated(const KUrl&)), this, SLOT(loadUrlInCurrentTab(const KUrl&))); + connect(urlBar, SIGNAL(activated(const KUrl &)), this, SLOT(openUrl(const KUrl &))); m_urlBars->addUrlBar(urlBar); WebView *webView = new WebView; // should be deleted on tab close - + // connecting webview with urlbar connect(webView, SIGNAL(loadProgress(int)), urlBar, SLOT(slotUpdateProgress(int))); connect(webView, SIGNAL(loadFinished(bool)), urlBar, SLOT(slotLoadFinished(bool))); connect(webView, SIGNAL(urlChanged(const QUrl &)), urlBar, SLOT(setUrl(const QUrl &))); connect(webView, SIGNAL(iconChanged()), urlBar, SLOT(slotUpdateUrl())); - + // connecting webview with mainview connect(webView, SIGNAL(loadStarted()), this, SLOT(webViewLoadStarted())); connect(webView, SIGNAL(loadProgress(int)), this, SLOT(webViewLoadProgress(int))); @@ -317,17 +324,17 @@ WebView *MainView::newWebView(bool makeCurrent) connect(webView, SIGNAL(shiftCtrlTabPressed()), this, SLOT(previousTab())); // connecting webPage signals with mainview - connect(webView->page(), SIGNAL(windowCloseRequested()), + connect(webView->page(), SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested())); - connect(webView->page(), SIGNAL(geometryChangeRequested(const QRect &)), + 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)), + connect(webView->page(), SIGNAL(menuBarVisibilityChangeRequested(bool)), this, SIGNAL(menuBarVisibilityChangeRequested(bool))); - connect(webView->page(), SIGNAL(statusBarVisibilityChangeRequested(bool)), + connect(webView->page(), SIGNAL(statusBarVisibilityChangeRequested(bool)), this, SIGNAL(statusBarVisibilityChangeRequested(bool))); - connect(webView->page(), SIGNAL(toolBarVisibilityChangeRequested(bool)), + connect(webView->page(), SIGNAL(toolBarVisibilityChangeRequested(bool)), this, SIGNAL(toolBarVisibilityChangeRequested(bool))); addTab(webView, i18n("(Untitled)")); @@ -507,9 +514,9 @@ void MainView::webViewLoadProgress(int progress) { return; } - + double totalBytes = static_cast(webView->webPage()->totalBytes() / 1024); - + QString message = i18n("Loading %1% (%2 %3)...", progress, totalBytes, QLatin1String("kB") ); emit showStatusBarMessage(message); } @@ -519,7 +526,7 @@ void MainView::webViewLoadFinished(bool ok) { WebView *webView = qobject_cast(sender()); int index = webViewIndex(webView); - + if (-1 != index) { QLabel *label = animatedLoading(index, true); @@ -527,7 +534,7 @@ void MainView::webViewLoadFinished(bool ok) if(movie) movie->stop(); } - + webViewIconChanged(); // don't display messages for background tabs @@ -535,7 +542,7 @@ void MainView::webViewLoadFinished(bool ok) { return; } - + if (ok) emit showStatusBarMessage(i18n("Done")); else @@ -610,21 +617,45 @@ void MainView::aboutToShowRecentTabsMenu() void MainView::aboutToShowRecentTriggeredAction(QAction *action) { KUrl url = action->data().toUrl(); - loadUrlInCurrentTab(url); + openUrl(url, Rekonq::Current); } -void MainView::loadUrlInCurrentTab(const KUrl &url) +void MainView::openUrl(const KUrl& url, Rekonq::OpenType type) { - WebView *webView = currentWebView(); - if (webView) + kDebug() << "sender:" << sender() << " line:" << __LINE__; + + if (url.isEmpty()) { - webView->loadUrl(url); - webView->setFocus(); + kWarning() << "Can't load an empty url; sender:" << sender() << "line: " << __LINE__; + return; } + + WebView *webView = NULL; + if (type == Rekonq::New) + webView = newWebView(true); + else if (type == Rekonq::Background) + webView = newWebView(false); + else + webView = currentWebView(); + + if (!webView) + { + kWarning() << "Can't find the view" << "line:" << __LINE__; + return; + } + webView->loadUrl(url); + webView->setFocus(); + + currentUrlBar()->setUrl(url.prettyUrl()); } +void MainView::loadUrlInCurrentTab(const KUrl &url) +{ + openUrl(url); +} + void MainView::nextTab() { int next = currentIndex() + 1; @@ -657,7 +688,7 @@ QLabel *MainView::animatedLoading(int index, bool addMovie) return 0; QLabel *label = qobject_cast(m_tabBar->tabButton(index, QTabBar::LeftSide)); - if (!label) + if (!label) { label = new QLabel(this); } -- cgit v1.2.1 From 78aef384a57bca278bdd4484e9b31bbd7b88c98e Mon Sep 17 00:00:00 2001 From: Alexandr Domrachev Date: Mon, 27 Apr 2009 18:01:41 +0000 Subject: TabBar code clean. Icons added to context menu --- src/mainview.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 9449a9c5..8cf09e2a 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -65,7 +65,6 @@ MainView::MainView(QWidget *parent) m_loadingGitPath = KStandardDirs::locate("appdata" , "pics/loading.gif"); - connect(m_tabBar, SIGNAL(newTab()), this, SLOT(newWebView())); connect(m_tabBar, SIGNAL(closeTab(int)), this, SLOT(slotCloseTab(int))); connect(m_tabBar, SIGNAL(cloneTab(int)), this, SLOT(slotCloneTab(int))); connect(m_tabBar, SIGNAL(closeOtherTabs(int)), this, SLOT(slotCloseOtherTabs(int))); -- cgit v1.2.1 From 61172b031c59d7f78447d224963b1333ce1d92bd Mon Sep 17 00:00:00 2001 From: Alexandr Domrachev Date: Mon, 27 Apr 2009 18:05:39 +0000 Subject: Open new tab on TabBar double click --- src/mainview.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index 8cf09e2a..dc614f5c 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -218,6 +218,19 @@ void MainView::clear() } +void MainView::mouseDoubleClickEvent(QMouseEvent *event) +{ + if (!childAt(event->pos()) + // Remove the line below when QTabWidget does not have a one pixel frame + && event->pos().y() < (tabBar()->y() + tabBar()->height())) + { + newWebView(true); + return; + } + KTabWidget::mouseDoubleClickEvent(event); +} + + // When index is -1 index chooses the current tab void MainView::slotReloadTab(int index) { -- cgit v1.2.1 From 2382db2c27728214cb9645fee3ef49222ca8dcd5 Mon Sep 17 00:00:00 2001 From: Alexandr Domrachev Date: Mon, 27 Apr 2009 18:42:51 +0000 Subject: TabBar context menu fix ported --- src/mainview.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/mainview.cpp') diff --git a/src/mainview.cpp b/src/mainview.cpp index dc614f5c..c3818b50 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -231,6 +231,16 @@ void MainView::mouseDoubleClickEvent(QMouseEvent *event) } +void MainView::contextMenuEvent(QContextMenuEvent *event) +{ + if (!childAt(event->pos())) + { + m_tabBar->contextMenuRequested(event->pos()); + return; + } + KTabWidget::contextMenuEvent(event); +} + // When index is -1 index chooses the current tab void MainView::slotReloadTab(int index) { -- cgit v1.2.1