1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

[ClosedTabsManager] Save icon of closed tab

Instead of searching icon from database, save the icon of tab.
It will now correctly shows icon of not-yet loaded closed tab if
the url was not in database.
This commit is contained in:
nowrep 2014-03-30 12:46:06 +02:00
parent a059c005ff
commit 6e71ae3c54
4 changed files with 15 additions and 8 deletions

View File

@ -155,7 +155,7 @@ void HistoryMenu::aboutToShowClosedTabs()
foreach (const ClosedTabsManager::Tab &tab, closedTabs) {
const QString title = QzTools::truncatedText(tab.title, 40);
QAction* act = m_menuClosedTabs->addAction(IconProvider::iconForUrl(tab.url), title, tabWidget, SLOT(restoreClosedTab()));
QAction* act = m_menuClosedTabs->addAction(tab.icon, title, tabWidget, SLOT(restoreClosedTab()));
act->setData(i++);
}

View File

@ -27,15 +27,21 @@ ClosedTabsManager::ClosedTabsManager()
{
}
void ClosedTabsManager::saveView(WebTab* tab, int position)
void ClosedTabsManager::saveTab(WebTab* tab, int position)
{
if (mApp->isPrivate() || (tab->url().isEmpty() && tab->history()->items().count() == 0)) {
if (mApp->isPrivate()) {
return;
}
// Don't save empty tab
if (tab->url().isEmpty() && tab->history()->items().count() == 0) {
return;
}
Tab closedTab;
closedTab.url = tab->url();
closedTab.title = tab->title();
closedTab.icon = tab->icon();
closedTab.position = position;
closedTab.history = tab->historyData();

View File

@ -19,6 +19,7 @@
#define CLOSEDTABSMANAGER_H
#include <QUrl>
#include <QIcon>
#include <QLinkedList>
#include "qzcommon.h"
@ -30,8 +31,9 @@ class QUPZILLA_EXPORT ClosedTabsManager
public:
struct Tab {
QUrl url;
QByteArray history;
QString title;
QIcon icon;
QByteArray history;
int position;
bool operator==(const Tab &a) const {
@ -43,7 +45,7 @@ public:
explicit ClosedTabsManager();
void saveView(WebTab* tab, int position);
void saveTab(WebTab* tab, int position);
bool isClosedTabAvailable();
// Takes tab that was most recently closed

View File

@ -20,7 +20,6 @@
#include "tabbedwebview.h"
#include "webpage.h"
#include "browserwindow.h"
#include "iconprovider.h"
#include "mainapplication.h"
#include "webtab.h"
#include "clickablelabel.h"
@ -322,7 +321,7 @@ void TabWidget::aboutToShowClosedTabsMenu()
foreach (const ClosedTabsManager::Tab &tab, closedTabs) {
const QString title = QzTools::truncatedText(tab.title, 40);
QAction* act = m_menuClosedTabs->addAction(IconProvider::iconForUrl(tab.url), title, this, SLOT(restoreClosedTab()));
QAction* act = m_menuClosedTabs->addAction(tab.icon, title, this, SLOT(restoreClosedTab()));
act->setData(i++);
}
@ -497,7 +496,7 @@ void TabWidget::closeTab(int index, bool force)
}
// Save tab url and history
m_closedTabsManager->saveView(webTab, index);
m_closedTabsManager->saveTab(webTab, index);
// This would close last tab, so we close the window instead
if (!force && count() == 1) {