X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/37327c9b0aae112c5890703cba1f0157043007e0..1c857e5589ef21a5f100e510b6f5e8aa5c1aeef2:/src/dolphinurlnavigator.h diff --git a/src/dolphinurlnavigator.h b/src/dolphinurlnavigator.h index 8f8d270ae..d6da51b47 100644 --- a/src/dolphinurlnavigator.h +++ b/src/dolphinurlnavigator.h @@ -1,6 +1,6 @@ /* This file is part of the KDE project - SPDX-FileCopyrightText: 2020 Felix Ernst + SPDX-FileCopyrightText: 2020 Felix Ernst SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ @@ -8,20 +8,16 @@ #ifndef DOLPHINURLNAVIGATOR_H #define DOLPHINURLNAVIGATOR_H -#include #include -#include - -class KToggleAction; - /** - * @brief Extends KUrlNavigator in a Dolphin-specific way + * @brief Extends KUrlNavigator in a Dolphin-specific way. * - * Makes sure that Dolphin preferences, settings and settings changes are + * Makes sure that Dolphin preferences and settings are * applied to all constructed DolphinUrlNavigators. - * * @see KUrlNavigator + * + * To apply changes to all instances of this class @see DolphinUrlNavigatorsController. */ class DolphinUrlNavigator : public KUrlNavigator { @@ -40,14 +36,9 @@ public: */ DolphinUrlNavigator(const QUrl &url, QWidget *parent = nullptr); - virtual ~DolphinUrlNavigator(); + ~DolphinUrlNavigator() override; - /** - * This method is needed so the DolphinNavigatorWidgetAction knows when there is not enough - * space to neatly align the UrlNavigator with the ViewContainers. Unfortunately KUrlNavigator - * does not have a useful sizeHint() currently. It would make more sense to change - * KUrlNavigator instead. - */ + // TODO: Fix KUrlNavigator::sizeHint() instead. QSize sizeHint() const override; /** @@ -65,6 +56,9 @@ public: /** * Retrieve the visual state of this DolphinUrlNavigator. * If two DolphinUrlNavigators have the same visual state they should look identical. + * + * @return a copy of the visualState of this object. Ownership of this copy is transferred + * to the caller via std::unique_ptr. */ std::unique_ptr visualState() const; /** @@ -72,40 +66,44 @@ public: */ void setVisualState(const VisualState &visualState); -public slots: /** - * Refreshes all DolphinUrlNavigators to get synchronized with the - * Dolphin settings if they were changed. + * Clears the text in the text field */ - static void slotReadSettings(); + void clearText() const; /** - * Switches to "breadcrumb" mode if the editable mode is not set to be - * preferred in the Dolphin settings. + * Displays placeholder text in the URL navigator */ - void slotReturnPressed(); + void setPlaceholderText(const QString &text); - static void slotPlacesPanelVisibilityChanged(bool visible); + /** + * Sets the visibility of the read-only badge at the end of the breadcrumb. + */ + void setReadOnlyBadgeVisible(bool visible); -protected: /** - * Constructor-helper function + * Returns the visibility of the read-only badge at the end of the breadcrumb. */ - void init(); + bool readOnlyBadgeVisible() const; -protected slots: +public Q_SLOTS: /** - * Sets the completion mode for all DolphinUrlNavigators - * and saves it in settings. + * Switches to "breadcrumb" mode if the editable mode is not set to be + * preferred in the Dolphin settings. */ - static void setCompletionMode(const KCompletion::CompletionMode completionMode); + void slotReturnPressed(); -protected: - /** Contains all currently constructed DolphinUrlNavigators */ - static std::forward_list s_instances; +Q_SIGNALS: + /** + * Escape was pressed, and the focus should return to the view. + */ + void requestToLoseFocus(); - /** Caches the (negated) places panel visibility */ - static bool s_placesSelectorVisible; +protected: + /** + * Return focus back to the view when pressing Escape and this would have no other effect (e.g. deselecting or changing edit mode). + */ + void keyPressEvent(QKeyEvent *keyEvent) override; }; #endif // DOLPHINURLNAVIGATOR_H