171
171
_addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
173
173
connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int)));
175
// ----------------------------------------------------------------------------------------------
176
// shortcuts for quickly switching to a tab
177
QSignalMapper *tabSignalMapper = new QSignalMapper(this);
178
for (int i = 0; i < 9; i++)
180
a = new KAction(i18n("Switch to Tab %1", i+1), this);
181
a->setShortcut(KShortcut(QString("Alt+%1").arg(i+1)));
182
actionCollection()->addAction(QL1S(QString("switch_tab_" + QString::number(i+1)).toAscii()), a);
183
connect(a, SIGNAL(triggered(bool)), tabSignalMapper, SLOT(map()));
184
tabSignalMapper->setMapping(a, i);
186
connect(tabSignalMapper, SIGNAL(mapped(int)), this, SLOT(setCurrentIndex(int)));
188
// shortcuts for loading favorite pages
189
QSignalMapper *favoritesSignalMapper = new QSignalMapper(this);
190
for (int i = 1; i <= 9; ++i)
192
a = new KAction(i18n("Switch to Favorite Page %1", i), this);
193
a->setShortcut(KShortcut(QString("Ctrl+%1").arg(i)));
194
actionCollection()->addAction(QL1S(QString("switch_favorite_" + QString::number(i)).toAscii()), a);
195
connect(a, SIGNAL(triggered(bool)), favoritesSignalMapper, SLOT(map()));
196
favoritesSignalMapper->setMapping(a, i);
198
connect(favoritesSignalMapper, SIGNAL(mapped(int)), this, SLOT(loadFavorite(int)));
220
247
WebWindow *tab = new WebWindow(this, _isPrivateBrowsing, page);
222
249
connect(tab, SIGNAL(titleChanged(QString)), this, SLOT(tabTitleChanged(QString)));
250
connect(tab, SIGNAL(iconChanged()), this, SLOT(tabIconChanged()));
224
252
connect(tab, SIGNAL(loadStarted()), this, SLOT(tabLoadStarted()));
225
253
connect(tab, SIGNAL(loadFinished(bool)), this, SLOT(tabLoadFinished(bool)));
366
394
tabTitle.replace('&', "&&");
368
396
int index = indexOf(tab);
369
398
if (-1 != index && !tabBar()->tabData(index).toBool())
371
400
setTabText(index, tabTitle);
414
void TabWindow::tabIconChanged()
416
WebWindow *tab = qobject_cast<WebWindow *>(sender());
420
if (tab->isLoading())
423
int index = indexOf(tab);
428
QLabel *label = qobject_cast<QLabel* >(tabBar()->tabButton(index, QTabBar::LeftSide));
431
label = new QLabel(this);
432
tabBar()->setTabButton(index, QTabBar::LeftSide, 0);
433
tabBar()->setTabButton(index, QTabBar::LeftSide, label);
436
KIcon ic = IconManager::self()->iconForUrl(tab->url());
437
label->setPixmap(ic.pixmap(16, 16));
385
441
void TabWindow::tabLoadStarted()
387
443
WebWindow *tab = qobject_cast<WebWindow *>(sender());
577
633
// WARNING: Code copied from prepareNewTab method.
578
634
// Any new changes there should be applied here...
579
635
disconnect(tab, SIGNAL(titleChanged(QString)), this, SLOT(tabTitleChanged(QString)));
636
disconnect(tab, SIGNAL(iconChanged()), this, SLOT(tabIconChanged()));
580
637
disconnect(tab, SIGNAL(loadStarted()), this, SLOT(tabLoadStarted()));
581
638
disconnect(tab, SIGNAL(loadFinished(bool)), this, SLOT(tabLoadFinished(bool)));
582
639
disconnect(tab, SIGNAL(pageCreated(WebPage*)), this, SLOT(pageCreated(WebPage*)));
585
642
// WARNING: Code copied from prepareNewTab method.
586
643
// Any new changes there should be applied here...
587
644
connect(tab, SIGNAL(titleChanged(QString)), w, SLOT(tabTitleChanged(QString)));
645
connect(tab, SIGNAL(iconChanged()), w, SLOT(tabIconChanged()));
588
646
connect(tab, SIGNAL(loadStarted()), w, SLOT(tabLoadStarted()));
589
647
connect(tab, SIGNAL(loadFinished(bool)), w, SLOT(tabLoadFinished(bool)));
590
648
connect(tab, SIGNAL(pageCreated(WebPage*)), w, SLOT(pageCreated(WebPage*)));
673
731
return _isPrivateBrowsing;
735
void TabWindow::loadFavorite(const int index)
737
QStringList urls = ReKonfig::previewUrls();
738
if (index < 0 || index > urls.length())
741
KUrl url = KUrl(urls.at(index - 1));
743
currentWebWindow()->setFocus();