DolphinRecentTabsMenu* recentTabsMenu = new DolphinRecentTabsMenu(this);
actionCollection()->addAction("closed_tabs", recentTabsMenu);
- connect(m_tabWidget, SIGNAL(rememberClosedTab(KUrl,KUrl)),
- recentTabsMenu, SLOT(rememberClosedTab(KUrl,KUrl)));
- connect(recentTabsMenu, SIGNAL(restoreClosedTab(KUrl,KUrl)),
- this, SLOT(openNewActivatedTab(KUrl,KUrl)));
+ connect(m_tabWidget, SIGNAL(rememberClosedTab(KUrl,QByteArray)),
+ recentTabsMenu, SLOT(rememberClosedTab(KUrl,QByteArray)));
+ connect(recentTabsMenu, SIGNAL(restoreClosedTab(QByteArray)),
+ m_tabWidget, SLOT(restoreClosedTab(QByteArray)));
connect(recentTabsMenu, SIGNAL(closedTabsCountChanged(uint)),
this, SLOT(closedTabsCountChanged(uint)));
this, SLOT(handleAction(QAction*)));
}
-void DolphinRecentTabsMenu::rememberClosedTab(const KUrl& primaryUrl, const KUrl& secondaryUrl)
+void DolphinRecentTabsMenu::rememberClosedTab(const KUrl& url, const QByteArray& state)
{
QAction* action = new QAction(menu());
- action->setText(primaryUrl.path());
-
- const QString iconName = KMimeType::iconNameForUrl(primaryUrl);
+ action->setText(url.path());
+ action->setData(state);
+ const QString iconName = KMimeType::iconNameForUrl(url);
action->setIcon(KIcon(iconName));
- KUrl::List urls;
- urls << primaryUrl;
- urls << secondaryUrl;
- action->setData(QVariant::fromValue(urls));
-
// Add the closed tab menu entry after the separator and
// "Empty Recently Closed Tabs" entry
if (menu()->actions().size() == 2) {
}
emit closedTabsCountChanged(0);
} else {
- const KUrl::List urls = action->data().value<KUrl::List>();
+ const QByteArray state = action->data().value<QByteArray>();
removeAction(action);
delete action;
action = 0;
- if (urls.count() == 2) {
- emit restoreClosedTab(urls.first(), urls.last());
- }
+ emit restoreClosedTab(state);
emit closedTabsCountChanged(menu()->actions().size() - 2);
}
explicit DolphinRecentTabsMenu(QObject* parent);
public slots:
- void rememberClosedTab(const KUrl& primaryUrl, const KUrl& secondaryUrl);
+ void rememberClosedTab(const KUrl& url, const QByteArray& state);
void undoCloseTab();
signals:
- void restoreClosedTab(const KUrl& primaryUrl, const KUrl& secondaryUrl);
+ void restoreClosedTab(const QByteArray& state);
void closedTabsCountChanged(unsigned int count);
private slots:
}
DolphinTabPage* tabPage = tabPageAt(index);
- if (tabPage->splitViewEnabled()) {
- emit rememberClosedTab(tabPage->primaryViewContainer()->url(),
- tabPage->secondaryViewContainer()->url());
- } else {
- emit rememberClosedTab(tabPage->primaryViewContainer()->url(), KUrl());
- }
+ emit rememberClosedTab(tabPage->activeViewContainer()->url(), tabPage->saveState());
removeTab(index);
tabPage->deleteLater();
}
}
+void DolphinTabWidget::restoreClosedTab(const QByteArray& state)
+{
+ openNewActivatedTab();
+ currentTabPage()->restoreState(state);
+}
+
void DolphinTabWidget::detachTab(int index)
{
Q_ASSERT(index >= 0);
/**
* Is emitted when a tab has been closed.
*/
- void rememberClosedTab(const KUrl& primaryUrl, const KUrl& secondaryUrl);
+ void rememberClosedTab(const KUrl& url, const QByteArray& state);
public slots:
/**
*/
void slotPlacesPanelVisibilityChanged(bool visible);
+ /**
+ * Is called when the user wants to reopen a previously closed tab from
+ * the recent tabs menu.
+ */
+ void restoreClosedTab(const QByteArray& state);
+
private slots:
/**
* Opens the tab with the index \a index in a new Dolphin instance and closes