From 7918bce1422fb217b59131111c6fb1ccdf52ddc4 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sun, 5 Jan 2020 10:55:56 +0200 Subject: Code cleanup - Replace Browser::getProfileManager with WebProfileManager::instance - Make WebProfileManager::profileMenu a free function - Replace Browser::loadProfile with Browser::loadProfiles --- src/webengine/webprofilemanager.h | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'src/webengine/webprofilemanager.h') diff --git a/src/webengine/webprofilemanager.h b/src/webengine/webprofilemanager.h index 2d9cd29..0e18d5f 100644 --- a/src/webengine/webprofilemanager.h +++ b/src/webengine/webprofilemanager.h @@ -18,28 +18,34 @@ #include #include +void profileMenu(QMenu *menu, const std::function &callback, WebProfile *current = nullptr, bool checkable = false); + +class Browser; class WebProfileManager : public QObject { Q_OBJECT + + friend class Browser; + friend void profileMenu(QMenu *, const std::function &, WebProfile *current, bool); + public: explicit WebProfileManager(QObject *parent); - ~WebProfileManager(); + ~WebProfileManager() override; + + static auto instance() -> const WebProfileManager *; + static void setInstance(WebProfileManager *ptr); /** Create a profile with specified id * param id The profile ID - * param path The path to the profile settings - * param isOffTheRecord Off-the-record toggle * return WebProfile* The profile, or nullptr if one could not be created */ - WebProfile *profile(const QString &id, const QString &path = QString(), bool isOffTheRecord = true); + WebProfile *profile(const QString &id) const; /** Set a profile for deletion * param id The profile ID * return void */ - void deleteProfile(const QString &id); - - void profileMenu(QMenu *menu, const std::function &callback, WebProfile *current = nullptr, bool checkable = false) const; + [[deprecated]] void deleteProfile(const QString &id); const QStringList idList() const { @@ -56,6 +62,9 @@ public: return QString(); } +protected: + WebProfile *add(const QString &id, const QString &path = QString(), bool isOffTheRecord = true); + private: struct Profile { WebProfile *ptr = nullptr; -- cgit v1.2.1