Move to automatic type registration

This commit is contained in:
Nicolas Werner 2023-06-19 01:38:40 +02:00
parent 2cb04fd741
commit ce1a64bc19
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
73 changed files with 570 additions and 472 deletions

View file

@ -9,10 +9,13 @@
#include <mtx/events/encrypted.hpp>
#include <mtxclient/crypto/client.hpp>
#include <QQmlEngine>
#include <CacheCryptoStructs.h>
namespace olm {
Q_NAMESPACE
QML_NAMED_ELEMENT(Olm)
enum DecryptionErrorCode
{

View file

@ -29,6 +29,11 @@ SelfVerificationStatus::SelfVerificationStatus(QObject *o)
Qt::UniqueConnection);
cache::client()->markUserKeysOutOfDate({http::client()->user_id().to_string()});
});
connect(ChatPage::instance(),
&ChatPage::initializeEmptyViews,
this,
&SelfVerificationStatus::invalidate);
}
void

View file

@ -5,11 +5,15 @@
#pragma once
#include <QObject>
#include <QQmlEngine>
class SelfVerificationStatus final : public QObject
{
Q_OBJECT
QML_ELEMENT
QML_SINGLETON
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
Q_PROPERTY(bool hasSSSS READ hasSSSS NOTIFY hasSSSSChanged)

View file

@ -15,6 +15,7 @@ VerificationManager::VerificationManager(TimelineViewManager *o)
: QObject(o)
, rooms_(o->rooms())
{
instance_ = this;
}
static bool

View file

@ -6,6 +6,7 @@
#include <QHash>
#include <QObject>
#include <QQmlEngine>
#include <QSharedPointer>
#include <mtx/events.hpp>
@ -21,8 +22,30 @@ class VerificationManager final : public QObject
{
Q_OBJECT
QML_ELEMENT
QML_SINGLETON
public:
VerificationManager(TimelineViewManager *o = nullptr);
VerificationManager(TimelineViewManager *o);
static VerificationManager *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_;
}
Q_INVOKABLE void removeVerificationFlow(DeviceVerificationFlow *flow);
void verifyUser(QString userid);
@ -45,4 +68,6 @@ private:
QHash<QString, QSharedPointer<DeviceVerificationFlow>> dvList;
bool isInitialSync_ = false;
RoomlistModel *rooms_;
inline static VerificationManager *instance_ = nullptr;
};