]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinurlnavigatorscontroller.cpp
GIT_SILENT Sync po/docbooks with svn
[dolphin.git] / src / dolphinurlnavigatorscontroller.cpp
1 /*
2 This file is part of the KDE project
3 SPDX-FileCopyrightText: 2020 Felix Ernst <felixernst@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6 */
7
8 #include "dolphinurlnavigatorscontroller.h"
9
10 #include "dolphin_generalsettings.h"
11 #include "dolphinurlnavigator.h"
12 #include "global.h"
13
14 #include <KUrlComboBox>
15
16 void DolphinUrlNavigatorsController::slotReadSettings()
17 {
18 // The startup settings should (only) get applied if they have been
19 // modified by the user. Otherwise keep the (possibly) different current
20 // settings of the URL navigators and split view.
21 if (GeneralSettings::modifiedStartupSettings()) {
22 for (DolphinUrlNavigator *urlNavigator : s_instances) {
23 urlNavigator->setUrlEditable(GeneralSettings::editableUrl());
24 urlNavigator->setShowFullPath(GeneralSettings::showFullPath());
25 urlNavigator->setHomeUrl(Dolphin::homeUrl());
26 }
27 }
28 }
29
30 void DolphinUrlNavigatorsController::slotPlacesPanelVisibilityChanged(bool visible)
31 {
32 // The places-selector from the URL navigator should only be shown
33 // if the places dock is invisible
34 s_placesSelectorVisible = !visible;
35
36 for (DolphinUrlNavigator *urlNavigator : s_instances) {
37 urlNavigator->setPlacesSelectorVisible(s_placesSelectorVisible);
38 }
39 }
40
41 bool DolphinUrlNavigatorsController::placesSelectorVisible()
42 {
43 return s_placesSelectorVisible;
44 }
45
46 void DolphinUrlNavigatorsController::registerDolphinUrlNavigator(DolphinUrlNavigator *dolphinUrlNavigator)
47 {
48 s_instances.push_front(dolphinUrlNavigator);
49 connect(dolphinUrlNavigator->editor(), &KUrlComboBox::completionModeChanged, DolphinUrlNavigatorsController::setCompletionMode);
50 }
51
52 void DolphinUrlNavigatorsController::unregisterDolphinUrlNavigator(DolphinUrlNavigator *dolphinUrlNavigator)
53 {
54 s_instances.remove(dolphinUrlNavigator);
55 }
56
57 void DolphinUrlNavigatorsController::setCompletionMode(const KCompletion::CompletionMode completionMode)
58 {
59 if (completionMode != GeneralSettings::urlCompletionMode()) {
60 GeneralSettings::setUrlCompletionMode(completionMode);
61 for (const DolphinUrlNavigator *urlNavigator : s_instances) {
62 urlNavigator->editor()->setCompletionMode(completionMode);
63 }
64 }
65 }
66
67 std::forward_list<DolphinUrlNavigator *> DolphinUrlNavigatorsController::s_instances;
68 bool DolphinUrlNavigatorsController::s_placesSelectorVisible = true;
69
70 #include "moc_dolphinurlnavigatorscontroller.cpp"