Rework NeoChatConnection to remove the dependency on NeoChatConfig

Title
This commit is contained in:
James Graham
2025-04-05 07:53:26 +00:00
parent 73623ec41a
commit d9b8b1c8ef
5 changed files with 40 additions and 32 deletions

View File

@@ -4,6 +4,7 @@
#include "controller.h"
#include <Quotient/connection.h>
#include <qt6keychain/keychain.h>
#include <KLocalizedString>
@@ -50,6 +51,17 @@ Controller::Controller(QObject *parent)
{
Connection::setRoomType<NeoChatRoom>();
Connection::setDirectChatEncryptionDefault(NeoChatConfig::preferUsingEncryption());
connect(NeoChatConfig::self(), &NeoChatConfig::PreferUsingEncryptionChanged, this, [] {
Connection::setDirectChatEncryptionDefault(NeoChatConfig::preferUsingEncryption());
});
NeoChatConnection::setGlobalUrlPreviewDefault(NeoChatConfig::showLinkPreview());
connect(NeoChatConfig::self(), &NeoChatConfig::ShowLinkPreviewChanged, this, [this] {
NeoChatConnection::setGlobalUrlPreviewDefault(NeoChatConfig::showLinkPreview());
Q_EMIT globalUrlPreviewDefaultChanged();
});
ProxyController::instance().setApplicationProxy();
#ifndef Q_OS_ANDROID
@@ -168,6 +180,7 @@ void Controller::addConnection(NeoChatConnection *c)
connect(c, &NeoChatConnection::syncDone, this, [this, c]() {
m_notificationsManager.handleNotifications(c);
});
connect(this, &Controller::globalUrlPreviewDefaultChanged, c, &NeoChatConnection::globalUrlPreviewEnabledChanged);
c->sync();