X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/e2f316578909e4c886430110808d4681997b3cb7..2201018673467bf7a871082b1fd1e3f8c6f926e7:/src/dolphintabwidget.cpp diff --git a/src/dolphintabwidget.cpp b/src/dolphintabwidget.cpp index f80b94ea7..b2f838a40 100644 --- a/src/dolphintabwidget.cpp +++ b/src/dolphintabwidget.cpp @@ -21,6 +21,7 @@ #include #include +#include DolphinTabWidget::DolphinTabWidget(DolphinNavigatorsWidgetAction *navigatorsWidget, QWidget *parent) : QTabWidget(parent) @@ -37,12 +38,20 @@ DolphinTabWidget::DolphinTabWidget(DolphinNavigatorsWidgetAction *navigatorsWidg connect(tabBar, &DolphinTabBar::tabDragMoveEvent, this, &DolphinTabWidget::tabDragMoveEvent); connect(tabBar, &DolphinTabBar::tabDropEvent, this, &DolphinTabWidget::tabDropEvent); connect(tabBar, &DolphinTabBar::tabDetachRequested, this, &DolphinTabWidget::detachTab); + connect(tabBar, &DolphinTabBar::tabRenamed, this, &DolphinTabWidget::renameTab); setTabBar(tabBar); setDocumentMode(true); setElideMode(Qt::ElideRight); setUsesScrollButtons(true); setTabBarAutoHide(true); + + auto stackWidget{findChild()}; + // i18n: This accessible name will be announced any time the user moves keyboard focus e.g. from the toolbar or the places panel towards the main working + // area of Dolphin. It gives structure. This container does not only contain the main view but also the status bar, the search panel, filter, and selection + // mode bars, so calling it just a "View" is a bit wrong, but hopefully still gets the point across. + stackWidget->setAccessibleName(i18nc("accessible name of Dolphin's view container", "Location View")); // Without this call, the non-descript Qt provided + // "Layered Pane" role is announced. } DolphinTabPage *DolphinTabWidget::currentTabPage() const @@ -114,6 +123,13 @@ void DolphinTabWidget::refreshViews() void DolphinTabWidget::updateTabName(int index) { Q_ASSERT(index >= 0); + + if (!tabPageAt(index)->customLabel().isEmpty()) { + QString name = tabPageAt(index)->customLabel(); + tabBar()->setTabText(index, name); + return; + } + tabBar()->setTabText(index, tabName(tabPageAt(index))); } @@ -162,7 +178,7 @@ void DolphinTabWidget::openNewActivatedTab(const QUrl &primaryUrl, const QUrl &s } } -void DolphinTabWidget::openNewTab(const QUrl &primaryUrl, const QUrl &secondaryUrl, DolphinTabWidget::NewTabPosition position) +DolphinTabPage *DolphinTabWidget::openNewTab(const QUrl &primaryUrl, const QUrl &secondaryUrl, DolphinTabWidget::NewTabPosition position) { QWidget *focusWidget = QApplication::focusWidget(); @@ -194,6 +210,7 @@ void DolphinTabWidget::openNewTab(const QUrl &primaryUrl, const QUrl &secondaryU // in background, assure that the previous focused widget gets the focus back. focusWidget->setFocus(); } + return tabPage; } void DolphinTabWidget::openDirectories(const QList &dirs, bool splitView) @@ -463,6 +480,12 @@ void DolphinTabWidget::currentTabChanged(int index) m_lastViewedTab = tabPage; } +void DolphinTabWidget::renameTab(int index, const QString &name) +{ + tabPageAt(index)->setCustomLabel(name); + updateTabName(index); +} + void DolphinTabWidget::tabInserted(int index) { QTabWidget::tabInserted(index);