Move more stuff to settings
This commit is contained in:
@@ -17,8 +17,6 @@ add_library(neochat STATIC
|
||||
models/roomlistmodel.h
|
||||
models/sortfilterspacelistmodel.cpp
|
||||
models/sortfilterspacelistmodel.h
|
||||
models/accountemoticonmodel.cpp
|
||||
models/accountemoticonmodel.h
|
||||
roommanager.cpp
|
||||
roommanager.h
|
||||
models/userlistmodel.cpp
|
||||
@@ -35,10 +33,6 @@ add_library(neochat STATIC
|
||||
models/spacetreeitem.h
|
||||
models/userdirectorylistmodel.cpp
|
||||
models/userdirectorylistmodel.h
|
||||
models/pushrulemodel.cpp
|
||||
models/pushrulemodel.h
|
||||
models/emoticonfiltermodel.cpp
|
||||
models/emoticonfiltermodel.h
|
||||
notificationsmanager.cpp
|
||||
notificationsmanager.h
|
||||
models/sortfilterroomlistmodel.cpp
|
||||
@@ -47,9 +41,6 @@ add_library(neochat STATIC
|
||||
models/roomtreemodel.h
|
||||
chatdocumenthandler.cpp
|
||||
chatdocumenthandler.h
|
||||
models/devicesmodel.cpp
|
||||
models/devicesmodel.h
|
||||
models/devicesproxymodel.cpp
|
||||
login.cpp
|
||||
login.h
|
||||
models/webshortcutmodel.cpp
|
||||
@@ -72,10 +63,6 @@ add_library(neochat STATIC
|
||||
models/statefiltermodel.h
|
||||
logger.cpp
|
||||
logger.h
|
||||
models/stickermodel.cpp
|
||||
models/stickermodel.h
|
||||
models/imagepacksmodel.cpp
|
||||
models/imagepacksmodel.h
|
||||
models/livelocationsmodel.cpp
|
||||
models/livelocationsmodel.h
|
||||
models/locationsmodel.cpp
|
||||
@@ -111,8 +98,6 @@ add_library(neochat STATIC
|
||||
threepidaddhelper.h
|
||||
identityserverhelper.cpp
|
||||
identityserverhelper.h
|
||||
models/permissionsmodel.cpp
|
||||
models/permissionsmodel.h
|
||||
threepidbindhelper.cpp
|
||||
threepidbindhelper.h
|
||||
enums/roomsortparameter.cpp
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "models/actionsmodel.h"
|
||||
#include "models/messagemodel.h"
|
||||
#include "models/pushrulemodel.h"
|
||||
#include "neochatconfig.h"
|
||||
#include "neochatconnection.h"
|
||||
#include "neochatroom.h"
|
||||
@@ -65,6 +66,11 @@ Controller::Controller(QObject *parent)
|
||||
Q_EMIT globalUrlPreviewDefaultChanged();
|
||||
});
|
||||
|
||||
NeoChatConnection::setKeywordPushRuleDefault(static_cast<PushRuleAction::Action>(NeoChatConfig::keywordPushRuleDefault()));
|
||||
connect(NeoChatConfig::self(), &NeoChatConfig::KeywordPushRuleDefaultChanged, this, [] {
|
||||
NeoChatConnection::setKeywordPushRuleDefault(static_cast<PushRuleAction::Action>(NeoChatConfig::keywordPushRuleDefault()));
|
||||
});
|
||||
|
||||
ActionsModel::setAllowQuickEdit(NeoChatConfig::allowQuickEdit());
|
||||
connect(NeoChatConfig::self(), &NeoChatConfig::AllowQuickEditChanged, this, []() {
|
||||
ActionsModel::setAllowQuickEdit(NeoChatConfig::allowQuickEdit());
|
||||
|
||||
@@ -29,6 +29,8 @@ target_sources(LibNeoChat PRIVATE
|
||||
models/actionsmodel.cpp
|
||||
models/customemojimodel.cpp
|
||||
models/emojimodel.cpp
|
||||
models/imagepacksmodel.cpp
|
||||
models/stickermodel.cpp
|
||||
)
|
||||
|
||||
ecm_add_qml_module(LibNeoChat GENERATE_PLUGIN_SOURCE
|
||||
|
||||
@@ -35,6 +35,7 @@ using namespace Quotient;
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
bool NeoChatConnection::m_globalUrlPreviewDefault = true;
|
||||
PushRuleAction::Action NeoChatConnection::m_defaultAction = PushRuleAction::Unknown;
|
||||
|
||||
NeoChatConnection::NeoChatConnection(QObject *parent)
|
||||
: Connection(parent)
|
||||
@@ -178,6 +179,16 @@ void NeoChatConnection::setGlobalUrlPreviewDefault(bool useByDefault)
|
||||
NeoChatConnection::m_globalUrlPreviewDefault = useByDefault;
|
||||
}
|
||||
|
||||
PushRuleAction::Action NeoChatConnection::keywordPushRuleDefault() const
|
||||
{
|
||||
return m_defaultAction;
|
||||
}
|
||||
|
||||
void NeoChatConnection::setKeywordPushRuleDefault(PushRuleAction::Action defaultAction)
|
||||
{
|
||||
NeoChatConnection::m_defaultAction = defaultAction;
|
||||
}
|
||||
|
||||
void NeoChatConnection::logout(bool serverSideLogout)
|
||||
{
|
||||
SettingsGroup(u"Accounts"_s).remove(userId());
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <Quotient/keyimport.h>
|
||||
|
||||
#include "enums/messagetype.h"
|
||||
#include "enums/pushrule.h"
|
||||
#include "linkpreviewer.h"
|
||||
|
||||
class NeoChatConnection : public Quotient::Connection
|
||||
@@ -181,6 +182,16 @@ public:
|
||||
*/
|
||||
static void setGlobalUrlPreviewDefault(bool useByDefault);
|
||||
|
||||
/**
|
||||
* @brief The current default PushRuleAction for keyword rules.
|
||||
*/
|
||||
PushRuleAction::Action keywordPushRuleDefault() const;
|
||||
|
||||
/**
|
||||
* @brief Set the current default PushRuleAction for keyword rules.
|
||||
*/
|
||||
static void setKeywordPushRuleDefault(PushRuleAction::Action defaultAction);
|
||||
|
||||
bool directChatInvites() const;
|
||||
|
||||
// note: this is intentionally a copied QString because
|
||||
@@ -223,6 +234,7 @@ Q_SIGNALS:
|
||||
|
||||
private:
|
||||
static bool m_globalUrlPreviewDefault;
|
||||
static PushRuleAction::Action m_defaultAction;
|
||||
|
||||
bool m_isOnline = true;
|
||||
void setIsOnline(bool isOnline);
|
||||
|
||||
@@ -46,8 +46,18 @@ ecm_add_qml_module(Settings GENERATE_PLUGIN_SOURCE
|
||||
RoomProfile.qml
|
||||
SOURCES
|
||||
colorschemer.cpp
|
||||
models/accountemoticonmodel.cpp
|
||||
models/devicesmodel.cpp
|
||||
models/devicesproxymodel.cpp
|
||||
models/emoticonfiltermodel.cpp
|
||||
models/permissionsmodel.cpp
|
||||
models/pushrulemodel.cpp
|
||||
)
|
||||
|
||||
|
||||
target_include_directories(Settings PRIVATE ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/models)
|
||||
target_link_libraries(Settings PRIVATE
|
||||
KF6::ColorScheme
|
||||
QuotientQt6
|
||||
LibNeoChat
|
||||
)
|
||||
|
||||
@@ -136,7 +136,8 @@ void DevicesModel::logout(const QString &deviceId, const QString &password)
|
||||
void DevicesModel::setName(const QString &deviceId, const QString &name)
|
||||
{
|
||||
int index;
|
||||
for (index = 0; m_devices[index].deviceId != deviceId; index++);
|
||||
for (index = 0; m_devices[index].deviceId != deviceId; index++)
|
||||
;
|
||||
|
||||
auto job = m_connection->callApi<UpdateDeviceJob>(m_devices[index].deviceId, name);
|
||||
QString oldName = m_devices[index].displayName;
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "emoticonfiltermodel.h"
|
||||
|
||||
#include "accountemoticonmodel.h"
|
||||
#include "stickermodel.h"
|
||||
#include "models/stickermodel.h"
|
||||
|
||||
EmoticonFilterModel::EmoticonFilterModel(QObject *parent)
|
||||
: QSortFilterProxyModel(parent)
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <Quotient/csapi/pushrules.h>
|
||||
#include <Quotient/jobs/basejob.h>
|
||||
|
||||
#include "neochatconfig.h"
|
||||
#include "enums/pushrule.h"
|
||||
|
||||
#include <KLazyLocalizedString>
|
||||
|
||||
@@ -65,7 +65,6 @@ static const QStringList noHighlight = {
|
||||
PushRuleModel::PushRuleModel(QObject *parent)
|
||||
: QAbstractListModel(parent)
|
||||
{
|
||||
m_defaultKeywordAction = static_cast<PushRuleAction::Action>(NeoChatConfig::self()->keywordPushRuleDefault());
|
||||
}
|
||||
|
||||
void PushRuleModel::updateNotificationRules(const QString &type)
|
||||
@@ -172,21 +171,6 @@ PushRuleSection::Section PushRuleModel::getSection(Quotient::PushRule rule)
|
||||
}
|
||||
}
|
||||
|
||||
PushRuleAction::Action PushRuleModel::defaultState() const
|
||||
{
|
||||
return m_defaultKeywordAction;
|
||||
}
|
||||
|
||||
void PushRuleModel::setDefaultState(PushRuleAction::Action defaultState)
|
||||
{
|
||||
if (defaultState == m_defaultKeywordAction) {
|
||||
return;
|
||||
}
|
||||
m_defaultKeywordAction = defaultState;
|
||||
NeoChatConfig::setKeywordPushRuleDefault(m_defaultKeywordAction);
|
||||
Q_EMIT defaultStateChanged();
|
||||
}
|
||||
|
||||
bool PushRuleModel::globalNotificationsEnabled() const
|
||||
{
|
||||
auto masterIndex = getRuleIndex(u".m.rule.master"_s);
|
||||
@@ -292,8 +276,12 @@ void PushRuleModel::setPushRuleAction(const QString &id, PushRuleAction::Action
|
||||
|
||||
void PushRuleModel::addKeyword(const QString &keyword, const QString &roomId)
|
||||
{
|
||||
if (!m_connection) {
|
||||
return;
|
||||
}
|
||||
|
||||
PushRuleKind::Kind kind = PushRuleKind::Content;
|
||||
const QList<QVariant> actions = actionToVariant(m_defaultKeywordAction);
|
||||
const QList<QVariant> actions = actionToVariant(m_connection->keywordPushRuleDefault());
|
||||
QList<Quotient::PushCondition> pushConditions;
|
||||
if (!roomId.isEmpty()) {
|
||||
kind = PushRuleKind::Override;
|
||||
@@ -23,11 +23,6 @@ class PushRuleModel : public QAbstractListModel
|
||||
Q_OBJECT
|
||||
QML_ELEMENT
|
||||
|
||||
/**
|
||||
* @brief The default state for any newly created keyword rule.
|
||||
*/
|
||||
Q_PROPERTY(PushRuleAction::Action defaultState READ defaultState WRITE setDefaultState NOTIFY defaultStateChanged)
|
||||
|
||||
/**
|
||||
* @brief The global notification state.
|
||||
*
|
||||
@@ -72,9 +67,6 @@ public:
|
||||
|
||||
explicit PushRuleModel(QObject *parent = nullptr);
|
||||
|
||||
[[nodiscard]] PushRuleAction::Action defaultState() const;
|
||||
void setDefaultState(PushRuleAction::Action defaultState);
|
||||
|
||||
[[nodiscard]] bool globalNotificationsEnabled() const;
|
||||
void setGlobalNotificationsEnabled(bool enabled);
|
||||
|
||||
@@ -117,7 +109,6 @@ public:
|
||||
NeoChatConnection *connection() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void defaultStateChanged();
|
||||
void globalNotificationsEnabledChanged();
|
||||
void globalNotificationsSetChanged();
|
||||
void connectionChanged();
|
||||
@@ -126,7 +117,6 @@ private Q_SLOTS:
|
||||
void updateNotificationRules(const QString &type);
|
||||
|
||||
private:
|
||||
PushRuleAction::Action m_defaultKeywordAction;
|
||||
QList<Rule> m_rules;
|
||||
QPointer<NeoChatConnection> m_connection;
|
||||
|
||||
Reference in New Issue
Block a user