diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2013-02-17 17:30:11 +0100 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2013-02-17 17:30:11 +0100 |
commit | b38f87b277617ccfea6e133e0965f2a6a4ad8caf (patch) | |
tree | 347fa2ce57fafe2e732e3d8ec37b83474cf4f5b0 /src | |
parent | Fix about pages title (diff) | |
download | rekonq-b38f87b277617ccfea6e133e0965f2a6a4ad8caf.tar.xz |
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...
Diffstat (limited to 'src')
-rw-r--r-- | src/rekonqpage/newtabpage.cpp | 169 | ||||
-rw-r--r-- | src/settings/settings_tabs.ui | 5 | ||||
-rw-r--r-- | src/tabwindow/tabwindow.cpp | 43 | ||||
-rw-r--r-- | src/tabwindow/tabwindow.h | 5 | ||||
-rw-r--r-- | src/webtab/protocolhandler.cpp | 3 |
5 files changed, 109 insertions, 116 deletions
diff --git a/src/rekonqpage/newtabpage.cpp b/src/rekonqpage/newtabpage.cpp index 5de1a6e4..547fcdf9 100644 --- a/src/rekonqpage/newtabpage.cpp +++ b/src/rekonqpage/newtabpage.cpp @@ -32,22 +32,25 @@ // Auto Includes #include "rekonq.h" -// Manager Includes -#include "bookmarkmanager.h" -#include "downloadmanager.h" -#include "iconmanager.h" - -#include "historymanager.h" -#include "historymodels.h" - // Local Includes #include "application.h" +#include "tabwindow.h" + #include "previewselectorbar.h" #include "thumbupdater.h" #include "websnap.h" #include "webpage.h" #include "webtab.h" +#include "tabhistory.h" + +#include "bookmarkmanager.h" +#include "downloadmanager.h" +#include "iconmanager.h" + +#include "historymanager.h" +#include "historymodels.h" + // KDE Includes #include <KBookmarkManager> #include <KIconLoader> @@ -171,49 +174,17 @@ void NewTabPage::generate(const KUrl &url) } } -// // about:tabs links -// if (KUrl("about:tabs").isParentOf(url)) -// { -// if (url.fileName() == QL1S("show")) -// { -// const int winIndex = url.queryItem(QL1S("win")).toInt(); -// const int tabIndex = url.queryItem(QL1S("tab")).toInt(); -// -// MainWindow *w = rApp->mainWindowList().at(winIndex).data(); -// -// // close about:tabs tab -// rApp->mainWindow()->mainView()->closeTab(rApp->mainWindow()->mainView()->currentIndex()); -// -// // show requested tab -// w->mainView()->setCurrentIndex(tabIndex); -// if (w != rApp->mainWindow()) -// w->raise(); -// return; -// } -// -// if (url.fileName() == QL1S("remove")) -// { -// const int winIndex = url.queryItem(QL1S("win")).toInt(); -// const int tabIndex = url.queryItem(QL1S("tab")).toInt(); -// -// MainWindow *w = rApp->mainWindowList().at(winIndex).data(); -// w->mainView()->closeTab(tabIndex); -// loadPageForUrl(KUrl("about:tabs")); -// return; -// } -// } -// -// // about:closedTabs links -// if (KUrl("about:closedTabs").isParentOf(url)) -// { -// if (url.fileName() == QL1S("restore")) -// { -// const int tabIndex = url.queryItem(QL1S("tab")).toInt(); -// -// rApp->mainWindow()->mainView()->restoreClosedTab(tabIndex, false); -// return; -// } -// } + // about:closedTabs links + if (KUrl("about:closedTabs").isParentOf(url)) + { + if (url.fileName() == QL1S("restore")) + { + const int tabIndex = url.queryItem(QL1S("tab")).toInt(); + + rApp->tabWindow()->restoreClosedTab(tabIndex, false); + return; + } + } // about:history links if (KUrl("about:history").isParentOf(url)) @@ -327,12 +298,6 @@ void NewTabPage::loadPageForUrl(const KUrl &url, const QString & filter) initJS(); return; } -// else if (encodedUrl == QByteArray("about:closedTabs")) -// { -// closedTabsPage(); -// updateWindowIcon(); -// title = i18n("Closed Tabs"); -// } else if (encodedUrl == QByteArray("about:history")) { historyPage(filter); @@ -351,12 +316,12 @@ void NewTabPage::loadPageForUrl(const KUrl &url, const QString & filter) // updateWindowIcon(); title = i18n("Downloads"); } -// else if (encodedUrl == QByteArray("about:tabs")) -// { -// tabsPage(); + else if (encodedUrl == QByteArray("about:closedTabs")) + { + closedTabsPage(); // updateWindowIcon(); -// title = i18n("Tabs"); -// } + title = i18n("Closed Tabs"); + } m_root.document().findFirst(QL1S("title")).setPlainText(title); } @@ -376,12 +341,6 @@ void NewTabPage::browsingMenu(const KUrl ¤tUrl) QL1S("emblem-favorite"), KIconLoader::Toolbar)); -// // Closed Tabs -// navItems.append(createLinkItem(i18n("Closed Tabs"), -// QL1S("about:closedTabs"), -// QL1S("tab-close"), -// KIconLoader::Toolbar)); - // Bookmarks navItems.append(createLinkItem(i18n("Bookmarks"), QL1S("about:bookmarks"), @@ -400,11 +359,11 @@ void NewTabPage::browsingMenu(const KUrl ¤tUrl) QL1S("download"), KIconLoader::Toolbar)); -// // Tabs -// navItems.append(createLinkItem(i18n("Tabs"), -// QL1S("about:tabs"), -// QL1S("tab-duplicate"), -// KIconLoader::Toolbar)); + // Closed Tabs + navItems.append(createLinkItem(i18n("Closed Tabs"), + QL1S("about:closedTabs"), + QL1S("tab-close"), + KIconLoader::Toolbar)); Q_FOREACH(QWebElement it, navItems) { @@ -594,38 +553,38 @@ void NewTabPage::bookmarksPage() } -// void NewTabPage::closedTabsPage() -// { -// m_root.addClass(QL1S("closedTabs")); -// -// QList<TabHistory> links = rApp->mainWindow()->mainView()->recentlyClosedTabs(); -// -// if (links.isEmpty()) -// { -// m_root.addClass(QL1S("empty")); -// m_root.setPlainText(i18n("There are no recently closed tabs")); -// return; -// } -// -// for (int i = 0; i < links.count(); ++i) -// { -// TabHistory item = links.at(i); -// QWebElement prev; -// -// if (item.url.isEmpty()) -// continue; -// -// prev = closedTabPreview(i, item.url, item.title); -// -// prev.setAttribute(QL1S("id"), QL1S("preview") + QVariant(i).toString()); -// -// // hide controls -// prev.findFirst(QL1S(".right")).setStyleProperty(QL1S("visibility"), QL1S("hidden")); -// prev.findFirst(QL1S(".left")).setStyleProperty(QL1S("visibility"), QL1S("hidden")); -// -// m_root.appendInside(prev); -// } -// } +void NewTabPage::closedTabsPage() +{ + m_root.addClass(QL1S("closedTabs")); + + QList<TabHistory> links = rApp->tabWindow()->recentlyClosedTabs(); + + if (links.isEmpty()) + { + m_root.addClass(QL1S("empty")); + m_root.setPlainText(i18n("There are no recently closed tabs")); + return; + } + + for (int i = 0; i < links.count(); ++i) + { + TabHistory item = links.at(i); + QWebElement prev; + + if (item.url.isEmpty()) + continue; + + prev = closedTabPreview(i, item.url, item.title); + + prev.setAttribute(QL1S("id"), QL1S("preview") + QVariant(i).toString()); + + // hide controls + prev.findFirst(QL1S(".right")).setStyleProperty(QL1S("visibility"), QL1S("hidden")); + prev.findFirst(QL1S(".left")).setStyleProperty(QL1S("visibility"), QL1S("hidden")); + + m_root.appendInside(prev); + } +} void NewTabPage::downloadsPage(const QString & filter) diff --git a/src/settings/settings_tabs.ui b/src/settings/settings_tabs.ui index 27e68238..51546635 100644 --- a/src/settings/settings_tabs.ui +++ b/src/settings/settings_tabs.ui @@ -114,6 +114,11 @@ <string>Downloads</string> </property> </item> + <item> + <property name="text"> + <string>Closed Tabs</string> + </property> + </item> </widget> </item> </layout> 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<TabHistory> TabWindow::recentlyClosedTabs() +{ + return m_recentlyClosedTabs; +} + + WebWindow *TabWindow::prepareNewTab(WebPage *page) { WebWindow *tab = new WebWindow(this, _isPrivateBrowsing, page); @@ -707,28 +713,45 @@ 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<TabHistory> 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); diff --git a/src/webtab/protocolhandler.cpp b/src/webtab/protocolhandler.cpp index 4f2e765e..e9f6a77c 100644 --- a/src/webtab/protocolhandler.cpp +++ b/src/webtab/protocolhandler.cpp @@ -158,6 +158,9 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra case 3: // downloads _url = KUrl("about:downloads"); break; + case 4: // closed tabs + _url = KUrl("about:closedTabs"); + break; default: // unuseful kDebug() << "oops... this should NOT happen..."; _url = KUrl("about:favorites"); |