void TabBar::setupHistoryActions() { MainWindow *w = Application::instance()->mainWindow(); MainView *mv = qobject_cast<MainView *>(parent()); QAction *openLastClosedTabAction = w->actionByName( QL1S("open_last_closed_tab") ); openLastClosedTabAction->setEnabled( mv->recentlyClosedTabs().size() > 0 ); // update closed tabs menu KActionMenu *am = qobject_cast<KActionMenu *>( 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; Q_FOREACH(const HistoryItem &item, mv->recentlyClosedTabs()) { KAction *a = new KAction(Application::iconManager()->iconForUrl(item.url), item.title, this); a->setData(item.url); connect(a, SIGNAL(triggered()), mv, SLOT(openClosedTab())); am->addAction(a); } }
KActionMenu *TabBar::setupHistoryActions() { MainWindow *w = rApp->mainWindow(); MainView *mv = qobject_cast<MainView *>(parent()); QAction *openLastClosedTabAction = w->actionByName(QL1S("open_last_closed_tab")); bool closedTabsAvailable = (mv->recentlyClosedTabs().size() > 0); openLastClosedTabAction->setEnabled(closedTabsAvailable); KActionMenu *am = new KActionMenu(KIcon("tab-new"), i18n("Closed Tabs"), this); am->setDelayed(false); am->setEnabled(closedTabsAvailable); if (am->menu()) am->menu()->clear(); if (!closedTabsAvailable) return am; for (int i = 0; i < mv->recentlyClosedTabs().count(); ++i) { TabHistory item = mv->recentlyClosedTabs().at(i); KAction *a = new KAction(rApp->iconManager()->iconForUrl(item.url), item.title, this); a->setData(i); connect(a, SIGNAL(triggered()), mv, SLOT(openClosedTab())); am->addAction(a); } return am; }