From b38f87b277617ccfea6e133e0965f2a6a4ad8caf Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 17 Feb 2013 17:30:11 +0100 Subject: Closed Tabs page return, first bits Restore about:closedTabs page and the ability to open back closed tabs. What's missing then? To load back on restart the closed tabs saved... --- src/tabwindow/tabwindow.cpp | 43 +++++++++++++++++++++++++++++++++---------- src/tabwindow/tabwindow.h | 5 ++++- 2 files changed, 37 insertions(+), 11 deletions(-) (limited to 'src/tabwindow') diff --git a/src/tabwindow/tabwindow.cpp b/src/tabwindow/tabwindow.cpp index acf84948..6865ca97 100644 --- a/src/tabwindow/tabwindow.cpp +++ b/src/tabwindow/tabwindow.cpp @@ -252,6 +252,12 @@ WebWindow *TabWindow::webWindow(int index) const } +QList TabWindow::recentlyClosedTabs() +{ + return m_recentlyClosedTabs; +} + + WebWindow *TabWindow::prepareNewTab(WebPage *page) { WebWindow *tab = new WebWindow(this, _isPrivateBrowsing, page); @@ -706,29 +712,46 @@ void TabWindow::bookmarkAllTabs() void TabWindow::restoreLastClosedTab() +{ + restoreClosedTab(0); +} + + +void TabWindow::restoreClosedTab(int index, bool inNewTab) { if (m_recentlyClosedTabs.isEmpty()) return; - - TabHistory history = m_recentlyClosedTabs.takeAt(0); + + if (index >= m_recentlyClosedTabs.count()) + return; + + TabHistory history = m_recentlyClosedTabs.takeAt(index); QUrl u = QUrl(history.url); int restorePosition = history.position; - WebWindow *tab = prepareNewTab(); - - if (restorePosition < count()) - insertTab(restorePosition, tab, i18n("restored tab")); - else - addTab(tab, i18n("restored tab")); + WebWindow *tab; - setCurrentWidget(tab); + if (inNewTab) + { + tab = prepareNewTab(); + if (restorePosition < count()) + insertTab(restorePosition, tab, i18n("restored tab")); + else + addTab(tab, i18n("restored tab")); + setCurrentWidget(tab); + } + else + { + tab = currentWebWindow(); + } + tab->load(u); // just to get sure... - m_recentlyClosedTabs.removeAll(history); + m_recentlyClosedTabs.removeAll(history); } diff --git a/src/tabwindow/tabwindow.h b/src/tabwindow/tabwindow.h index a273d3b1..a1e369d9 100644 --- a/src/tabwindow/tabwindow.h +++ b/src/tabwindow/tabwindow.h @@ -73,6 +73,9 @@ public: virtual KActionCollection *actionCollection() const; QAction *actionByName(const QString &name); + QList recentlyClosedTabs(); + void restoreClosedTab(int index, bool inNewTab = true); + public Q_SLOTS: void loadUrl(const KUrl &, Rekonq::OpenType type = Rekonq::CurrentTab, TabHistory *history = 0); void newTab(WebPage *page = 0); @@ -115,7 +118,7 @@ private Q_SLOTS: void previousTab(); void restoreLastClosedTab(); - + void setFullScreen(bool); void loadFavorite(const int); -- cgit v1.2.1