From 45391c97ff67794dd63a9ec9c0f5300b31a7dcfe Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sat, 16 Apr 2022 16:19:57 +0200 Subject: [PATCH] Remove unnecessary meta type registrations --- src/Cache.cpp | 14 ---------- src/ChatPage.cpp | 12 --------- src/LoginPage.cpp | 7 ----- src/MainWindow.cpp | 49 +++++++++++----------------------- src/MatrixClient.cpp | 42 ----------------------------- src/MatrixClient.h | 4 --- src/SingleImagePackModel.cpp | 4 --- src/emoji/Provider.h | 2 -- src/main.cpp | 2 -- src/timeline/EventStore.cpp | 5 ---- src/timeline/RoomlistModel.cpp | 2 -- src/timeline/TimelineModel.cpp | 2 -- src/ui/Theme.cpp | 3 --- src/voip/CallManager.cpp | 8 ------ 14 files changed, 15 insertions(+), 141 deletions(-) diff --git a/src/Cache.cpp b/src/Cache.cpp index 19775f04..bbf10e11 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp @@ -87,12 +87,6 @@ constexpr auto MEGOLM_SESSIONS_DATA_DB("megolm_sessions_data_db"); using CachedReceipts = std::multimap>; using Receipts = std::map>; -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 instance_ = nullptr; } @@ -4862,14 +4856,6 @@ namespace cache { void init(const QString &user_id) { - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType>(); - qRegisterMetaType>(); - qRegisterMetaType>(); - qRegisterMetaType(); - instance_ = std::make_unique(user_id); } diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp index ccaf2926..bf471fb2 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp @@ -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) -Q_DECLARE_METATYPE(std::optional) -Q_DECLARE_METATYPE(mtx::presence::PresenceState) -Q_DECLARE_METATYPE(mtx::secret_storage::AesHmacSha2KeyDescription) -Q_DECLARE_METATYPE(SecretsToDecrypt) - ChatPage::ChatPage(QSharedPointer userSettings, QObject *parent) : QObject(parent) , isConnected_(true) @@ -54,12 +48,6 @@ ChatPage::ChatPage(QSharedPointer userSettings, QObject *parent) instance_ = this; - qRegisterMetaType>(); - qRegisterMetaType>(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - view_manager_ = new TimelineViewManager(callManager_, this); connect(this, diff --git a/src/LoginPage.cpp b/src/LoginPage.cpp index b34e9806..238592e5 100644 --- a/src/LoginPage.cpp +++ b/src/LoginPage.cpp @@ -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"); - [[maybe_unused]] static auto ignored2 = qRegisterMetaType(); - connect(this, &LoginPage::versionOkCb, this, &LoginPage::versionOk, Qt::QueuedConnection); connect(this, &LoginPage::versionErrorCb, this, &LoginPage::versionError, Qt::QueuedConnection); connect( diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 0ccbc5c8..e42ccc5c 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -4,6 +4,8 @@ // // SPDX-License-Identifier: GPL-3.0-or-later +#include "MainWindow.h" + #include #include @@ -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) -Q_DECLARE_METATYPE(std::vector) - 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 diff --git a/src/MatrixClient.cpp b/src/MatrixClient.cpp index c565176e..39d1575c 100644 --- a/src/MatrixClient.cpp +++ b/src/MatrixClient.cpp @@ -8,28 +8,6 @@ #include #include -#include -#include -#include - -#include "nlohmann/json.hpp" -#include - -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) -Q_DECLARE_METATYPE(std::vector) -Q_DECLARE_METATYPE(std::set) - namespace http { mtx::http::Client * @@ -44,24 +22,4 @@ is_logged_in() { return !client()->access_token().empty(); } - -void -init() -{ - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); - // qRegisterMetaType(); - qRegisterMetaType>(); - qRegisterMetaType>(); - qRegisterMetaType>("std::map"); - qRegisterMetaType>(); -} - } // namespace http diff --git a/src/MatrixClient.h b/src/MatrixClient.h index f57ba7af..3e514573 100644 --- a/src/MatrixClient.h +++ b/src/MatrixClient.h @@ -17,10 +17,6 @@ client(); bool is_logged_in(); - -//! Initialize the http module -void -init(); } template<> diff --git a/src/SingleImagePackModel.cpp b/src/SingleImagePackModel.cpp index 5fb0fa92..66c3948f 100644 --- a/src/SingleImagePackModel.cpp +++ b/src/SingleImagePackModel.cpp @@ -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(); - if (!pack.pack) pack.pack = mtx::events::msc2545::ImagePack::PackDescription{}; diff --git a/src/emoji/Provider.h b/src/emoji/Provider.h index 8b0b0080..b8184b5f 100644 --- a/src/emoji/Provider.h +++ b/src/emoji/Provider.h @@ -52,6 +52,4 @@ public: // all emoji for QML purposes static const QVector emoji; }; - } // namespace emoji -Q_DECLARE_METATYPE(emoji::Emoji) diff --git a/src/main.cpp b/src/main.cpp index afb00229..7f44291f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -231,8 +231,6 @@ main(int argc, char *argv[]) app.setDesktopFileName(QStringLiteral("nheko")); #endif - http::init(); - createStandardDirectory(QStandardPaths::CacheLocation); createStandardDirectory(QStandardPaths::AppDataLocation); diff --git a/src/timeline/EventStore.cpp b/src/timeline/EventStore.cpp index 79bd028a..2f033929 100644 --- a/src/timeline/EventStore.cpp +++ b/src/timeline/EventStore.cpp @@ -19,8 +19,6 @@ #include "UserSettingsPage.h" #include "Utils.h" -Q_DECLARE_METATYPE(Reaction) - QCache EventStore::decryptedEvents_{1000}; QCache EventStore::events_by_id_{ 1000}; @@ -29,9 +27,6 @@ QCache EventStore:: EventStore::EventStore(std::string room_id, QObject *) : room_id_(std::move(room_id)) { - static auto reactionType = qRegisterMetaType(); - (void)reactionType; - auto range = cache::client()->getTimelineRange(room_id_); if (range) { diff --git a/src/timeline/RoomlistModel.cpp b/src/timeline/RoomlistModel.cpp index ca905829..a74667a8 100644 --- a/src/timeline/RoomlistModel.cpp +++ b/src/timeline/RoomlistModel.cpp @@ -23,8 +23,6 @@ RoomlistModel::RoomlistModel(TimelineViewManager *parent) : QAbstractListModel(parent) , manager(parent) { - [[maybe_unused]] static auto id = qRegisterMetaType(); - connect(ChatPage::instance(), &ChatPage::decryptSidebarChanged, this, [this]() { auto decrypt = ChatPage::instance()->userSettings()->decryptSidebar(); QHash>::iterator i; diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index e7212f31..dec33f19 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -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) diff --git a/src/ui/Theme.cpp b/src/ui/Theme.cpp index 2f95b274..6c2a6261 100644 --- a/src/ui/Theme.cpp +++ b/src/ui/Theme.cpp @@ -5,12 +5,9 @@ #include "Theme.h" -Q_DECLARE_METATYPE(Theme) - QPalette Theme::paletteFromTheme(QStringView theme) { - [[maybe_unused]] static auto meta = qRegisterMetaType("Theme"); static QPalette original; if (theme == u"light") { static QPalette lightActive = [] { diff --git a/src/voip/CallManager.cpp b/src/voip/CallManager.cpp index 00a2b214..f5503bb8 100644 --- a/src/voip/CallManager.cpp +++ b/src/voip/CallManager.cpp @@ -35,10 +35,6 @@ extern "C" } #endif -Q_DECLARE_METATYPE(std::vector) -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>(); - qRegisterMetaType(); - qRegisterMetaType(); - connect( &session_, &WebRTCSession::offerCreated,