#include "dolphin_generalsettings.h"
#include "dolphintabbar.h"
#include "dolphinviewcontainer.h"
+#include "views/draganddrophelper.h"
#include <KAcceleratorManager>
#include <KConfigGroup>
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);
const int tabCount = count();
for (int i = 0; i < tabCount; ++i) {
- tabBar()->setTabText(i, tabName(tabPageAt(i)));
+ updateTabName(i);
tabPageAt(i)->refreshViews();
}
}
+void DolphinTabWidget::updateTabName(int index)
+{
+ Q_ASSERT(index >= 0);
+ tabBar()->setTabText(index, tabName(tabPageAt(index)));
+}
+
bool DolphinTabWidget::isUrlOpen(const QUrl &url) const
{
return viewOpenAtDirectory(url).has_value();
connect(tabPage, &DolphinTabPage::activeViewChanged, this, &DolphinTabWidget::activeViewChanged);
connect(tabPage, &DolphinTabPage::activeViewUrlChanged, this, &DolphinTabWidget::tabUrlChanged);
connect(tabPage->activeViewContainer(), &DolphinViewContainer::captionChanged, this, [this, tabPage]() {
- const int tabIndex = indexOf(tabPage);
- Q_ASSERT(tabIndex >= 0);
- tabBar()->setTabText(tabIndex, tabName(tabPage));
+ updateTabName(indexOf(tabPage));
});
if (position == NewTabPosition::FollowSetting) {
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) {
{
const int index = indexOf(qobject_cast<QWidget *>(sender()));
if (index >= 0) {
- tabBar()->setTabText(index, tabName(tabPageAt(index)));
+ updateTabName(index);
tabBar()->setTabToolTip(index, url.toDisplayString(QUrl::PreferLocalFile));
if (tabBar()->isVisible()) {
// ensure the path url ends with a slash to have proper folder icon for remote folders
if (index == currentIndex()) {
Q_EMIT currentUrlChanged(url);
}
+
+ Q_EMIT urlChanged(url);
}
}