Commit a96e7c8296d789a38c0d4834413e8abf98608fde

Fixed bug causing Ctrl+W to not close current tab (accidentally redefined the shortcut when I meant to define m_reload's). Deleted the closeCurrentTab() function and converted closeTab(int index) to be closeTab(int index = CLOSECURRENT) where CLOSECURRENT is defined as -5 (the function checks for that and knows to redefine index to the current tab's index). Made webtab use tabBar() instead of "tabs" when manipulating the tab bar... can now just ditch making my own tab bar as thats automatically handled if I want... may just keep it around for when I switch to KTab*.

Commit diff

src/foxkit.cpp

 
115115 m_closeTab = new KAction(KIcon("tab-close.png"), i18n("Close Tab"), this);
116116 m_closeTab->setStatusTip(i18n("Closes the current tab."));
117117 m_closeTab->setShortcut(i18n("Ctrl+W"));
118 connect(m_closeTab, SIGNAL(triggered()), this, SLOT(closeCurrentTab()));
118 connect(m_closeTab, SIGNAL(triggered()), this, SLOT(closeTab()));
119119 actionCollection()->addAction("closetab", m_closeTab);
120120
121121 KStandardAction::back(this, SLOT(pageBack()), actionCollection());
122122 KStandardAction::forward(this, SLOT(pageForward()), actionCollection());
123123 m_reload = new KAction(KIcon("view-refresh.png"), i18n("Reload"), this);
124 m_closeTab->setStatusTip(i18n("Reloads the current tab."));
125 m_closeTab->setShortcut(i18n("F5"));
124 m_reload->setStatusTip(i18n("Reloads the current tab."));
125 m_reload->setShortcut(i18n("F5"));
126126 connect(m_reload, SIGNAL(triggered()), this, SLOT(pageReload()));
127127 actionCollection()->addAction("reload", m_reload);
128128 KStandardAction::quit(kapp, SLOT(quit()), actionCollection());
299299 newTab(url);
300300}
301301
302void foxkit::closeCurrentTab()
303{
304 closeTab(tabs->currentIndex());
305}
306
307302void foxkit::closeTab(int index)
308303{
304 if(index == CLOSECURRENT)
305 index = tabs->currentIndex(); // We wanna close the current tab.
306
309307 //FIXME unless a new tab is created before removing the last tab it will segfault
310308 //TODO: Make a nice little template for a blank page and show that instead (call it 'about:foxkit'?)
311309 if(tabs->count() == 1)
335335 }
336336}
337337
338//TODO Inline these functions? Maybe connect the buttons directly to m_activeView->back()?
338//TODO Connect the buttons directly to m_activeView->back() and delete these?
339339void foxkit::pageBack()
340340{
341341 m_activeView->back();
toggle raw diff

src/foxkit.h

 
4141class QProgressBar;
4242#include <KLineEdit>
4343
44#define CLOSECURRENT -5
45
4446class foxkit : public KXmlGuiWindow
4547{
4648 Q_OBJECT
7171 void setCurrentTitle(QString title, int);
7272 void setIcon(QIcon icon, int index);
7373 void setStatusBarText(QString text, int);
74 void closeCurrentTab();
75 void closeTab(int index);
74 void closeTab(int index = CLOSECURRENT);
7675 void loadProgress(int progress, int index);
7776 void newViewUrl(bool newWin, QUrl url);
7877
toggle raw diff

src/webtab.cpp

 
3131
3232webTab::~webTab()
3333{
34 tabs->deleteLater();
34 tabBar()->deleteLater();
3535}
3636
3737void webTab::hideTabs()
3838{
39 tabs->hide();
39 tabBar()->hide();
4040}
4141void webTab::showTabs()
4242{
43 tabs->show();
43 tabBar()->show();
4444}
4545
4646void webTab::closeTab(int index)
4747{
4848 removeTab(index);
4949 if(count() <= 1)
50 tabs->hide();
50 tabBar()->hide();
5151}
5252
5353int webTab::newTab(QWidget * page, const QString & label)
5454{
5555 int tmp = addTab(page, label);
5656 if(count() > 1)
57 tabs->show();
57 tabBar()->show();
5858 return tmp;
5959}
6060
toggle raw diff