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.h | 76 ++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/dolphinurlnavigatorscontroller.h (limited to 'src/dolphinurlnavigatorscontroller.h') diff --git a/src/dolphinurlnavigatorscontroller.h b/src/dolphinurlnavigatorscontroller.h new file mode 100644 index 000000000..797cbf4f9 --- /dev/null +++ b/src/dolphinurlnavigatorscontroller.h @@ -0,0 +1,76 @@ +/* + 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 +*/ + +#ifndef DOLPHINURLNAVIGATORSCONTROLLER_H +#define DOLPHINURLNAVIGATORSCONTROLLER_H + +#include + +#include + +#include + +class DolphinUrlNavigator; + +/** + * @brief A controller managing all DolphinUrlNavigators. + * + * This class is used to apply settings changes to all constructed DolphinUrlNavigators. + * + * @see DolphinUrlNavigator + */ +class DolphinUrlNavigatorsController : public QObject +{ + Q_OBJECT + +public: + DolphinUrlNavigatorsController() = delete; + +public slots: + /** + * Refreshes all DolphinUrlNavigators to get synchronized with the + * Dolphin settings if they were changed. + */ + static void slotReadSettings(); + + static void slotPlacesPanelVisibilityChanged(bool visible); + +private: + /** + * @return wether the places selector of DolphinUrlNavigators should be visible. + */ + static bool placesSelectorVisible(); + + /** + * Adds \p dolphinUrlNavigator to the list of DolphinUrlNavigators + * controlled by this class. + */ + static void registerDolphinUrlNavigator(DolphinUrlNavigator *dolphinUrlNavigator); + + /** + * Removes \p dolphinUrlNavigator from the list of DolphinUrlNavigators + * controlled by this class. + */ + static void unregisterDolphinUrlNavigator(DolphinUrlNavigator *dolphinUrlNavigator); + +private slots: + /** + * Sets the completion mode for all DolphinUrlNavigators and saves it in settings. + */ + static void setCompletionMode(const KCompletion::CompletionMode completionMode); + +private: + /** Contains all currently constructed DolphinUrlNavigators */ + static std::forward_list s_instances; + + /** Caches the (negated) places panel visibility */ + static bool s_placesSelectorVisible; + + friend class DolphinUrlNavigator; +}; + +#endif // DOLPHINURLNAVIGATORSCONTROLLER_H -- cgit v1.3