Changeset View
Changeset View
Standalone View
Standalone View
src/dolphintabwidget.cpp
Show First 20 Lines • Show All 110 Lines • ▼ Show 20 Line(s) | 94 | { | |||
---|---|---|---|---|---|
111 | const int index = group.readEntry("Active Tab Index", 0); | 111 | const int index = group.readEntry("Active Tab Index", 0); | ||
112 | setCurrentIndex(index); | 112 | setCurrentIndex(index); | ||
113 | } | 113 | } | ||
114 | 114 | | |||
115 | void DolphinTabWidget::refreshViews() | 115 | void DolphinTabWidget::refreshViews() | ||
116 | { | 116 | { | ||
117 | const int tabCount = count(); | 117 | const int tabCount = count(); | ||
118 | for (int i = 0; i < tabCount; ++i) { | 118 | for (int i = 0; i < tabCount; ++i) { | ||
119 | tabBar()->setTabText(i, tabName()); | ||||
119 | tabPageAt(i)->refreshViews(); | 120 | tabPageAt(i)->refreshViews(); | ||
120 | } | 121 | } | ||
121 | } | 122 | } | ||
122 | 123 | | |||
123 | void DolphinTabWidget::openNewActivatedTab() | 124 | void DolphinTabWidget::openNewActivatedTab() | ||
124 | { | 125 | { | ||
125 | const DolphinViewContainer* oldActiveViewContainer = currentTabPage()->activeViewContainer(); | 126 | const DolphinViewContainer* oldActiveViewContainer = currentTabPage()->activeViewContainer(); | ||
126 | Q_ASSERT(oldActiveViewContainer); | 127 | Q_ASSERT(oldActiveViewContainer); | ||
Show All 28 Lines | 155 | { | |||
155 | QWidget* focusWidget = QApplication::focusWidget(); | 156 | QWidget* focusWidget = QApplication::focusWidget(); | ||
156 | 157 | | |||
157 | DolphinTabPage* tabPage = new DolphinTabPage(primaryUrl, secondaryUrl, this); | 158 | DolphinTabPage* tabPage = new DolphinTabPage(primaryUrl, secondaryUrl, this); | ||
158 | tabPage->setPlacesSelectorVisible(m_placesSelectorVisible); | 159 | tabPage->setPlacesSelectorVisible(m_placesSelectorVisible); | ||
159 | connect(tabPage, &DolphinTabPage::activeViewChanged, | 160 | connect(tabPage, &DolphinTabPage::activeViewChanged, | ||
160 | this, &DolphinTabWidget::activeViewChanged); | 161 | this, &DolphinTabWidget::activeViewChanged); | ||
161 | connect(tabPage, &DolphinTabPage::activeViewUrlChanged, | 162 | connect(tabPage, &DolphinTabPage::activeViewUrlChanged, | ||
162 | this, &DolphinTabWidget::tabUrlChanged); | 163 | this, &DolphinTabWidget::tabUrlChanged); | ||
163 | addTab(tabPage, QIcon::fromTheme(KIO::iconNameForUrl(primaryUrl)), tabName(primaryUrl)); | 164 | addTab(tabPage, QIcon::fromTheme(KIO::iconNameForUrl(primaryUrl)), tabName()); | ||
164 | 165 | | |||
165 | if (focusWidget) { | 166 | if (focusWidget) { | ||
166 | // The DolphinViewContainer grabbed the keyboard focus. As the tab is opened | 167 | // The DolphinViewContainer grabbed the keyboard focus. As the tab is opened | ||
167 | // in background, assure that the previous focused widget gets the focus back. | 168 | // in background, assure that the previous focused widget gets the focus back. | ||
168 | focusWidget->setFocus(); | 169 | focusWidget->setFocus(); | ||
169 | } | 170 | } | ||
170 | } | 171 | } | ||
171 | 172 | | |||
▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Line(s) | 299 | if (index >= 0) { | |||
300 | view->dropUrls(view->url(), event, view); | 301 | view->dropUrls(view->url(), event, view); | ||
301 | } | 302 | } | ||
302 | } | 303 | } | ||
303 | 304 | | |||
304 | void DolphinTabWidget::tabUrlChanged(const QUrl& url) | 305 | void DolphinTabWidget::tabUrlChanged(const QUrl& url) | ||
305 | { | 306 | { | ||
306 | const int index = indexOf(qobject_cast<QWidget*>(sender())); | 307 | const int index = indexOf(qobject_cast<QWidget*>(sender())); | ||
307 | if (index >= 0) { | 308 | if (index >= 0) { | ||
308 | tabBar()->setTabText(index, tabName(url)); | 309 | tabBar()->setTabText(index, tabName()); | ||
309 | tabBar()->setTabIcon(index, QIcon::fromTheme(KIO::iconNameForUrl(url))); | 310 | tabBar()->setTabIcon(index, QIcon::fromTheme(KIO::iconNameForUrl(url))); | ||
310 | 311 | | |||
311 | // Emit the currentUrlChanged signal if the url of the current tab has been changed. | 312 | // Emit the currentUrlChanged signal if the url of the current tab has been changed. | ||
312 | if (index == currentIndex()) { | 313 | if (index == currentIndex()) { | ||
313 | emit currentUrlChanged(url); | 314 | emit currentUrlChanged(url); | ||
314 | } | 315 | } | ||
315 | } | 316 | } | ||
316 | } | 317 | } | ||
Show All 31 Lines | 345 | { | |||
348 | // closing the last tab is not possible. | 349 | // closing the last tab is not possible. | ||
349 | if (count() < 2) { | 350 | if (count() < 2) { | ||
350 | tabBar()->hide(); | 351 | tabBar()->hide(); | ||
351 | } | 352 | } | ||
352 | 353 | | |||
353 | emit tabCountChanged(count()); | 354 | emit tabCountChanged(count()); | ||
354 | } | 355 | } | ||
355 | 356 | | |||
356 | QString DolphinTabWidget::tabName(const QUrl& url) const | 357 | QString DolphinTabWidget::tabName() const | ||
357 | { | 358 | { | ||
358 | QString name; | 359 | if (currentTabPage() == nullptr) { | ||
359 | if (url == QUrl(QStringLiteral("file:///"))) { | 360 | return QString(); | ||
360 | name = '/'; | 361 | } | ||
361 | } else { | 362 | QString name = currentTabPage()->activeViewContainer()->getCaption(); | ||
362 | name = url.adjusted(QUrl::StripTrailingSlash).fileName(); | | |||
363 | if (name.isEmpty()) { | | |||
364 | name = url.scheme(); | | |||
365 | } else { | | |||
366 | // Make sure that a '&' inside the directory name is displayed correctly | 363 | // Make sure that a '&' inside the directory name is displayed correctly | ||
367 | // and not misinterpreted as a keyboard shortcut in QTabBar::setTabText() | 364 | // and not misinterpreted as a keyboard shortcut in QTabBar::setTabText() | ||
368 | name.replace('&', QLatin1String("&&")); | 365 | return name.replace('&', QLatin1String("&&")); | ||
369 | } | | |||
370 | } | | |||
371 | return name; | | |||
372 | } | 366 | } |