]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Make it more obvious that you can connect to servers on remote:/ page
authorNate Graham <nate@kde.org>
Thu, 10 Dec 2020 22:16:12 +0000 (15:16 -0700)
committerElvis Angelaccio <elvis.angelaccio@kde.org>
Sun, 27 Dec 2020 17:38:55 +0000 (17:38 +0000)
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
src/dolphinurlnavigator.cpp
src/dolphinurlnavigator.h

index cabeac4ed2cdc05439fe883b19750e82b5135494..6b76aad08424c965252f79cb0c6af4f55435cd6e 100644 (file)
@@ -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);
index 1dfe5420f1df6d8d31464351575e6c5bd8bd1fd5..d8d325bb43530e588b7ff743cf25c926df0a9d4d 100644 (file)
@@ -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()) {
index 9bcc32b4d1463d1cfbcc37a31dd3068b92cdb312..1962e2f06269c994bd0c30c4eda9e03fc2c0383f 100644 (file)
@@ -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