X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/c161b895ffd8d62371ec288cf4105386350a8a3c..844d1c05477a3137cce54561514c851bdfe49406:/src/dolphintabwidget.cpp diff --git a/src/dolphintabwidget.cpp b/src/dolphintabwidget.cpp index d61a9f74f..cfb695e7d 100644 --- a/src/dolphintabwidget.cpp +++ b/src/dolphintabwidget.cpp @@ -87,15 +87,8 @@ void DolphinTabWidget::readProperties(const KConfigGroup& group) if (i >= count()) { openNewActivatedTab(); } - if (group.hasKey("Tab Data " % QString::number(i))) { - // Tab state created with Dolphin > 4.14.x - const QByteArray state = group.readEntry("Tab Data " % QString::number(i), QByteArray()); - tabPageAt(i)->restoreState(state); - } else { - // Tab state created with Dolphin <= 4.14.x - const QByteArray state = group.readEntry("Tab " % QString::number(i), QByteArray()); - tabPageAt(i)->restoreStateV1(state); - } + const QByteArray state = group.readEntry("Tab Data " % QString::number(i), QByteArray()); + tabPageAt(i)->restoreState(state); } const int index = group.readEntry("Active Tab Index", 0); @@ -186,14 +179,20 @@ void DolphinTabWidget::openDirectories(const QList& dirs, bool splitView) { Q_ASSERT(dirs.size() > 0); + bool somethingWasAlreadyOpen = false; + QList::const_iterator it = dirs.constBegin(); while (it != dirs.constEnd()) { const QUrl& primaryUrl = *(it++); const QPair indexInfo = indexByUrl(primaryUrl); const int index = indexInfo.first; const bool isInPrimaryView = indexInfo.second; + + // When the user asks for a URL that's already open, activate it instead + // of opening a second copy if (index >= 0) { - setCurrentIndex(index); + somethingWasAlreadyOpen = true; + activateTab(index); const auto tabPage = tabPageAt(index); if (isInPrimaryView) { tabPage->primaryViewContainer()->setActive(true); @@ -204,13 +203,19 @@ void DolphinTabWidget::openDirectories(const QList& dirs, bool splitView) // Required for updateViewState() call in openFiles() to work as expected // If there is a selection, updateViewState() calls are effectively a no-op tabPage->activeViewContainer()->view()->clearSelection(); - continue; - } - if (splitView && (it != dirs.constEnd())) { + } else if (splitView && (it != dirs.constEnd())) { const QUrl& secondaryUrl = *(it++); - openNewActivatedTab(primaryUrl, secondaryUrl); + if (somethingWasAlreadyOpen) { + openNewTab(primaryUrl, secondaryUrl); + } else { + openNewActivatedTab(primaryUrl, secondaryUrl); + } } else { - openNewActivatedTab(primaryUrl); + if (somethingWasAlreadyOpen) { + openNewTab(primaryUrl); + } else { + openNewActivatedTab(primaryUrl); + } } } }