diff options
| author | Felix Ernst <[email protected]> | 2020-11-05 23:30:07 +0100 |
|---|---|---|
| committer | Elvis Angelaccio <[email protected]> | 2020-11-09 23:49:07 +0100 |
| commit | 2d4d2ce9a14902ee5a2b236f8510596fc2f86b99 (patch) | |
| tree | 07607a2561e3f6e268e4e883f422582bdc908013 /src/dolphinurlnavigatorscontroller.h | |
| parent | 42023831374496c62708ce7ad2cdd69104a1c820 (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.h')
| -rw-r--r-- | src/dolphinurlnavigatorscontroller.h | 76 |
1 files changed, 76 insertions, 0 deletions
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 <[email protected]> + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#ifndef DOLPHINURLNAVIGATORSCONTROLLER_H +#define DOLPHINURLNAVIGATORSCONTROLLER_H + +#include <KCompletion> + +#include <QObject> + +#include <forward_list> + +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<DolphinUrlNavigator *> s_instances; + + /** Caches the (negated) places panel visibility */ + static bool s_placesSelectorVisible; + + friend class DolphinUrlNavigator; +}; + +#endif // DOLPHINURLNAVIGATORSCONTROLLER_H |
