File indexing completed on 2024-04-21 16:30:16
0001 /* 0002 This file is part of the KDE project 0003 SPDX-FileCopyrightText: 2020 Felix Ernst <felixernst@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0006 */ 0007 0008 #include "dolphinurlnavigatorscontroller.h" 0009 0010 #include "dolphin_generalsettings.h" 0011 #include "dolphinurlnavigator.h" 0012 #include "global.h" 0013 0014 #include <KUrlComboBox> 0015 0016 void DolphinUrlNavigatorsController::slotReadSettings() 0017 { 0018 // The startup settings should (only) get applied if they have been 0019 // modified by the user. Otherwise keep the (possibly) different current 0020 // settings of the URL navigators and split view. 0021 if (GeneralSettings::modifiedStartupSettings()) { 0022 for (DolphinUrlNavigator *urlNavigator : s_instances) { 0023 urlNavigator->setUrlEditable(GeneralSettings::editableUrl()); 0024 urlNavigator->setShowFullPath(GeneralSettings::showFullPath()); 0025 urlNavigator->setHomeUrl(Dolphin::homeUrl()); 0026 } 0027 } 0028 } 0029 0030 void DolphinUrlNavigatorsController::slotPlacesPanelVisibilityChanged(bool visible) 0031 { 0032 // The places-selector from the URL navigator should only be shown 0033 // if the places dock is invisible 0034 s_placesSelectorVisible = !visible; 0035 0036 for (DolphinUrlNavigator *urlNavigator : s_instances) { 0037 urlNavigator->setPlacesSelectorVisible(s_placesSelectorVisible); 0038 } 0039 } 0040 0041 bool DolphinUrlNavigatorsController::placesSelectorVisible() 0042 { 0043 return s_placesSelectorVisible; 0044 } 0045 0046 void DolphinUrlNavigatorsController::registerDolphinUrlNavigator(DolphinUrlNavigator *dolphinUrlNavigator) 0047 { 0048 s_instances.push_front(dolphinUrlNavigator); 0049 connect(dolphinUrlNavigator->editor(), &KUrlComboBox::completionModeChanged, DolphinUrlNavigatorsController::setCompletionMode); 0050 } 0051 0052 void DolphinUrlNavigatorsController::unregisterDolphinUrlNavigator(DolphinUrlNavigator *dolphinUrlNavigator) 0053 { 0054 s_instances.remove(dolphinUrlNavigator); 0055 } 0056 0057 void DolphinUrlNavigatorsController::setCompletionMode(const KCompletion::CompletionMode completionMode) 0058 { 0059 if (completionMode != GeneralSettings::urlCompletionMode()) { 0060 GeneralSettings::setUrlCompletionMode(completionMode); 0061 for (const DolphinUrlNavigator *urlNavigator : s_instances) { 0062 urlNavigator->editor()->setCompletionMode(completionMode); 0063 } 0064 } 0065 } 0066 0067 std::forward_list<DolphinUrlNavigator *> DolphinUrlNavigatorsController::s_instances; 0068 bool DolphinUrlNavigatorsController::s_placesSelectorVisible = true; 0069 0070 #include "moc_dolphinurlnavigatorscontroller.cpp"