┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphinurlnavigatorscontroller.cpp
diff options
context:
space:
mode:
authorFelix Ernst <[email protected]>2020-11-05 23:30:07 +0100
committerElvis Angelaccio <[email protected]>2020-11-09 23:49:07 +0100
commit2d4d2ce9a14902ee5a2b236f8510596fc2f86b99 (patch)
tree07607a2561e3f6e268e4e883f422582bdc908013 /src/dolphinurlnavigatorscontroller.cpp
parent42023831374496c62708ce7ad2cdd69104a1c820 (diff)
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.
Diffstat (limited to 'src/dolphinurlnavigatorscontroller.cpp')
-rw-r--r--src/dolphinurlnavigatorscontroller.cpp67
1 files changed, 67 insertions, 0 deletions
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 <[email protected]>
+
+ 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 <KUrlComboBox>
+
+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<DolphinUrlNavigator *> DolphinUrlNavigatorsController::s_instances;
+bool DolphinUrlNavigatorsController::s_placesSelectorVisible = true;