From c5a713763daf113c78697341bfea7dc0860192a3 Mon Sep 17 00:00:00 2001 From: Elvis Angelaccio Date: Sun, 1 Sep 2019 22:32:35 +0200 Subject: [PATCH 1/3] Fix places text when the URL has a trailing slash Summary: QUrl::fileName() returns an empty string if the URL ends with a slash. Test Plan: 1. Run `dolphin /tmp` from command line 2. Right-click from viewport and click 'Add to Places' Reviewers: ngraham Subscribers: kfm-devel Tags: #dolphin Differential Revision: https://phabricator.kde.org/D23654 --- src/dolphinviewcontainer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index 5856105505..6a8ff914b5 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -426,7 +426,7 @@ QString DolphinViewContainer::placesText() const if (isSearchModeEnabled()) { text = i18n("Search for %1 in %2", m_searchBox->text(), m_searchBox->searchPath().fileName()); } else { - text = url().fileName(); + text = url().adjusted(QUrl::StripTrailingSlash).fileName(); if (text.isEmpty()) { text = url().host(); } From 56b3059f774ae5917185d91a380c9f0a95e7584f Mon Sep 17 00:00:00 2001 From: Alexander Saoutkin Date: Mon, 2 Sep 2019 23:13:52 +0200 Subject: [PATCH 2/3] Making sure that DBus objects are all created before the service Summary: Currently the DBus service is created before the MainWindow DBus object is created. This can cause hangs if another service makes calls to a a method in an object that's not been initialised, when the service is already published. This patch defers the creation of the service until all DBus objects are created. Test Plan: Tested in KDevelop. Have "open new folders in tabs" feature enabled. Open several folders with Dolphin at once. Before this patch there would be noticeable hanging. With this patch all tabs instantly open with no hanging. Reviewers: elvisangelaccio, ngraham Reviewed By: elvisangelaccio Subscribers: kfm-devel Tags: #dolphin Differential Revision: https://phabricator.kde.org/D23672 --- src/main.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 8981b54bce..a4685f2573 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -116,9 +116,6 @@ extern "C" Q_DECL_EXPORT int kdemain(int argc, char **argv) KAboutData::setApplicationData(aboutData); - KDBusService dolphinDBusService; - DBusInterface interface; - QCommandLineParser parser; aboutData.setupCommandLine(&parser); @@ -139,6 +136,8 @@ extern "C" Q_DECL_EXPORT int kdemain(int argc, char **argv) QList urls = Dolphin::validateUris(args); if (parser.isSet(QStringLiteral("daemon"))) { + KDBusService dolphinDBusService; + DBusInterface interface; return app.exec(); } @@ -178,5 +177,8 @@ extern "C" Q_DECL_EXPORT int kdemain(int argc, char **argv) } } + KDBusService dolphinDBusService; + DBusInterface interface; + return app.exec(); // krazy:exclude=crash; } From a6403716439ae72bfdf86a14af94ea9d212f08ee Mon Sep 17 00:00:00 2001 From: Alexander Saoutkin Date: Mon, 2 Sep 2019 23:15:08 +0200 Subject: [PATCH 3/3] Fixing bugs in new folders in tabs feature Summary: Fixing bug where urls in secondary view containers would not be considered for the open new folders in tabs feature. Test Plan: Manual testing. Testing for no regressions. Testing that URL is found if in secondary view container Reviewers: elvisangelaccio Reviewed By: elvisangelaccio Subscribers: kfm-devel, ngraham Tags: #dolphin Differential Revision: https://phabricator.kde.org/D23655 --- src/dolphinmainwindow.cpp | 2 +- src/dolphintabwidget.cpp | 29 ++++++++++++++++++----------- src/dolphintabwidget.h | 8 ++++++-- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 19f7906629..c9ed9c5cd5 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -2089,7 +2089,7 @@ void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job* job) 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.cpp b/src/dolphintabwidget.cpp index defd089c16..7928c510e2 100644 --- a/src/dolphintabwidget.cpp +++ b/src/dolphintabwidget.cpp @@ -186,9 +186,15 @@ void DolphinTabWidget::openDirectories(const QList& dirs, bool splitView) 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())) { @@ -381,16 +387,17 @@ QString DolphinTabWidget::tabName(DolphinTabPage* tabPage) const 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; + 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 -1; + return qMakePair(-1, false); } diff --git a/src/dolphintabwidget.h b/src/dolphintabwidget.h index 3e8301725c..7eb001b219 100644 --- a/src/dolphintabwidget.h +++ b/src/dolphintabwidget.h @@ -80,9 +80,13 @@ public: /** * @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: /**