Remove unnecessary meta type registrations

qt6
Nicolas Werner 3 years ago
parent 76c5d6d2ca
commit 45391c97ff
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
  1. 14
      src/Cache.cpp
  2. 12
      src/ChatPage.cpp
  3. 7
      src/LoginPage.cpp
  4. 49
      src/MainWindow.cpp
  5. 42
      src/MatrixClient.cpp
  6. 4
      src/MatrixClient.h
  7. 4
      src/SingleImagePackModel.cpp
  8. 2
      src/emoji/Provider.h
  9. 2
      src/main.cpp
  10. 5
      src/timeline/EventStore.cpp
  11. 2
      src/timeline/RoomlistModel.cpp
  12. 2
      src/timeline/TimelineModel.cpp
  13. 3
      src/ui/Theme.cpp
  14. 8
      src/voip/CallManager.cpp

@ -87,12 +87,6 @@ constexpr auto MEGOLM_SESSIONS_DATA_DB("megolm_sessions_data_db");
using CachedReceipts = std::multimap<uint64_t, std::string, std::greater<uint64_t>>;
using Receipts = std::map<std::string, std::map<std::string, uint64_t>>;
Q_DECLARE_METATYPE(RoomMember)
Q_DECLARE_METATYPE(mtx::responses::Timeline)
Q_DECLARE_METATYPE(RoomSearchResult)
Q_DECLARE_METATYPE(RoomInfo)
Q_DECLARE_METATYPE(mtx::responses::QueryKeys)
namespace {
std::unique_ptr<Cache> instance_ = nullptr;
}
@ -4862,14 +4856,6 @@ namespace cache {
void
init(const QString &user_id)
{
qRegisterMetaType<RoomMember>();
qRegisterMetaType<RoomSearchResult>();
qRegisterMetaType<RoomInfo>();
qRegisterMetaType<QMap<QString, RoomInfo>>();
qRegisterMetaType<std::map<QString, RoomInfo>>();
qRegisterMetaType<std::map<QString, mtx::responses::Timeline>>();
qRegisterMetaType<mtx::responses::QueryKeys>();
instance_ = std::make_unique<Cache>(user_id);
}

@ -37,12 +37,6 @@ constexpr int CHECK_CONNECTIVITY_INTERVAL = 15'000;
constexpr int RETRY_TIMEOUT = 5'000;
constexpr size_t MAX_ONETIME_KEYS = 50;
Q_DECLARE_METATYPE(std::optional<mtx::crypto::EncryptedFile>)
Q_DECLARE_METATYPE(std::optional<RelatedInfo>)
Q_DECLARE_METATYPE(mtx::presence::PresenceState)
Q_DECLARE_METATYPE(mtx::secret_storage::AesHmacSha2KeyDescription)
Q_DECLARE_METATYPE(SecretsToDecrypt)
ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QObject *parent)
: QObject(parent)
, isConnected_(true)
@ -54,12 +48,6 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QObject *parent)
instance_ = this;
qRegisterMetaType<std::optional<mtx::crypto::EncryptedFile>>();
qRegisterMetaType<std::optional<RelatedInfo>>();
qRegisterMetaType<mtx::presence::PresenceState>();
qRegisterMetaType<mtx::secret_storage::AesHmacSha2KeyDescription>();
qRegisterMetaType<SecretsToDecrypt>();
view_manager_ = new TimelineViewManager(callManager_, this);
connect(this,

@ -18,19 +18,12 @@
#include "SSOHandler.h"
#include "UserSettingsPage.h"
Q_DECLARE_METATYPE(LoginPage::LoginMethod)
Q_DECLARE_METATYPE(SSOProvider)
using namespace mtx::identifiers;
LoginPage::LoginPage(QObject *parent)
: QObject(parent)
, inferredServerAddress_()
{
[[maybe_unused]] static auto ignored =
qRegisterMetaType<LoginPage::LoginMethod>("LoginPage::LoginMethod");
[[maybe_unused]] static auto ignored2 = qRegisterMetaType<SSOProvider>();
connect(this, &LoginPage::versionOkCb, this, &LoginPage::versionOk, Qt::QueuedConnection);
connect(this, &LoginPage::versionErrorCb, this, &LoginPage::versionError, Qt::QueuedConnection);
connect(

@ -4,6 +4,8 @@
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "MainWindow.h"
#include <QApplication>
#include <QMessageBox>
@ -14,45 +16,24 @@
#include "Cache.h"
#include "Cache_p.h"
#include "ChatPage.h"
#include "Clipboard.h"
#include "ColorImageProvider.h"
#include "CombinedImagePackModel.h"
#include "CompletionProxyModel.h"
#include "Config.h"
#include "EventAccessors.h"
#include "ImagePackListModel.h"
#include "InviteesModel.h"
#include "JdenticonProvider.h"
#include "Logging.h"
#include "MainWindow.h"
#include "MatrixClient.h"
#include "MemberList.h"
#include "MxcImageProvider.h"
#include "ReadReceiptsModel.h"
#include "RoomDirectoryModel.h"
#include "RoomsModel.h"
#include "SingleImagePackModel.h"
#include "TrayIcon.h"
#include "UserSettingsPage.h"
#include "UsersModel.h"
#include "Utils.h"
#include "emoji/EmojiModel.h"
#include "emoji/Provider.h"
#include "encryption/DeviceVerificationFlow.h"
#include "encryption/SelfVerificationStatus.h"
#include "timeline/TimelineViewManager.h"
#include "ui/NhekoGlobalObject.h"
#include "ui/UIA.h"
#include "voip/WebRTCSession.h"
#include "ui/Theme.h"
#ifdef NHEKO_DBUS_SYS
#include "dbus/NhekoDBusApi.h"
#endif
Q_DECLARE_METATYPE(mtx::events::collections::TimelineEvents)
Q_DECLARE_METATYPE(std::vector<DeviceInfo>)
Q_DECLARE_METATYPE(std::vector<mtx::responses::PublicRoomsChunk>)
MainWindow *MainWindow::instance_ = nullptr;
MainWindow::MainWindow(QWindow *parent)
@ -92,6 +73,18 @@ MainWindow::MainWindow(QWindow *parent)
trayIcon_->setVisible(userSettings_->tray());
#ifdef NHEKO_DBUS_SYS
if (UserSettings::instance()->exposeDBusApi()) {
if (QDBusConnection::sessionBus().isConnected() &&
QDBusConnection::sessionBus().registerService(NHEKO_DBUS_SERVICE_NAME)) {
nheko::dbus::init();
nhlog::ui()->info("Initialized D-Bus");
dbusAvailable_ = true;
} else
nhlog::ui()->warn("Could not connect to D-Bus!");
}
#endif
// load cache on event loop
QTimer::singleShot(0, this, [this] {
if (hasActiveUser()) {
@ -129,18 +122,6 @@ MainWindow::registerQmlTypes()
engine()->addImageProvider(QStringLiteral("jdenticon"), new JdenticonProvider());
QObject::connect(engine(), &QQmlEngine::quit, &QGuiApplication::quit);
#ifdef NHEKO_DBUS_SYS
if (UserSettings::instance()->exposeDBusApi()) {
if (QDBusConnection::sessionBus().isConnected() &&
QDBusConnection::sessionBus().registerService(NHEKO_DBUS_SERVICE_NAME)) {
nheko::dbus::init();
nhlog::ui()->info("Initialized D-Bus");
dbusAvailable_ = true;
} else
nhlog::ui()->warn("Could not connect to D-Bus!");
}
#endif
}
void

@ -8,28 +8,6 @@
#include <memory>
#include <set>
#include <QMetaType>
#include <QObject>
#include <QString>
#include "nlohmann/json.hpp"
#include <mtx/responses.hpp>
Q_DECLARE_METATYPE(mtx::responses::Login)
Q_DECLARE_METATYPE(mtx::responses::Messages)
Q_DECLARE_METATYPE(mtx::responses::Notifications)
Q_DECLARE_METATYPE(mtx::responses::Rooms)
Q_DECLARE_METATYPE(mtx::responses::Sync)
Q_DECLARE_METATYPE(mtx::responses::StateEvents)
Q_DECLARE_METATYPE(mtx::responses::JoinedGroups)
Q_DECLARE_METATYPE(mtx::responses::GroupProfile)
// Q_DECLARE_METATYPE(nlohmann::json)
Q_DECLARE_METATYPE(std::string)
Q_DECLARE_METATYPE(std::vector<std::string>)
Q_DECLARE_METATYPE(std::vector<QString>)
Q_DECLARE_METATYPE(std::set<QString>)
namespace http {
mtx::http::Client *
@ -44,24 +22,4 @@ is_logged_in()
{
return !client()->access_token().empty();
}
void
init()
{
qRegisterMetaType<mtx::responses::Login>();
qRegisterMetaType<mtx::responses::Messages>();
qRegisterMetaType<mtx::responses::Notifications>();
qRegisterMetaType<mtx::responses::Rooms>();
qRegisterMetaType<mtx::responses::Sync>();
qRegisterMetaType<mtx::responses::StateEvents>();
qRegisterMetaType<mtx::responses::JoinedGroups>();
qRegisterMetaType<mtx::responses::GroupProfile>();
qRegisterMetaType<std::string>();
// qRegisterMetaType<nlohmann::json>();
qRegisterMetaType<std::vector<std::string>>();
qRegisterMetaType<std::vector<QString>>();
qRegisterMetaType<std::map<QString, bool>>("std::map<QString, bool>");
qRegisterMetaType<std::set<QString>>();
}
} // namespace http

@ -17,10 +17,6 @@ client();
bool
is_logged_in();
//! Initialize the http module
void
init();
}
template<>

@ -16,8 +16,6 @@
#include "timeline/Permissions.h"
#include "timeline/TimelineModel.h"
Q_DECLARE_METATYPE(mtx::common::ImageInfo)
SingleImagePackModel::SingleImagePackModel(ImagePackInfo pack_, QObject *parent)
: QAbstractListModel(parent)
, roomid_(std::move(pack_.source_room))
@ -25,8 +23,6 @@ SingleImagePackModel::SingleImagePackModel(ImagePackInfo pack_, QObject *parent)
, old_statekey_(statekey_)
, pack(std::move(pack_.pack))
{
[[maybe_unused]] static auto imageInfoType = qRegisterMetaType<mtx::common::ImageInfo>();
if (!pack.pack)
pack.pack = mtx::events::msc2545::ImagePack::PackDescription{};

@ -52,6 +52,4 @@ public:
// all emoji for QML purposes
static const QVector<Emoji> emoji;
};
} // namespace emoji
Q_DECLARE_METATYPE(emoji::Emoji)

@ -231,8 +231,6 @@ main(int argc, char *argv[])
app.setDesktopFileName(QStringLiteral("nheko"));
#endif
http::init();
createStandardDirectory(QStandardPaths::CacheLocation);
createStandardDirectory(QStandardPaths::AppDataLocation);

@ -19,8 +19,6 @@
#include "UserSettingsPage.h"
#include "Utils.h"
Q_DECLARE_METATYPE(Reaction)
QCache<EventStore::IdIndex, olm::DecryptionResult> EventStore::decryptedEvents_{1000};
QCache<EventStore::IdIndex, mtx::events::collections::TimelineEvents> EventStore::events_by_id_{
1000};
@ -29,9 +27,6 @@ QCache<EventStore::Index, mtx::events::collections::TimelineEvents> EventStore::
EventStore::EventStore(std::string room_id, QObject *)
: room_id_(std::move(room_id))
{
static auto reactionType = qRegisterMetaType<Reaction>();
(void)reactionType;
auto range = cache::client()->getTimelineRange(room_id_);
if (range) {

@ -23,8 +23,6 @@ RoomlistModel::RoomlistModel(TimelineViewManager *parent)
: QAbstractListModel(parent)
, manager(parent)
{
[[maybe_unused]] static auto id = qRegisterMetaType<RoomPreview>();
connect(ChatPage::instance(), &ChatPage::decryptSidebarChanged, this, [this]() {
auto decrypt = ChatPage::instance()->userSettings()->decryptSidebar();
QHash<QString, QSharedPointer<TimelineModel>>::iterator i;

@ -34,8 +34,6 @@
#include "Utils.h"
#include "encryption/Olm.h"
Q_DECLARE_METATYPE(QModelIndex)
namespace std {
inline uint // clazy:exclude=qhash-namespace
qHash(const std::string &key, uint seed = 0)

@ -5,12 +5,9 @@
#include "Theme.h"
Q_DECLARE_METATYPE(Theme)
QPalette
Theme::paletteFromTheme(QStringView theme)
{
[[maybe_unused]] static auto meta = qRegisterMetaType<Theme>("Theme");
static QPalette original;
if (theme == u"light") {
static QPalette lightActive = [] {

@ -35,10 +35,6 @@ extern "C"
}
#endif
Q_DECLARE_METATYPE(std::vector<mtx::events::msg::CallCandidates::Candidate>)
Q_DECLARE_METATYPE(mtx::events::msg::CallCandidates::Candidate)
Q_DECLARE_METATYPE(mtx::responses::TurnServer)
using namespace mtx::events;
using namespace mtx::events::msg;
@ -75,10 +71,6 @@ CallManager::CallManager(QObject *parent)
, session_(WebRTCSession::instance())
, turnServerTimer_(this)
{
qRegisterMetaType<std::vector<mtx::events::msg::CallCandidates::Candidate>>();
qRegisterMetaType<mtx::events::msg::CallCandidates::Candidate>();
qRegisterMetaType<mtx::responses::TurnServer>();
connect(
&session_,
&WebRTCSession::offerCreated,

Loading…
Cancel
Save