2 This file is part of the KDE project
3 SPDX-FileCopyrightText: 2020 Felix Ernst <felixernst@kde.org>
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
8 #include "dolphinurlnavigatorscontroller.h"
10 #include "dolphin_generalsettings.h"
11 #include "dolphinurlnavigator.h"
14 #include <KUrlComboBox>
16 void DolphinUrlNavigatorsController::slotReadSettings()
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());
30 void DolphinUrlNavigatorsController::slotPlacesPanelVisibilityChanged(bool visible
)
32 // The places-selector from the URL navigator should only be shown
33 // if the places dock is invisible
34 s_placesSelectorVisible
= !visible
;
36 for (DolphinUrlNavigator
*urlNavigator
: s_instances
) {
37 urlNavigator
->setPlacesSelectorVisible(s_placesSelectorVisible
);
41 bool DolphinUrlNavigatorsController::placesSelectorVisible()
43 return s_placesSelectorVisible
;
46 void DolphinUrlNavigatorsController::registerDolphinUrlNavigator(DolphinUrlNavigator
*dolphinUrlNavigator
)
48 s_instances
.push_front(dolphinUrlNavigator
);
49 connect(dolphinUrlNavigator
->editor(), &KUrlComboBox::completionModeChanged
, DolphinUrlNavigatorsController::setCompletionMode
);
52 void DolphinUrlNavigatorsController::unregisterDolphinUrlNavigator(DolphinUrlNavigator
*dolphinUrlNavigator
)
54 s_instances
.remove(dolphinUrlNavigator
);
57 void DolphinUrlNavigatorsController::setCompletionMode(const KCompletion::CompletionMode completionMode
)
59 if (completionMode
!= GeneralSettings::urlCompletionMode()) {
60 GeneralSettings::setUrlCompletionMode(completionMode
);
61 for (const DolphinUrlNavigator
*urlNavigator
: s_instances
) {
62 urlNavigator
->editor()->setCompletionMode(completionMode
);
67 std::forward_list
<DolphinUrlNavigator
*> DolphinUrlNavigatorsController::s_instances
;
68 bool DolphinUrlNavigatorsController::s_placesSelectorVisible
= true;
70 #include "moc_dolphinurlnavigatorscontroller.cpp"