From 8ebc401712fd157030a485f38d4500543a013cd0 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 2 Dec 2012 11:44:32 +0100 Subject: Restore tab position on reopening BUG: 249457 --- src/tabhistory.h | 1 + src/tabwindow/tabwindow.cpp | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/tabhistory.h b/src/tabhistory.h index aac359a3..d542fd7c 100644 --- a/src/tabhistory.h +++ b/src/tabhistory.h @@ -65,6 +65,7 @@ public: QString title; QString url; QByteArray history; + int position; }; #endif // TAB_HISTORY diff --git a/src/tabwindow/tabwindow.cpp b/src/tabwindow/tabwindow.cpp index a37cc249..beb087c5 100644 --- a/src/tabwindow/tabwindow.cpp +++ b/src/tabwindow/tabwindow.cpp @@ -449,9 +449,9 @@ void TabWindow::cloneTab(int index) QUrl u = webWindow(index)->url(); QWebHistory* history = webWindow(index)->page()->history(); - TabHistory tHistory(history); + TabHistory clonedHistory(history); - loadUrl(u, Rekonq::NewTab, &tHistory); + loadUrl(u, Rekonq::NewTab, &clonedHistory); } @@ -483,7 +483,8 @@ void TabWindow::closeTab(int index, bool del) TabHistory history(tabToClose->page()->history()); history.title = tabToClose->title(); history.url = tabToClose->url().url(); - + history.position = index; + m_recentlyClosedTabs.removeAll(history); if (m_recentlyClosedTabs.count() == recentlyClosedTabsLimit) m_recentlyClosedTabs.removeLast(); @@ -610,7 +611,18 @@ void TabWindow::restoreLastClosedTab() QUrl u = QUrl(history.url); - loadUrl(u, Rekonq::NewFocusedTab, &history); + int restorePosition = history.position; + + WebWindow *tab = prepareNewTab(); + + if (restorePosition < count()) + insertTab(restorePosition, tab, i18n("restored tab")); + else + addTab(tab, i18n("restored tab")); + + setCurrentWidget(tab); + + tab->load(u); // just to get sure... m_recentlyClosedTabs.removeAll(history); -- cgit v1.2.1