diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2023-06-19 01:38:40 +0200 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2023-06-19 01:38:40 +0200 |
commit | ce1a64bc19ffc21e115bdf2587bb053d7a417f3e (patch) | |
tree | a195d127228218772a535448de642f0bb7b6d053 /src/timeline/TimelineViewManager.h | |
parent | Remove explicit link styling (diff) | |
download | nheko-ce1a64bc19ffc21e115bdf2587bb053d7a417f3e.tar.xz |
Move to automatic type registration
Diffstat (limited to 'src/timeline/TimelineViewManager.h')
-rw-r--r-- | src/timeline/TimelineViewManager.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/timeline/TimelineViewManager.h b/src/timeline/TimelineViewManager.h index 303e2af2..a4bc6c41 100644 --- a/src/timeline/TimelineViewManager.h +++ b/src/timeline/TimelineViewManager.h @@ -34,6 +34,9 @@ class TimelineViewManager final : public QObject { Q_OBJECT + QML_NAMED_ELEMENT(TimelineManager) + QML_SINGLETON + Q_PROPERTY( bool isInitialSync MEMBER isInitialSync_ READ isInitialSync NOTIFY initialSyncChanged) Q_PROPERTY(bool isConnected READ isConnected NOTIFY isConnectedChanged) @@ -41,6 +44,25 @@ class TimelineViewManager final : public QObject public: TimelineViewManager(CallManager *callManager, ChatPage *parent = nullptr); + static TimelineViewManager *create(QQmlEngine *qmlEngine, QJSEngine *) + { + // The instance has to exist before it is used. We cannot replace it. + Q_ASSERT(instance_); + + // The engine has to have the same thread affinity as the singleton. + Q_ASSERT(qmlEngine->thread() == instance_->thread()); + + // There can only be one engine accessing the singleton. + static QJSEngine *s_engine = nullptr; + if (s_engine) + Q_ASSERT(qmlEngine == s_engine); + else + s_engine = qmlEngine; + + QJSEngine::setObjectOwnership(instance_, QJSEngine::CppOwnership); + return instance_; + } + void sync(const mtx::responses::Sync &sync_); VerificationManager *verificationManager() { return verificationManager_; } @@ -123,6 +145,7 @@ private: bool isConnected_ = true; RoomlistModel *rooms_ = nullptr; + FilteredRoomlistModel *frooms_ = nullptr; CommunitiesModel *communities_ = nullptr; // don't move this above the rooms_ @@ -130,4 +153,6 @@ private: PresenceEmitter *presenceEmitter = nullptr; QHash<QPair<QString, quint64>, QColor> userColors; + + inline static TimelineViewManager *instance_ = nullptr; }; |