mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-17 15:31:20 +00:00
Don't re-open already-open URLs when using session-restore feature
If Dolphin would be asked to open a location that is already open, don't open it again in a new tab; instead switch to that view. Supports tabs and split view. BUG: 434911 FIXED-IN: 21.04
This commit is contained in:
parent
a32373e587
commit
1755380208
|
@ -186,14 +186,20 @@ void DolphinTabWidget::openDirectories(const QList<QUrl>& dirs, bool splitView)
|
||||||
{
|
{
|
||||||
Q_ASSERT(dirs.size() > 0);
|
Q_ASSERT(dirs.size() > 0);
|
||||||
|
|
||||||
|
bool somethingWasAlreadyOpen = false;
|
||||||
|
|
||||||
QList<QUrl>::const_iterator it = dirs.constBegin();
|
QList<QUrl>::const_iterator it = dirs.constBegin();
|
||||||
while (it != dirs.constEnd()) {
|
while (it != dirs.constEnd()) {
|
||||||
const QUrl& primaryUrl = *(it++);
|
const QUrl& primaryUrl = *(it++);
|
||||||
const QPair<int, bool> indexInfo = indexByUrl(primaryUrl);
|
const QPair<int, bool> indexInfo = indexByUrl(primaryUrl);
|
||||||
const int index = indexInfo.first;
|
const int index = indexInfo.first;
|
||||||
const bool isInPrimaryView = indexInfo.second;
|
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) {
|
if (index >= 0) {
|
||||||
setCurrentIndex(index);
|
somethingWasAlreadyOpen = true;
|
||||||
|
activateTab(index);
|
||||||
const auto tabPage = tabPageAt(index);
|
const auto tabPage = tabPageAt(index);
|
||||||
if (isInPrimaryView) {
|
if (isInPrimaryView) {
|
||||||
tabPage->primaryViewContainer()->setActive(true);
|
tabPage->primaryViewContainer()->setActive(true);
|
||||||
|
@ -204,13 +210,19 @@ void DolphinTabWidget::openDirectories(const QList<QUrl>& dirs, bool splitView)
|
||||||
// Required for updateViewState() call in openFiles() to work as expected
|
// Required for updateViewState() call in openFiles() to work as expected
|
||||||
// If there is a selection, updateViewState() calls are effectively a no-op
|
// If there is a selection, updateViewState() calls are effectively a no-op
|
||||||
tabPage->activeViewContainer()->view()->clearSelection();
|
tabPage->activeViewContainer()->view()->clearSelection();
|
||||||
continue;
|
} else if (splitView) {
|
||||||
}
|
|
||||||
if (splitView && (it != dirs.constEnd())) {
|
|
||||||
const QUrl& secondaryUrl = *(it++);
|
const QUrl& secondaryUrl = *(it++);
|
||||||
openNewActivatedTab(primaryUrl, secondaryUrl);
|
if (somethingWasAlreadyOpen) {
|
||||||
|
openNewTab(primaryUrl, secondaryUrl);
|
||||||
|
} else {
|
||||||
|
openNewActivatedTab(primaryUrl, secondaryUrl);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
openNewActivatedTab(primaryUrl);
|
if (somethingWasAlreadyOpen) {
|
||||||
|
openNewTab(primaryUrl);
|
||||||
|
} else {
|
||||||
|
openNewActivatedTab(primaryUrl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue