2 * Copyright 2020 Felix Ernst <fe.a.ernst@gmail.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) version 3, or any
8 * later version accepted by the membership of KDE e.V. (or its
9 * successor approved by the membership of KDE e.V.), which shall
10 * act as a proxy defined in Section 6 of version 3 of the license.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library. If not, see <https://www.gnu.org/licenses/>.
21 #ifndef DOLPHINURLNAVIGATOR_H
22 #define DOLPHINURLNAVIGATOR_H
24 #include <KCompletion>
25 #include <KUrlNavigator>
27 #include <forward_list>
32 * @brief Extends KUrlNavigator in a Dolphin-specific way
34 * Makes sure that Dolphin preferences, settings and settings changes are
35 * applied to all constructed DolphinUrlNavigators.
39 class DolphinUrlNavigator
: public KUrlNavigator
45 * Applies all Dolphin-specific settings to a KUrlNavigator
46 * @see KUrlNavigator::KurlNavigator()
48 DolphinUrlNavigator(QWidget
*parent
= nullptr);
51 * Applies all Dolphin-specific settings to a KUrlNavigator
52 * @see KUrlNavigator::KurlNavigator()
54 DolphinUrlNavigator(const QUrl
&url
, QWidget
*parent
= nullptr);
56 virtual ~DolphinUrlNavigator();
60 * Refreshes all DolphinUrlNavigators to get synchronized with the
61 * Dolphin settings if they were changed.
63 static void slotReadSettings();
66 * Switches to "breadcrumb" mode if the editable mode is not set to be
67 * preferred in the Dolphin settings.
69 void slotReturnPressed();
72 * This method is specifically here so the locationInToolbar
73 * KToggleAction that is created in DolphinMainWindow can be passed to
74 * this class and then appear in all context menus. This last part is
75 * done by eventFilter().
76 * For any other use parts of this class need to be rewritten.
77 * @param action The locationInToolbar-action from DolphinMainWindow
79 static void addToContextMenu(QAction
*action
);
81 static void slotPlacesPanelVisibilityChanged(bool visible
);
85 * Constructor-helper function
90 * This filter adds the s_ActionForContextMenu action to QMenus which
91 * are spawned by the watched QObject if that QMenu contains at least
93 * @see addToContextMenu()
95 bool eventFilter(QObject
* watched
, QEvent
* event
) override
;
99 * Sets the completion mode for all DolphinUrlNavigators
100 * and saves it in settings.
102 static void setCompletionMode(const KCompletion::CompletionMode completionMode
);
105 /** Contains all currently constructed DolphinUrlNavigators */
106 static std::forward_list
<DolphinUrlNavigator
*> s_instances
;
108 /** Caches the (negated) places panel visibility */
109 static bool s_placesSelectorVisible
;
111 /** An action that is added to the context menu */
112 static QAction
*s_ActionForContextMenu
;
115 #endif // DOLPHINURLNAVIGATOR_H