From 2d4d2ce9a14902ee5a2b236f8510596fc2f86b99 Mon Sep 17 00:00:00 2001 From: Felix Ernst Date: Thu, 5 Nov 2020 23:30:07 +0100 Subject: Adress most of the second round of Angelaccio's review comments This commit applies most suggestions which were made on the MR. Most notably the DolphinUrlNavigator class is split up which leads to the creation of a DolphinUrlNavigatorsController class. Additionally some minor coding style and const correctness changes are included. The error value of cached integers is changed from -1 to INT_MIN because situations could come up in which -1 would be a valid value. --- src/dolphinurlnavigatorscontroller.cpp | 67 ++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/dolphinurlnavigatorscontroller.cpp (limited to 'src/dolphinurlnavigatorscontroller.cpp') diff --git a/src/dolphinurlnavigatorscontroller.cpp b/src/dolphinurlnavigatorscontroller.cpp new file mode 100644 index 000000000..78fecd18a --- /dev/null +++ b/src/dolphinurlnavigatorscontroller.cpp @@ -0,0 +1,67 @@ +/* + This file is part of the KDE project + SPDX-FileCopyrightText: 2020 Felix Ernst + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "dolphinurlnavigatorscontroller.h" + +#include "dolphin_generalsettings.h" +#include "dolphinurlnavigator.h" +#include "global.h" + +#include + +void DolphinUrlNavigatorsController::slotReadSettings() +{ + // The startup settings should (only) get applied if they have been + // modified by the user. Otherwise keep the (possibly) different current + // settings of the URL navigators and split view. + if (GeneralSettings::modifiedStartupSettings()) { + for (DolphinUrlNavigator *urlNavigator : s_instances) { + urlNavigator->setUrlEditable(GeneralSettings::editableUrl()); + urlNavigator->setShowFullPath(GeneralSettings::showFullPath()); + urlNavigator->setHomeUrl(Dolphin::homeUrl()); + } + } +} + +void DolphinUrlNavigatorsController::slotPlacesPanelVisibilityChanged(bool visible) +{ + // The places-selector from the URL navigator should only be shown + // if the places dock is invisible + s_placesSelectorVisible = !visible; + + for (DolphinUrlNavigator *urlNavigator : s_instances) { + urlNavigator->setPlacesSelectorVisible(s_placesSelectorVisible); + } +} + +bool DolphinUrlNavigatorsController::placesSelectorVisible() +{ + return s_placesSelectorVisible; +} + +void DolphinUrlNavigatorsController::registerDolphinUrlNavigator(DolphinUrlNavigator *dolphinUrlNavigator) +{ + s_instances.push_front(dolphinUrlNavigator); +} + +void DolphinUrlNavigatorsController::unregisterDolphinUrlNavigator(DolphinUrlNavigator *dolphinUrlNavigator) +{ + s_instances.remove(dolphinUrlNavigator); +} + +void DolphinUrlNavigatorsController::setCompletionMode(const KCompletion::CompletionMode completionMode) +{ + if (completionMode != GeneralSettings::urlCompletionMode()) { + GeneralSettings::setUrlCompletionMode(completionMode); + for (const DolphinUrlNavigator *urlNavigator : s_instances) { + urlNavigator->editor()->setCompletionMode(completionMode); + } + } +} + +std::forward_list DolphinUrlNavigatorsController::s_instances; +bool DolphinUrlNavigatorsController::s_placesSelectorVisible = true; -- cgit v1.3