From 5e581fc1fa5a1d1d23fe8c4e3fe94fb2fc9250ab Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 16 Jun 2010 01:50:19 +0200 Subject: This commit changes rekonq behavior on "closed tabs" management. The problem comes when too much sites are listed as closed tabs, so I though to create the contextual menu just on request and to clean out the sites that are reopened. (They are NO MORE closed tabs..) This and the next commit should fast a lot rekonq about that --- src/tabbar.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src/tabbar.cpp') diff --git a/src/tabbar.cpp b/src/tabbar.cpp index 09aa814d..a1bbf2b8 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -46,6 +46,7 @@ #include #include #include +#include // Qt Includes #include @@ -284,6 +285,8 @@ void TabBar::mousePressEvent(QMouseEvent *event) void TabBar::contextMenu(int tab, const QPoint &pos) { + setupHistoryActions(); + m_actualIndex = tab; KMenu menu; @@ -308,6 +311,8 @@ void TabBar::contextMenu(int tab, const QPoint &pos) void TabBar::emptyAreaContextMenu(const QPoint &pos) { + setupHistoryActions(); + KMenu menu; MainWindow *mainWindow = Application::instance()->mainWindow(); @@ -342,3 +347,35 @@ void TabBar::tabRemoved(int index) m_currentTabPreviewIndex = -1; } } + + +void TabBar::setupHistoryActions() +{ + MainWindow *w = Application::instance()->mainWindow(); + MainView *mv = qobject_cast(parent()); + + QAction *openClosedTabsAction = w->actionByName( QL1S("open_closed_tabs") ); + openClosedTabsAction->setEnabled( mv->recentlyClosedTabs().size() > 0 ); + + // update closed tabs menu + KActionMenu *am = qobject_cast( w->actionByName( QL1S("closed_tab_menu") )); + if (!am) + return; + + bool isEnabled = ( mv->recentlyClosedTabs().size() > 0 ); + am->setEnabled(isEnabled); + + if (am->menu()) + am->menu()->clear(); + + if(!isEnabled) + return; + + foreach (const HistoryItem &item, mv->recentlyClosedTabs()) + { + KAction *a = new KAction(Application::icon(item.url), item.title, this); + a->setData(item.url); + connect(a, SIGNAL(triggered()), mv, SLOT(openClosedTab())); + am->addAction(a); + } +} -- cgit v1.2.1