diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -2087,7 +2087,7 @@ bool DolphinMainWindow::isUrlOpen(const QString& url) { - if (m_tabWidget->getIndexByUrl(QUrl::fromUserInput((url))) >= 0) { + if (m_tabWidget->getIndexByUrl(QUrl::fromUserInput((url))).first >= 0) { return true; } else { return false; diff --git a/src/dolphintabwidget.h b/src/dolphintabwidget.h --- a/src/dolphintabwidget.h +++ b/src/dolphintabwidget.h @@ -80,9 +80,13 @@ /** * @param url The URL that we would like - * @return index of the tab with the desired URL. returns -1 if not found + * @return a QPair with first containing the index of the tab with the + * desired URL or -1 if not found. Second says true if URL is in primary + * view container, false otherwise. False means the URL is in the secondary + * view container, unless first == -1. In that case the value of second + * is meaningless. */ - int getIndexByUrl(const QUrl& url) const; + QPair getIndexByUrl(const QUrl& url) const; signals: /** diff --git a/src/dolphintabwidget.cpp b/src/dolphintabwidget.cpp --- a/src/dolphintabwidget.cpp +++ b/src/dolphintabwidget.cpp @@ -187,9 +187,15 @@ QList::const_iterator it = dirs.constBegin(); while (it != dirs.constEnd()) { const QUrl& primaryUrl = *(it++); - const int index = getIndexByUrl(primaryUrl); - if (index >= 0) { - setCurrentIndex(index); + const QPair 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())) { @@ -382,16 +388,18 @@ return name.replace('&', QLatin1String("&&")); } -int DolphinTabWidget::getIndexByUrl(const QUrl& url) const +QPair DolphinTabWidget::getIndexByUrl(const QUrl& url) const { for (int i = 0; i < count(); i++) { - // Conversion to display string is necessary to deal with the '~' alias. - // i.e. to acknowledge that ~/ is equivalent to /home/user/ - const QUrl tabUrl = tabPageAt(i)->activeViewContainer()->url(); - if (url == tabUrl || - url.toDisplayString(QUrl::StripTrailingSlash) == tabUrl.toDisplayString(QUrl::StripTrailingSlash)) { - return i; + QUrl primaryUrl = tabPageAt(i)->primaryViewContainer()->url(); + if (url == primaryUrl) { + return qMakePair(i, true); + } else if (auto secondView = tabPageAt(i)->secondaryViewContainer()) { + // If split view is enabled in this tab, check the second view. + if (url == secondView->url()) { + return qMakePair(i, false); + } } } - return -1; + return qMakePair(-1, false); } diff --git a/src/main.cpp b/src/main.cpp --- a/src/main.cpp +++ b/src/main.cpp @@ -116,8 +116,6 @@ KAboutData::setApplicationData(aboutData); - KDBusService dolphinDBusService; - DBusInterface interface; QCommandLineParser parser; aboutData.setupCommandLine(&parser); @@ -139,6 +137,8 @@ QList urls = Dolphin::validateUris(args); if (parser.isSet(QStringLiteral("daemon"))) { + KDBusService dolphinDBusService; + DBusInterface interface; return app.exec(); } @@ -178,5 +178,8 @@ } } + KDBusService dolphinDBusService; + DBusInterface interface; + return app.exec(); // krazy:exclude=crash; }