2020-06-14 14:20:02 +00:00
|
|
|
/*
|
2020-09-20 16:53:59 +00:00
|
|
|
This file is part of the KDE project
|
|
|
|
SPDX-FileCopyrightText: 2020 Felix Ernst <fe.a.ernst@gmail.com>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
|
|
|
*/
|
2020-06-14 14:20:02 +00:00
|
|
|
|
|
|
|
#ifndef DOLPHINURLNAVIGATOR_H
|
|
|
|
#define DOLPHINURLNAVIGATOR_H
|
|
|
|
|
|
|
|
#include <KUrlNavigator>
|
|
|
|
|
|
|
|
/**
|
2020-11-05 22:30:07 +00:00
|
|
|
* @brief Extends KUrlNavigator in a Dolphin-specific way.
|
2020-09-20 16:53:59 +00:00
|
|
|
*
|
2020-11-05 22:30:07 +00:00
|
|
|
* Makes sure that Dolphin preferences and settings are
|
2020-06-14 14:20:02 +00:00
|
|
|
* applied to all constructed DolphinUrlNavigators.
|
|
|
|
* @see KUrlNavigator
|
2020-11-09 13:25:15 +00:00
|
|
|
*
|
|
|
|
* To apply changes to all instances of this class @see DolphinUrlNavigatorsController.
|
2020-06-14 14:20:02 +00:00
|
|
|
*/
|
|
|
|
class DolphinUrlNavigator : public KUrlNavigator
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Applies all Dolphin-specific settings to a KUrlNavigator
|
|
|
|
* @see KUrlNavigator::KurlNavigator()
|
|
|
|
*/
|
|
|
|
DolphinUrlNavigator(QWidget *parent = nullptr);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Applies all Dolphin-specific settings to a KUrlNavigator
|
|
|
|
* @see KUrlNavigator::KurlNavigator()
|
|
|
|
*/
|
|
|
|
DolphinUrlNavigator(const QUrl &url, QWidget *parent = nullptr);
|
|
|
|
|
2021-10-25 11:34:22 +00:00
|
|
|
~DolphinUrlNavigator() override;
|
2020-06-14 14:20:02 +00:00
|
|
|
|
2020-11-05 22:30:07 +00:00
|
|
|
// TODO: Fix KUrlNavigator::sizeHint() instead.
|
2020-09-20 16:53:59 +00:00
|
|
|
QSize sizeHint() const override;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Wraps the visual state of a DolphinUrlNavigator so it can be passed around.
|
|
|
|
* This notably doesn't involve the locationUrl or history.
|
|
|
|
*/
|
|
|
|
struct VisualState {
|
|
|
|
bool isUrlEditable;
|
|
|
|
bool hasFocus;
|
|
|
|
QString text;
|
|
|
|
int cursorPosition;
|
|
|
|
int selectionStart;
|
|
|
|
int selectionLength;
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* Retrieve the visual state of this DolphinUrlNavigator.
|
|
|
|
* If two DolphinUrlNavigators have the same visual state they should look identical.
|
2020-11-09 13:25:15 +00:00
|
|
|
*
|
|
|
|
* @return a copy of the visualState of this object. Ownership of this copy is transferred
|
|
|
|
* to the caller via std::unique_ptr.
|
2020-09-20 16:53:59 +00:00
|
|
|
*/
|
|
|
|
std::unique_ptr<VisualState> visualState() const;
|
|
|
|
/**
|
|
|
|
* @param visualState A struct describing the new visual state of this object.
|
|
|
|
*/
|
|
|
|
void setVisualState(const VisualState &visualState);
|
|
|
|
|
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
2020-12-10 22:16:12 +00:00
|
|
|
/**
|
|
|
|
* Clears the text in the text field
|
|
|
|
*/
|
|
|
|
void clearText() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays placeholder text in the URL navigator
|
|
|
|
*/
|
|
|
|
void setPlaceholderText(const QString &text);
|
|
|
|
|
2021-02-08 22:09:59 +00:00
|
|
|
public Q_SLOTS:
|
2020-06-14 14:20:02 +00:00
|
|
|
/**
|
|
|
|
* Switches to "breadcrumb" mode if the editable mode is not set to be
|
|
|
|
* preferred in the Dolphin settings.
|
|
|
|
*/
|
|
|
|
void slotReturnPressed();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // DOLPHINURLNAVIGATOR_H
|