#include "dolphintabwidget.h"
+#include "dolphin_generalsettings.h"
#include "dolphintabbar.h"
#include "dolphintabpage.h"
#include "dolphinviewcontainer.h"
m_lastViewedTab(0)
{
connect(this, &DolphinTabWidget::tabCloseRequested,
- this, static_cast<void (DolphinTabWidget::*)(int)>(&DolphinTabWidget::closeTab));
+ this, QOverload<int>::of(&DolphinTabWidget::closeTab));
connect(this, &DolphinTabWidget::currentChanged,
this, &DolphinTabWidget::currentTabChanged);
DolphinTabBar* tabBar = new DolphinTabBar(this);
connect(tabBar, &DolphinTabBar::openNewActivatedTab,
- this, static_cast<void (DolphinTabWidget::*)(int)>(&DolphinTabWidget::openNewActivatedTab));
+ this, QOverload<int>::of(&DolphinTabWidget::openNewActivatedTab));
connect(tabBar, &DolphinTabBar::tabDropEvent,
this, &DolphinTabWidget::tabDropEvent);
connect(tabBar, &DolphinTabBar::tabDetachRequested,
void DolphinTabWidget::refreshViews()
{
+ // Left-elision is better when showing full paths, since you care most
+ // about the current directory which is on the right
+ if (GeneralSettings::showFullPathInTitlebar()) {
+ setElideMode(Qt::ElideLeft);
+ } else {
+ setElideMode(Qt::ElideRight);
+ }
+
const int tabCount = count();
for (int i = 0; i < tabCount; ++i) {
tabBar()->setTabText(i, tabName(tabPageAt(i)));
QWidget* focusWidget = QApplication::focusWidget();
DolphinTabPage* tabPage = new DolphinTabPage(primaryUrl, secondaryUrl, this);
+ tabPage->setActive(false);
tabPage->setPlacesSelectorVisible(m_placesSelectorVisible);
connect(tabPage, &DolphinTabPage::activeViewChanged,
this, &DolphinTabWidget::activeViewChanged);
if (tabPlacement == AfterCurrentTab) {
newTabIndex = currentIndex() + 1;
}
- insertTab(newTabIndex, tabPage, QIcon::fromTheme(KIO::iconNameForUrl(primaryUrl)), tabName(tabPage));
+ insertTab(newTabIndex, tabPage, QIcon() /* loaded in tabInserted */, tabName(tabPage));
if (focusWidget) {
// The DolphinViewContainer grabbed the keyboard focus. As the tab is opened
QList<QUrl>::const_iterator it = dirs.constBegin();
while (it != dirs.constEnd()) {
const QUrl& primaryUrl = *(it++);
+ const QPair<int, bool> viewLocation = getIndexByUrl(primaryUrl);
+ if (viewLocation.first >= 0) {
+ setCurrentIndex(viewLocation.first);
+ const auto tabPage = tabPageAt(viewLocation.first);
+ if (viewLocation.second) {
+ tabPage->primaryViewContainer()->setActive(true);
+ } else {
+ tabPage->secondaryViewContainer()->setActive(true);
+ }
+ continue;
+ }
if (splitView && (it != dirs.constEnd())) {
const QUrl& secondaryUrl = *(it++);
- openNewTab(primaryUrl, secondaryUrl);
+ openNewActivatedTab(primaryUrl, secondaryUrl);
} else {
- openNewTab(primaryUrl);
+ openNewActivatedTab(primaryUrl);
}
}
}
args << tabPage->secondaryViewContainer()->url().url();
args << QStringLiteral("--split");
}
+ args << QStringLiteral("--new-window");
const QString command = QStringLiteral("dolphin %1").arg(KShell::joinArgs(args));
KRun::runCommand(command, this);
const int index = indexOf(qobject_cast<QWidget*>(sender()));
if (index >= 0) {
tabBar()->setTabText(index, tabName(tabPageAt(index)));
- tabBar()->setTabIcon(index, QIcon::fromTheme(KIO::iconNameForUrl(url)));
+ if (tabBar()->isVisible()) {
+ tabBar()->setTabIcon(index, QIcon::fromTheme(KIO::iconNameForUrl(url)));
+ } else {
+ // Mark as dirty, actually load once the tab bar actually gets shown
+ tabBar()->setTabIcon(index, QIcon());
+ }
// Emit the currentUrlChanged signal if the url of the current tab has been changed.
if (index == currentIndex()) {
QTabWidget::tabInserted(index);
if (count() > 1) {
+ // Resolve all pending tab icons
+ for (int i = 0; i < count(); ++i) {
+ if (tabBar()->tabIcon(i).isNull()) {
+ tabBar()->setTabIcon(i, QIcon::fromTheme(KIO::iconNameForUrl(tabPageAt(i)->activeViewContainer()->url())));
+ }
+ }
+
tabBar()->show();
}
// and not misinterpreted as a keyboard shortcut in QTabBar::setTabText()
return name.replace('&', QLatin1String("&&"));
}
+
+QPair<int, bool> DolphinTabWidget::getIndexByUrl(const QUrl& url) const
+{
+ for (int i = 0; i < count(); i++) {
+ const auto tabPage = tabPageAt(i);
+ if (url == tabPage->primaryViewContainer()->url()) {
+ return qMakePair(i, true);
+ }
+
+ if (tabPage->splitViewEnabled() && url == tabPage->secondaryViewContainer()->url()) {
+ return qMakePair(i, false);
+ }
+ }
+ return qMakePair(-1, false);
+}