From b14f98de19b97bcf8ca967f635c6df39963df2b0 Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Thu, 10 Dec 2020 15:16:12 -0700 Subject: [PATCH] Make it more obvious that you can connect to servers on remote:/ page Right now it is not super obvious how you connect to a remote server in Dolphin when you already know the URL. Users will go to the "Network" item in the Places panel, but from there it is not totally clear. The "Add Network Folder" icon in the view opens a complicated wizard and it's also a bit of an odd UX to have it living in the view as opposed to being a toolbar button. Old hands and developers know that the URL navigator is, well, a URL navigator, and as such, it accepts arbitrary URLs from any view. However this may not be obvious to other more casual users, for two reasons: 1. The URL navigator is in breadcrumbs view nearly all of the time and by default, so may users may not know that it can accept text at all 2. Even when it's displaying URLs, they are almost always local paths, so users may not make the connection that it can accept remote URLs rather that just local paths To improve the discoverability of this feature, this commit makes the following change: When the view is displaying the remote:/ ioslave (i.e. the "Networks" place), the URL navigator is put into URL entry mode and given some placeholder text that hints at what it can do. It reverts to breadcrumbs mode when you leave. BUG: 414670 FIXED-IN: 21.04 --- src/dolphinnavigatorswidgetaction.cpp | 17 +++++++++++++++-- src/dolphinurlnavigator.cpp | 10 ++++++++++ src/dolphinurlnavigator.h | 10 ++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/dolphinnavigatorswidgetaction.cpp b/src/dolphinnavigatorswidgetaction.cpp index cabeac4ed2..6b76aad084 100644 --- a/src/dolphinnavigatorswidgetaction.cpp +++ b/src/dolphinnavigatorswidgetaction.cpp @@ -212,11 +212,24 @@ QWidget *DolphinNavigatorsWidgetAction::createNavigatorWidget(Side side) const auto emptyTrashButton = newEmptyTrashButton(urlNavigator, navigatorWidget); layout->addWidget(emptyTrashButton); - connect(urlNavigator, &KUrlNavigator::urlChanged, this, [this]() { + connect(urlNavigator, &KUrlNavigator::urlChanged, this, [urlNavigator, this]() { + // Update URL navigator to show a server URL entry placeholder text if we + // just loaded the remote:/ page, to make it easier for users to figure out + // that they can enter arbitrary remote URLs. See bug 414670 + if (urlNavigator->locationUrl().scheme() == QLatin1String("remote")) { + if (!urlNavigator->isUrlEditable()) { + urlNavigator->setUrlEditable(true); + } + urlNavigator->clearText(); + urlNavigator->setPlaceholderText(i18n("Enter server URL (e.g. smb://[ip address])")); + } else { + urlNavigator->setPlaceholderText(QString()); + } + // We have to wait for DolphinUrlNavigator::sizeHint() to update which // happens a little bit later than when urlChanged is emitted. this->m_adjustSpacingTimer->start(); - }); + }, Qt::QueuedConnection); auto trailingSpacing = new QWidget{navigatorWidget}; layout->addWidget(trailingSpacing); diff --git a/src/dolphinurlnavigator.cpp b/src/dolphinurlnavigator.cpp index 1dfe5420f1..d8d325bb43 100644 --- a/src/dolphinurlnavigator.cpp +++ b/src/dolphinurlnavigator.cpp @@ -101,6 +101,16 @@ void DolphinUrlNavigator::setVisualState(const VisualState& visualState) } } +void DolphinUrlNavigator::clearText() const +{ + editor()->lineEdit()->clear(); +} + +void DolphinUrlNavigator::setPlaceholderText(const QString &text) +{ + editor()->lineEdit()->setPlaceholderText(text); +} + void DolphinUrlNavigator::slotReturnPressed() { if (!GeneralSettings::editableUrl()) { diff --git a/src/dolphinurlnavigator.h b/src/dolphinurlnavigator.h index 9bcc32b4d1..1962e2f062 100644 --- a/src/dolphinurlnavigator.h +++ b/src/dolphinurlnavigator.h @@ -66,6 +66,16 @@ public: */ void setVisualState(const VisualState &visualState); + /** + * Clears the text in the text field + */ + void clearText() const; + + /** + * Displays placeholder text in the URL navigator + */ + void setPlaceholderText(const QString &text); + public slots: /** * Switches to "breadcrumb" mode if the editable mode is not set to be