mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +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:
parent
a059c005ff
commit
6e71ae3c54
@ -155,7 +155,7 @@ void HistoryMenu::aboutToShowClosedTabs()
|
|||||||
|
|
||||||
foreach (const ClosedTabsManager::Tab &tab, closedTabs) {
|
foreach (const ClosedTabsManager::Tab &tab, closedTabs) {
|
||||||
const QString title = QzTools::truncatedText(tab.title, 40);
|
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++);
|
act->setData(i++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Tab closedTab;
|
Tab closedTab;
|
||||||
closedTab.url = tab->url();
|
closedTab.url = tab->url();
|
||||||
closedTab.title = tab->title();
|
closedTab.title = tab->title();
|
||||||
|
closedTab.icon = tab->icon();
|
||||||
closedTab.position = position;
|
closedTab.position = position;
|
||||||
closedTab.history = tab->historyData();
|
closedTab.history = tab->historyData();
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#define CLOSEDTABSMANAGER_H
|
#define CLOSEDTABSMANAGER_H
|
||||||
|
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
#include <QIcon>
|
||||||
#include <QLinkedList>
|
#include <QLinkedList>
|
||||||
|
|
||||||
#include "qzcommon.h"
|
#include "qzcommon.h"
|
||||||
@ -30,8 +31,9 @@ class QUPZILLA_EXPORT ClosedTabsManager
|
|||||||
public:
|
public:
|
||||||
struct Tab {
|
struct Tab {
|
||||||
QUrl url;
|
QUrl url;
|
||||||
QByteArray history;
|
|
||||||
QString title;
|
QString title;
|
||||||
|
QIcon icon;
|
||||||
|
QByteArray history;
|
||||||
int position;
|
int position;
|
||||||
|
|
||||||
bool operator==(const Tab &a) const {
|
bool operator==(const Tab &a) const {
|
||||||
@ -43,7 +45,7 @@ public:
|
|||||||
|
|
||||||
explicit ClosedTabsManager();
|
explicit ClosedTabsManager();
|
||||||
|
|
||||||
void saveView(WebTab* tab, int position);
|
void saveTab(WebTab* tab, int position);
|
||||||
bool isClosedTabAvailable();
|
bool isClosedTabAvailable();
|
||||||
|
|
||||||
// Takes tab that was most recently closed
|
// Takes tab that was most recently closed
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#include "tabbedwebview.h"
|
#include "tabbedwebview.h"
|
||||||
#include "webpage.h"
|
#include "webpage.h"
|
||||||
#include "browserwindow.h"
|
#include "browserwindow.h"
|
||||||
#include "iconprovider.h"
|
|
||||||
#include "mainapplication.h"
|
#include "mainapplication.h"
|
||||||
#include "webtab.h"
|
#include "webtab.h"
|
||||||
#include "clickablelabel.h"
|
#include "clickablelabel.h"
|
||||||
@ -322,7 +321,7 @@ void TabWidget::aboutToShowClosedTabsMenu()
|
|||||||
|
|
||||||
foreach (const ClosedTabsManager::Tab &tab, closedTabs) {
|
foreach (const ClosedTabsManager::Tab &tab, closedTabs) {
|
||||||
const QString title = QzTools::truncatedText(tab.title, 40);
|
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++);
|
act->setData(i++);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -497,7 +496,7 @@ void TabWidget::closeTab(int index, bool force)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Save tab url and history
|
// 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
|
// This would close last tab, so we close the window instead
|
||||||
if (!force && count() == 1) {
|
if (!force && count() == 1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user