#include "dolphin_generalsettings.h"
#include "dolphintabbar.h"
#include "dolphinviewcontainer.h"
+#include "views/draganddrophelper.h"
#include <KAcceleratorManager>
#include <KConfigGroup>
#include <QApplication>
#include <QDropEvent>
+#include <QStackedWidget>
DolphinTabWidget::DolphinTabWidget(DolphinNavigatorsWidgetAction *navigatorsWidget, QWidget *parent)
: QTabWidget(parent)
DolphinTabBar *tabBar = new DolphinTabBar(this);
connect(tabBar, &DolphinTabBar::openNewActivatedTab, this, QOverload<int>::of(&DolphinTabWidget::openNewActivatedTab));
+ 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<QStackedWidget *>()};
+ // 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
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)));
}
}
}
-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();
// in background, assure that the previous focused widget gets the focus back.
focusWidget->setFocus();
}
+ return tabPage;
}
void DolphinTabWidget::openDirectories(const QList<QUrl> &dirs, bool splitView)
openNewActivatedTab(tabPage->activeViewContainer()->url());
}
+void DolphinTabWidget::tabDragMoveEvent(int index, QDragMoveEvent *event)
+{
+ if (index >= 0) {
+ DolphinView *view = tabPageAt(index)->activeViewContainer()->view();
+ DragAndDropHelper::updateDropAction(event, view->url());
+ }
+}
+
void DolphinTabWidget::tabDropEvent(int index, QDropEvent *event)
{
if (index >= 0) {
if (index == currentIndex()) {
Q_EMIT currentUrlChanged(url);
}
+
+ Q_EMIT urlChanged(url);
}
}
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);