From f0b55360c6ba8da48098362aa85ca88fa293b5a1 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 11 Oct 2009 11:57:33 +0200 Subject: Restored recently closed tabs I'm not a big fan of this implementation, but modifying history for this is impossible (no sense) and storing it somewhere.. don't know Perhaps someone has some better ideas here :) --- src/application.cpp | 2 +- src/homepage.cpp | 35 ++++++++++++++++++++++++++++++----- src/homepage.h | 3 ++- src/mainview.cpp | 9 +++++++++ src/mainview.h | 3 +++ 5 files changed, 45 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/application.cpp b/src/application.cpp index f16b831d..6719d456 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -433,7 +433,7 @@ MainWindowList Application::mainWindowList() bool Application::homePage(const KUrl &url) { - if ( url == KUrl("rekonq:lastSites") + if ( url == KUrl("rekonq:closedTabs") || url == KUrl("rekonq:history") || url == KUrl("rekonq:bookmarks") || url == KUrl("rekonq:favorites") diff --git a/src/homepage.cpp b/src/homepage.cpp index 3cc908a9..398308be 100644 --- a/src/homepage.cpp +++ b/src/homepage.cpp @@ -75,9 +75,9 @@ QString HomePage::rekonqHomePage(const KUrl &url) QString menu = homePageMenu(url); QString speed; - if(url == KUrl("rekonq:lastSites")) + if(url == KUrl("rekonq:closedTabs")) { - speed = lastVisitedSites(); + speed = fillRecentlyClosedTabs(); } if(url == KUrl("rekonq:history")) { @@ -182,11 +182,11 @@ QString HomePage::homePageMenu(KUrl currentUrl) menu += "Favorites"; menu += "
"; + menu += "\">"; menu += "iconPath("edit-undo", KIconLoader::Desktop) + "\" />"; - menu += "Last Visited
"; + menu += "Closed Tabs"; menu += "
" + bookmark.text() + "
"; return books; } + + +QString HomePage::fillRecentlyClosedTabs() +{ + KUrl::List links = Application::instance()->mainWindow()->mainView()->recentlyClosedTabs(); + QString closed; + + Q_FOREACH( const KUrl &url, links) + { + QString text = url.prettyUrl(); + if(text.length() > 20) + { + text.truncate(17); + text += "..."; + } + closed += "
"; + closed += ""; + closed += ""; + closed += "
"; + closed += "" + text + "
"; + } + + return closed; +} diff --git a/src/homepage.h b/src/homepage.h index 73bb5859..7d62f50a 100644 --- a/src/homepage.h +++ b/src/homepage.h @@ -55,7 +55,8 @@ private: QString lastVisitedSites(); QString fillHistory(); QString fillBookmarks(); - + QString fillRecentlyClosedTabs(); + QString createBookItem(const KBookmark &bookmark); QString m_homePagePath; diff --git a/src/mainview.cpp b/src/mainview.cpp index 0abf6996..3c78a0f6 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -179,6 +179,8 @@ void MainView::clear() // What exactly do we need to clear here? m_urlBar->clearHistory(); m_urlBar->clear(); + + m_recentlyClosedTabs.clear(); } @@ -411,6 +413,7 @@ void MainView::slotCloseTab(int index) return; } hasFocus = tab->hasFocus(); + m_recentlyClosedTabs.prepend(tab->url()); } QWidget *webView = widget(index); @@ -569,3 +572,9 @@ QLabel *MainView::animatedLoading(int index, bool addMovie) m_tabBar->setTabButton(index, QTabBar::LeftSide, label); return label; } + + +KUrl::List MainView::recentlyClosedTabs() +{ + return m_recentlyClosedTabs; +} diff --git a/src/mainview.h b/src/mainview.h index 48e0b58b..96710919 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -89,6 +89,7 @@ public: */ WebView *newWebView(bool focused = true, bool nearParent = false); + KUrl::List recentlyClosedTabs(); signals: // tab widget signals @@ -155,6 +156,8 @@ private: QString m_loadingGitPath; int m_currentTabIndex; + + KUrl::List m_recentlyClosedTabs; }; #endif // MAINVIEW_H -- cgit v1.2.1