diff options
Diffstat (limited to 'options/bundle.hpp')
-rw-r--r-- | options/bundle.hpp | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/options/bundle.hpp b/options/bundle.hpp index 9ab7f74c..c1bb716d 100644 --- a/options/bundle.hpp +++ b/options/bundle.hpp @@ -29,14 +29,8 @@ #include "export.hpp" namespace options::detail { - class OTR_OPTIONS_EXPORT mutex final : public QMutex - { - public: - explicit mutex(QMutex::RecursionMode mode); - cc_noinline operator QMutex*() const; // NOLINT - }; - class bundle; + struct bundler; } // ns options::detail namespace options { @@ -51,11 +45,15 @@ class OTR_OPTIONS_EXPORT bundle final : public QObject, public connector { Q_OBJECT - mutex mtx; + friend struct bundler; + + mutable QMutex mtx { QMutex::Recursive }; const QString group_name; group saved; group transient; + void reload_no_notify(); + signals: void reloading(); void saving() const; @@ -65,7 +63,7 @@ public: bundle(const bundle&) = delete; bundle& operator=(const bundle&) = delete; - QMutex* get_mtx() const override { return mtx; } + QMutex* get_mtx() const override { return &mtx; } QString name() const { return group_name; } explicit bundle(const QString& group_name); @@ -75,6 +73,7 @@ public: bool contains(const QString& name) const; QVariant get_variant(const QString& name) const; + void notify(); public slots: void save(); @@ -89,19 +88,25 @@ struct OTR_OPTIONS_EXPORT bundler final using weak = std::weak_ptr<v>; using shared = std::shared_ptr<v>; - static void refresh_all_bundles(); + static void notify(); + static void reload_no_notify(); + + void reload(); private: QMutex implsgl_mtx { QMutex::Recursive }; std::unordered_map<k, weak> implsgl_data {}; - void after_profile_changed_(); + void notify_(); + void reload_no_notify_(); + + void reload_(); - friend OTR_OPTIONS_EXPORT + friend std::shared_ptr<v> options::make_bundle(const QString& name); - [[nodiscard]] std::shared_ptr<v> make_bundle_(const k& key); - [[nodiscard]] static bundler& bundler_singleton(); + std::shared_ptr<v> make_bundle_(const k& key); + static bundler& singleton(); bundler(); ~bundler(); |