Re-run clang-format
This commit is contained in:
@@ -12,8 +12,8 @@
|
||||
#include <QStringBuilder>
|
||||
|
||||
#include "controller.h"
|
||||
#include "roommanager.h"
|
||||
#include "customemojimodel.h"
|
||||
#include "roommanager.h"
|
||||
|
||||
ActionsHandler::ActionsHandler(QObject *parent)
|
||||
: QObject(parent)
|
||||
@@ -62,7 +62,6 @@ void ActionsHandler::setConnection(Connection *connection)
|
||||
|
||||
void ActionsHandler::postEdit(const QString &text)
|
||||
{
|
||||
|
||||
const auto localId = Controller::instance().activeConnection()->userId();
|
||||
for (auto it = m_room->messageEvents().crbegin(); it != m_room->messageEvents().crend(); ++it) {
|
||||
const auto &evt = **it;
|
||||
@@ -104,12 +103,12 @@ void ActionsHandler::postMessage(const QString &text,
|
||||
const QString &replyEventId,
|
||||
const QString &editEventId,
|
||||
const QVariantMap &usernames,
|
||||
CustomEmojiModel* cem)
|
||||
CustomEmojiModel *cem)
|
||||
{
|
||||
QString rawText = text;
|
||||
QString cleanedText = text;
|
||||
|
||||
auto preprocess = [cem](const QString& it) -> QString {
|
||||
auto preprocess = [cem](const QString &it) -> QString {
|
||||
if (cem == nullptr) {
|
||||
return it;
|
||||
}
|
||||
@@ -135,8 +134,8 @@ void ActionsHandler::postMessage(const QString &text,
|
||||
static const QString lennyPrefix = QStringLiteral("/lenny");
|
||||
static const QString tableflipPrefix = QStringLiteral("/tableflip");
|
||||
static const QString unflipPrefix = QStringLiteral("/unflip");
|
||||
//static const QString plainPrefix = QStringLiteral("/plain "); // TODO
|
||||
//static const QString htmlPrefix = QStringLiteral("/html "); // TODO
|
||||
// static const QString plainPrefix = QStringLiteral("/plain "); // TODO
|
||||
// static const QString htmlPrefix = QStringLiteral("/html "); // TODO
|
||||
static const QString rainbowPrefix = QStringLiteral("/rainbow ");
|
||||
static const QString rainbowmePrefix = QStringLiteral("/rainbowme ");
|
||||
static const QString spoilerPrefix = QStringLiteral("/spoiler ");
|
||||
@@ -144,12 +143,12 @@ void ActionsHandler::postMessage(const QString &text,
|
||||
static const QString noticePrefix = QStringLiteral("/notice ");
|
||||
|
||||
// Actions commands
|
||||
//static const QString ddgPrefix = QStringLiteral("/ddg "); // TODO
|
||||
//static const QString nickPrefix = QStringLiteral("/nick "); // TODO
|
||||
//static const QString meroomnickPrefix = QStringLiteral("/myroomnick "); // TODO
|
||||
//static const QString roomavatarPrefix = QStringLiteral("/roomavatar "); // TODO
|
||||
//static const QString myroomavatarPrefix = QStringLiteral("/myroomavatar "); // TODO
|
||||
//static const QString myavatarPrefix = QStringLiteral("/myavatar "); // TODO
|
||||
// static const QString ddgPrefix = QStringLiteral("/ddg "); // TODO
|
||||
// static const QString nickPrefix = QStringLiteral("/nick "); // TODO
|
||||
// static const QString meroomnickPrefix = QStringLiteral("/myroomnick "); // TODO
|
||||
// static const QString roomavatarPrefix = QStringLiteral("/roomavatar "); // TODO
|
||||
// static const QString myroomavatarPrefix = QStringLiteral("/myroomavatar "); // TODO
|
||||
// static const QString myavatarPrefix = QStringLiteral("/myavatar "); // TODO
|
||||
static const QString invitePrefix = QStringLiteral("/invite ");
|
||||
static const QString joinPrefix = QStringLiteral("/join ");
|
||||
static const QString joinShortPrefix = QStringLiteral("/j ");
|
||||
@@ -157,8 +156,8 @@ void ActionsHandler::postMessage(const QString &text,
|
||||
static const QString leavePrefix = QStringLiteral("/leave");
|
||||
static const QString ignorePrefix = QStringLiteral("/ignore ");
|
||||
static const QString unignorePrefix = QStringLiteral("/unignore ");
|
||||
//static const QString queryPrefix = QStringLiteral("/query "); // TODO
|
||||
//static const QString msgPrefix = QStringLiteral("/msg "); // TODO
|
||||
// static const QString queryPrefix = QStringLiteral("/query "); // TODO
|
||||
// static const QString msgPrefix = QStringLiteral("/msg "); // TODO
|
||||
static const QString reactPrefix = QStringLiteral("/react ");
|
||||
|
||||
// Admin commands
|
||||
|
||||
@@ -18,7 +18,6 @@ class ActionsHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
/// \brief The connection that will handle sending the message.
|
||||
Q_PROPERTY(Connection *connection READ connection WRITE setConnection NOTIFY connectionChanged)
|
||||
|
||||
@@ -35,8 +34,6 @@ public:
|
||||
explicit ActionsHandler(QObject *parent = nullptr);
|
||||
~ActionsHandler();
|
||||
|
||||
|
||||
|
||||
[[nodiscard]] Connection *connection() const;
|
||||
void setConnection(Connection *connection);
|
||||
|
||||
@@ -57,8 +54,12 @@ public Q_SLOTS:
|
||||
/// \brief Post a message.
|
||||
///
|
||||
/// This also interprets commands if any.
|
||||
void
|
||||
postMessage(const QString &text, const QString &attachementPath, const QString &replyEventId, const QString &editEventId, const QVariantMap &usernames, CustomEmojiModel* cem);
|
||||
void postMessage(const QString &text,
|
||||
const QString &attachementPath,
|
||||
const QString &replyEventId,
|
||||
const QString &editEventId,
|
||||
const QVariantMap &usernames,
|
||||
CustomEmojiModel *cem);
|
||||
|
||||
/// \brief Send edit instructions (.e.g s/hallo/hello/)
|
||||
///
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "colorschemer.h"
|
||||
|
||||
ColorSchemer::ColorSchemer(QObject* parent)
|
||||
ColorSchemer::ColorSchemer(QObject *parent)
|
||||
: QObject(parent)
|
||||
, c(new KColorSchemeManager(this))
|
||||
{
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QIdentityProxyModel>
|
||||
#include <QObject>
|
||||
|
||||
class QAbstractItemModel;
|
||||
class KColorSchemeManager;
|
||||
@@ -14,16 +14,15 @@ class ColorSchemer : public QObject
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QAbstractItemModel *model READ model CONSTANT)
|
||||
public:
|
||||
ColorSchemer(QObject* parent = nullptr);
|
||||
ColorSchemer(QObject *parent = nullptr);
|
||||
~ColorSchemer();
|
||||
|
||||
QAbstractItemModel* model() const;
|
||||
QAbstractItemModel *model() const;
|
||||
Q_INVOKABLE void apply(int idx);
|
||||
Q_INVOKABLE void apply(const QString &name);
|
||||
Q_INVOKABLE int indexForScheme(const QString &name) const;
|
||||
Q_INVOKABLE QString nameForIndex(int index) const;
|
||||
|
||||
private:
|
||||
KColorSchemeManager* c;
|
||||
KColorSchemeManager *c;
|
||||
};
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "actionshandler.h"
|
||||
#include "commandmodel.h"
|
||||
|
||||
|
||||
QVariantList CommandModel::filterModel(const QString &filter)
|
||||
{
|
||||
QVariantList result;
|
||||
@@ -24,85 +23,47 @@ QVariantList CommandModel::filterModel(const QString &filter)
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
QVariantList CommandModel::commands()
|
||||
{
|
||||
QVariantList commands;
|
||||
|
||||
// Messages commands
|
||||
commands.append(QVariant::fromValue(Command{
|
||||
QStringLiteral("/me "),
|
||||
QStringLiteral("<message>"),
|
||||
i18n("Displays action")}));
|
||||
commands.append(QVariant::fromValue(Command{QStringLiteral("/me "), QStringLiteral("<message>"), i18n("Displays action")}));
|
||||
|
||||
commands.append(QVariant::fromValue(Command{
|
||||
QStringLiteral("/shrug "),
|
||||
QStringLiteral("<message>"),
|
||||
i18n("Prepends ¯\\_(ツ)_/¯ to a plain-text message")}));
|
||||
commands.append(QVariant::fromValue(Command{QStringLiteral("/shrug "), QStringLiteral("<message>"), i18n("Prepends ¯\\_(ツ)_/¯ to a plain-text message")}));
|
||||
|
||||
commands.append(QVariant::fromValue(Command{
|
||||
QStringLiteral("/lenny "),
|
||||
QStringLiteral("<message>"),
|
||||
i18n("Prepends ( ͡° ͜ʖ ͡°) to a plain-text message")}));
|
||||
commands.append(QVariant::fromValue(Command{QStringLiteral("/lenny "), QStringLiteral("<message>"), i18n("Prepends ( ͡° ͜ʖ ͡°) to a plain-text message")}));
|
||||
|
||||
commands.append(QVariant::fromValue(Command{
|
||||
QStringLiteral("/tableflip "),
|
||||
QStringLiteral("<message>"),
|
||||
i18n("Prepends (╯°□°)╯︵ ┻━┻ to a plain-text message")}));
|
||||
commands.append(
|
||||
QVariant::fromValue(Command{QStringLiteral("/tableflip "), QStringLiteral("<message>"), i18n("Prepends (╯°□°)╯︵ ┻━┻ to a plain-text message")}));
|
||||
|
||||
commands.append(QVariant::fromValue(Command{
|
||||
QStringLiteral("/unflip "),
|
||||
QStringLiteral("<message>"),
|
||||
i18n("Prepends ┬──┬ ノ( ゜-゜ノ) to a plain-text message")}));
|
||||
commands.append(
|
||||
QVariant::fromValue(Command{QStringLiteral("/unflip "), QStringLiteral("<message>"), i18n("Prepends ┬──┬ ノ( ゜-゜ノ) to a plain-text message")}));
|
||||
|
||||
commands.append(QVariant::fromValue(Command{
|
||||
QStringLiteral("/plain "),
|
||||
QStringLiteral("<message>"),
|
||||
i18n("Sends a message as plain text, without interpreting it as markdown")}));
|
||||
commands.append(QVariant::fromValue(
|
||||
Command{QStringLiteral("/plain "), QStringLiteral("<message>"), i18n("Sends a message as plain text, without interpreting it as markdown")}));
|
||||
|
||||
commands.append(QVariant::fromValue(Command{
|
||||
QStringLiteral("/html "),
|
||||
QStringLiteral("<message>"),
|
||||
i18n("Sends a message as html, without interpreting it as markdown")}));
|
||||
commands.append(QVariant::fromValue(
|
||||
Command{QStringLiteral("/html "), QStringLiteral("<message>"), i18n("Sends a message as html, without interpreting it as markdown")}));
|
||||
|
||||
commands.append(QVariant::fromValue(Command{
|
||||
QStringLiteral("/rainbow "),
|
||||
QStringLiteral("<message>"),
|
||||
i18n("Sends the given message coloured as a rainbow")}));
|
||||
commands.append(
|
||||
QVariant::fromValue(Command{QStringLiteral("/rainbow "), QStringLiteral("<message>"), i18n("Sends the given message coloured as a rainbow")}));
|
||||
|
||||
commands.append(QVariant::fromValue(Command{
|
||||
QStringLiteral("/rainbowme "),
|
||||
QStringLiteral("<message>"),
|
||||
i18n("Sends the given emote coloured as a rainbow")}));
|
||||
|
||||
commands.append(QVariant::fromValue(Command{
|
||||
QStringLiteral("/spoiler "),
|
||||
QStringLiteral("<message>"),
|
||||
i18n("Sends the given message as a spoiler")}));
|
||||
commands.append(
|
||||
QVariant::fromValue(Command{QStringLiteral("/rainbowme "), QStringLiteral("<message>"), i18n("Sends the given emote coloured as a rainbow")}));
|
||||
|
||||
commands.append(QVariant::fromValue(Command{QStringLiteral("/spoiler "), QStringLiteral("<message>"), i18n("Sends the given message as a spoiler")}));
|
||||
|
||||
// Actions commands
|
||||
commands.append(QVariant::fromValue(Command{
|
||||
QStringLiteral("/join "), QStringLiteral("<room-address>"),
|
||||
i18n("Joins room with given address")}));
|
||||
commands.append(QVariant::fromValue(Command{QStringLiteral("/join "), QStringLiteral("<room-address>"), i18n("Joins room with given address")}));
|
||||
|
||||
commands.append(QVariant::fromValue(Command{
|
||||
QStringLiteral("/part "),
|
||||
QStringLiteral("[<room-address>]"),
|
||||
i18n("Leave room")}));
|
||||
commands.append(QVariant::fromValue(Command{QStringLiteral("/part "), QStringLiteral("[<room-address>]"), i18n("Leave room")}));
|
||||
|
||||
commands.append(QVariant::fromValue(Command{
|
||||
QStringLiteral("/invite "),
|
||||
QStringLiteral("<user-id>"),
|
||||
i18n("Invites user with given id to current room")}));
|
||||
commands.append(QVariant::fromValue(Command{QStringLiteral("/invite "), QStringLiteral("<user-id>"), i18n("Invites user with given id to current room")}));
|
||||
|
||||
commands.append(QVariant::fromValue(Command{
|
||||
QStringLiteral("/react "),
|
||||
QStringLiteral("<reaction text>"),
|
||||
i18n("React to this message with a text")}));
|
||||
commands.append(QVariant::fromValue(Command{QStringLiteral("/react "), QStringLiteral("<reaction text>"), i18n("React to this message with a text")}));
|
||||
|
||||
// TODO more see elements /help action
|
||||
|
||||
return commands;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,11 +21,10 @@ struct Command {
|
||||
QString parameter;
|
||||
QString help;
|
||||
|
||||
Q_GADGET
|
||||
Q_GADGET
|
||||
Q_PROPERTY(QString command MEMBER command)
|
||||
Q_PROPERTY(QString parameter MEMBER parameter)
|
||||
Q_PROPERTY(QString help MEMBER help)
|
||||
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(Command)
|
||||
|
||||
@@ -23,12 +23,12 @@
|
||||
#include <QElapsedTimer>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QQuickItem>
|
||||
#include <QGuiApplication>
|
||||
#include <QMovie>
|
||||
#include <QNetworkConfigurationManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QPixmap>
|
||||
#include <QQuickItem>
|
||||
#include <QQuickWindow>
|
||||
#include <QStandardPaths>
|
||||
#include <QStringBuilder>
|
||||
@@ -50,9 +50,9 @@
|
||||
#include "neochatconfig.h"
|
||||
#include "neochatroom.h"
|
||||
#include "neochatuser.h"
|
||||
#include "roommanager.h"
|
||||
#include "settings.h"
|
||||
#include "utils.h"
|
||||
#include "roommanager.h"
|
||||
#include <KStandardShortcut>
|
||||
|
||||
#ifndef Q_OS_ANDROID
|
||||
@@ -119,8 +119,7 @@ Controller::Controller(QObject *parent)
|
||||
}
|
||||
#endif
|
||||
|
||||
connect(m_mgr, &QNetworkConfigurationManager::onlineStateChanged,
|
||||
this, &Controller::isOnlineChanged);
|
||||
connect(m_mgr, &QNetworkConfigurationManager::onlineStateChanged, this, &Controller::isOnlineChanged);
|
||||
}
|
||||
|
||||
Controller::~Controller()
|
||||
@@ -399,7 +398,7 @@ void Controller::changeAvatar(Connection *conn, const QUrl &localFile)
|
||||
{
|
||||
auto job = conn->uploadFile(localFile.toLocalFile());
|
||||
#ifdef QUOTIENT_07
|
||||
if(isJobPending(job)) {
|
||||
if (isJobPending(job)) {
|
||||
#else
|
||||
if (isJobRunning(job)) {
|
||||
#endif
|
||||
@@ -641,6 +640,5 @@ bool Controller::hasWindowSystem() const
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <QMediaPlayer>
|
||||
#include <QQuickItem>
|
||||
#include <QObject>
|
||||
#include <QQuickItem>
|
||||
|
||||
#include <KAboutData>
|
||||
#include <KFormat>
|
||||
@@ -91,6 +91,7 @@ public:
|
||||
Q_INVOKABLE void openOrCreateDirectChat(NeoChatUser *user);
|
||||
|
||||
Q_INVOKABLE void setBlur(QQuickItem *item, bool blur);
|
||||
|
||||
private:
|
||||
explicit Controller(QObject *parent = nullptr);
|
||||
~Controller() override;
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <csapi/account-data.h>
|
||||
#include <csapi/profile.h>
|
||||
#include <csapi/content-repo.h>
|
||||
#include <csapi/profile.h>
|
||||
|
||||
#include "customemojimodel_p.h"
|
||||
|
||||
@@ -19,16 +19,16 @@ void CustomEmojiModel::fetchEmojies()
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& data = d->conn->accountData("im.ponies.user_emotes");
|
||||
const auto &data = d->conn->accountData("im.ponies.user_emotes");
|
||||
if (data == nullptr) {
|
||||
return;
|
||||
}
|
||||
QJsonObject emojies = data->contentJson()["images"].toObject();
|
||||
|
||||
//TODO: Remove with stable migration
|
||||
// TODO: Remove with stable migration
|
||||
const auto legacyEmojies = data->contentJson()["emoticons"].toObject();
|
||||
for(const auto &emoji : legacyEmojies.keys()) {
|
||||
if(!emojies.contains(emoji)) {
|
||||
for (const auto &emoji : legacyEmojies.keys()) {
|
||||
if (!emojies.contains(emoji)) {
|
||||
emojies[emoji] = legacyEmojies[emoji];
|
||||
}
|
||||
}
|
||||
@@ -36,22 +36,18 @@ void CustomEmojiModel::fetchEmojies()
|
||||
beginResetModel();
|
||||
d->emojies.clear();
|
||||
|
||||
for (const auto& emoji : emojies.keys()) {
|
||||
const auto& data = emojies[emoji];
|
||||
for (const auto &emoji : emojies.keys()) {
|
||||
const auto &data = emojies[emoji];
|
||||
|
||||
const auto e = emoji.startsWith(":") ? emoji : (QStringLiteral(":") + emoji + QStringLiteral(":"));
|
||||
|
||||
d->emojies << CustomEmoji {
|
||||
e,
|
||||
data.toObject()["url"].toString(),
|
||||
QRegularExpression(QStringLiteral(R"((^|[^\\]))") + e)
|
||||
};
|
||||
d->emojies << CustomEmoji{e, data.toObject()["url"].toString(), QRegularExpression(QStringLiteral(R"((^|[^\\]))") + e)};
|
||||
}
|
||||
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void CustomEmojiModel::addEmoji(const QString& name, const QUrl& location)
|
||||
void CustomEmojiModel::addEmoji(const QString &name, const QUrl &location)
|
||||
{
|
||||
using namespace Quotient;
|
||||
|
||||
@@ -59,7 +55,7 @@ void CustomEmojiModel::addEmoji(const QString& name, const QUrl& location)
|
||||
|
||||
if (running(job)) {
|
||||
connect(job, &BaseJob::success, this, [this, name, job] {
|
||||
const auto& data = d->conn->accountData("im.ponies.user_emotes");
|
||||
const auto &data = d->conn->accountData("im.ponies.user_emotes");
|
||||
auto json = data != nullptr ? data->contentJson() : QJsonObject();
|
||||
auto emojiData = json["images"].toObject();
|
||||
emojiData[QStringLiteral("%1").arg(name)] = QJsonObject({
|
||||
@@ -75,30 +71,30 @@ void CustomEmojiModel::addEmoji(const QString& name, const QUrl& location)
|
||||
}
|
||||
}
|
||||
|
||||
void CustomEmojiModel::removeEmoji(const QString& name)
|
||||
void CustomEmojiModel::removeEmoji(const QString &name)
|
||||
{
|
||||
using namespace Quotient;
|
||||
|
||||
const auto& data = d->conn->accountData("im.ponies.user_emotes");
|
||||
const auto &data = d->conn->accountData("im.ponies.user_emotes");
|
||||
Q_ASSERT(data != nullptr); // something's screwed if we get here with a nullptr
|
||||
auto json = data->contentJson();
|
||||
const QString _name = name.mid(1).chopped(1);
|
||||
auto emojiData = json["images"].toObject();
|
||||
|
||||
if(emojiData.contains(name)) {
|
||||
if (emojiData.contains(name)) {
|
||||
emojiData.remove(name);
|
||||
json["images"] = emojiData;
|
||||
}
|
||||
if(emojiData.contains(_name)) {
|
||||
if (emojiData.contains(_name)) {
|
||||
emojiData.remove(_name);
|
||||
json["images"] = emojiData;
|
||||
}
|
||||
emojiData = json["emoticons"].toObject();
|
||||
if(emojiData.contains(name)) {
|
||||
if (emojiData.contains(name)) {
|
||||
emojiData.remove(name);
|
||||
json["emoticons"] = emojiData;
|
||||
}
|
||||
if(emojiData.contains(_name)) {
|
||||
if (emojiData.contains(_name)) {
|
||||
emojiData.remove(_name);
|
||||
json["emoticons"] = emojiData;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// SPDX-FileCopyrightText: 2021 Carson Black <uhhadd@gmail.com>
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "emojimodel.h"
|
||||
#include "customemojimodel_p.h"
|
||||
#include "emojimodel.h"
|
||||
|
||||
enum Roles {
|
||||
Name,
|
||||
@@ -10,13 +10,16 @@ enum Roles {
|
||||
ModelData, // for emulating the regular emoji model's usage, otherwise the UI code would get too complicated
|
||||
};
|
||||
|
||||
CustomEmojiModel::CustomEmojiModel(QObject* parent) : QAbstractListModel(parent), d(new Private)
|
||||
CustomEmojiModel::CustomEmojiModel(QObject *parent)
|
||||
: QAbstractListModel(parent)
|
||||
, d(new Private)
|
||||
{
|
||||
connect(this, &CustomEmojiModel::connectionChanged, this, &CustomEmojiModel::fetchEmojies);
|
||||
connect(this, &CustomEmojiModel::connectionChanged, this, [this]() {
|
||||
if (!d->conn) return;
|
||||
if (!d->conn)
|
||||
return;
|
||||
|
||||
connect(d->conn, &Connection::accountDataChanged, this, [this](const QString& id) {
|
||||
connect(d->conn, &Connection::accountDataChanged, this, [this](const QString &id) {
|
||||
if (id != QStringLiteral("im.ponies.user_emotes")) {
|
||||
return;
|
||||
}
|
||||
@@ -27,24 +30,19 @@ CustomEmojiModel::CustomEmojiModel(QObject* parent) : QAbstractListModel(parent)
|
||||
|
||||
CustomEmojiModel::~CustomEmojiModel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QVariant CustomEmojiModel::data(const QModelIndex& idx, int role) const
|
||||
QVariant CustomEmojiModel::data(const QModelIndex &idx, int role) const
|
||||
{
|
||||
const auto row = idx.row();
|
||||
if (row >= d->emojies.length()) {
|
||||
return QVariant();
|
||||
}
|
||||
const auto& data = d->emojies[row];
|
||||
const auto &data = d->emojies[row];
|
||||
|
||||
switch (Roles(role)) {
|
||||
case Roles::ModelData:
|
||||
return QVariant::fromValue(Emoji(
|
||||
QStringLiteral("image://mxc/") + data.url.mid(6),
|
||||
data.name,
|
||||
true
|
||||
));
|
||||
return QVariant::fromValue(Emoji(QStringLiteral("image://mxc/") + data.url.mid(6), data.name, true));
|
||||
case Roles::Name:
|
||||
return data.name;
|
||||
case Roles::ImageURL:
|
||||
@@ -54,28 +52,28 @@ QVariant CustomEmojiModel::data(const QModelIndex& idx, int role) const
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
int CustomEmojiModel::rowCount(const QModelIndex& parent) const
|
||||
int CustomEmojiModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
|
||||
return d->emojies.length();
|
||||
}
|
||||
|
||||
QHash<int,QByteArray> CustomEmojiModel::roleNames() const
|
||||
QHash<int, QByteArray> CustomEmojiModel::roleNames() const
|
||||
{
|
||||
return {
|
||||
{ Name, "name" },
|
||||
{ ImageURL, "imageURL" },
|
||||
{ ModelData, "modelData" },
|
||||
{Name, "name"},
|
||||
{ImageURL, "imageURL"},
|
||||
{ModelData, "modelData"},
|
||||
};
|
||||
}
|
||||
|
||||
Connection* CustomEmojiModel::connection() const
|
||||
Connection *CustomEmojiModel::connection() const
|
||||
{
|
||||
return d->conn;
|
||||
}
|
||||
|
||||
void CustomEmojiModel::setConnection(Connection* it)
|
||||
void CustomEmojiModel::setConnection(Connection *it)
|
||||
{
|
||||
if (d->conn == it) {
|
||||
return;
|
||||
@@ -90,8 +88,10 @@ void CustomEmojiModel::setConnection(Connection* it)
|
||||
QString CustomEmojiModel::preprocessText(const QString &it)
|
||||
{
|
||||
auto cp = it;
|
||||
for (const auto& emoji : qAsConst(d->emojies)) {
|
||||
cp.replace(emoji.regexp, QStringLiteral(R"(<img data-mx-emoticon="" src="%1" alt="%2" title="%2" height="32" vertical-align="middle" />)").arg(emoji.url, emoji.name));
|
||||
for (const auto &emoji : qAsConst(d->emojies)) {
|
||||
cp.replace(
|
||||
emoji.regexp,
|
||||
QStringLiteral(R"(<img data-mx-emoticon="" src="%1" alt="%2" title="%2" height="32" vertical-align="middle" />)").arg(emoji.url, emoji.name));
|
||||
}
|
||||
return cp;
|
||||
}
|
||||
@@ -99,15 +99,13 @@ QString CustomEmojiModel::preprocessText(const QString &it)
|
||||
QVariantList CustomEmojiModel::filterModel(const QString &filter)
|
||||
{
|
||||
QVariantList results;
|
||||
for (const auto& emoji : qAsConst(d->emojies)) {
|
||||
if (results.length() >= 10) break;
|
||||
if (!emoji.name.contains(filter, Qt::CaseInsensitive)) continue;
|
||||
for (const auto &emoji : qAsConst(d->emojies)) {
|
||||
if (results.length() >= 10)
|
||||
break;
|
||||
if (!emoji.name.contains(filter, Qt::CaseInsensitive))
|
||||
continue;
|
||||
|
||||
results << QVariant::fromValue(Emoji(
|
||||
QStringLiteral("image://mxc/") + emoji.url.mid(6),
|
||||
emoji.name,
|
||||
true
|
||||
));
|
||||
results << QVariant::fromValue(Emoji(QStringLiteral("image://mxc/") + emoji.url.mid(6), emoji.name, true));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
@@ -13,43 +13,39 @@ using namespace Quotient;
|
||||
|
||||
class CustomEmojiModel : public QAbstractListModel
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(Connection *connection READ connection WRITE setConnection NOTIFY connectionChanged)
|
||||
|
||||
public:
|
||||
|
||||
// constructors
|
||||
|
||||
explicit CustomEmojiModel(QObject* parent = nullptr);
|
||||
explicit CustomEmojiModel(QObject *parent = nullptr);
|
||||
~CustomEmojiModel();
|
||||
|
||||
// model
|
||||
|
||||
QVariant data(const QModelIndex& idx, int role = Qt::DisplayRole) const override;
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override;
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
QHash<int,QByteArray> roleNames() const override;
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
// property setters
|
||||
|
||||
Connection* connection() const;
|
||||
void setConnection(Connection* it);
|
||||
Connection *connection() const;
|
||||
void setConnection(Connection *it);
|
||||
Q_SIGNAL void connectionChanged();
|
||||
|
||||
// QML functions
|
||||
|
||||
Q_INVOKABLE QString preprocessText(const QString& it);
|
||||
Q_INVOKABLE QString preprocessText(const QString &it);
|
||||
Q_INVOKABLE QVariantList filterModel(const QString &filter);
|
||||
Q_INVOKABLE void addEmoji(const QString& name, const QUrl& location);
|
||||
Q_INVOKABLE void removeEmoji(const QString& name);
|
||||
Q_INVOKABLE void addEmoji(const QString &name, const QUrl &location);
|
||||
Q_INVOKABLE void removeEmoji(const QString &name);
|
||||
|
||||
private:
|
||||
|
||||
struct Private;
|
||||
std::unique_ptr<Private> d;
|
||||
|
||||
void fetchEmojies();
|
||||
|
||||
};
|
||||
|
||||
@@ -5,15 +5,13 @@
|
||||
|
||||
#include "customemojimodel.h"
|
||||
|
||||
struct CustomEmoji
|
||||
{
|
||||
struct CustomEmoji {
|
||||
QString name; // with :semicolons:
|
||||
QString url; // mxc://
|
||||
QRegularExpression regexp;
|
||||
};
|
||||
|
||||
struct CustomEmojiModel::Private
|
||||
{
|
||||
Connection* conn = nullptr;
|
||||
struct CustomEmojiModel::Private {
|
||||
Connection *conn = nullptr;
|
||||
QList<CustomEmoji> emojies;
|
||||
};
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
DevicesModel::DevicesModel(QObject *parent)
|
||||
: QAbstractListModel(parent)
|
||||
{
|
||||
connect(&Controller::instance(), &Controller::activeConnectionChanged,
|
||||
this, &DevicesModel::fetchDevices);
|
||||
connect(&Controller::instance(), &Controller::activeConnectionChanged, this, &DevicesModel::fetchDevices);
|
||||
|
||||
fetchDevices();
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ void Login::init()
|
||||
|
||||
m_testing = true;
|
||||
Q_EMIT testingChanged();
|
||||
if(!m_connection) {
|
||||
if (!m_connection) {
|
||||
m_connection = new Connection(this);
|
||||
}
|
||||
m_connection->resolveServer(m_matrixId);
|
||||
|
||||
43
src/main.cpp
43
src/main.cpp
@@ -2,16 +2,16 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
#include <QCommandLineParser>
|
||||
#include <QDebug>
|
||||
#include <QFontDatabase>
|
||||
#include <QGuiApplication>
|
||||
#include <QIcon>
|
||||
#include <QNetworkProxy>
|
||||
#include <QNetworkProxyFactory>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QQmlContext>
|
||||
#include <QQuickStyle>
|
||||
#include <QQuickWindow>
|
||||
#include <QDebug>
|
||||
#include <QIcon>
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
#include <QGuiApplication>
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
#include "accountlistmodel.h"
|
||||
#include "actionshandler.h"
|
||||
#include "blurhashimageprovider.h"
|
||||
#include "chatboxhelper.h"
|
||||
#include "chatdocumenthandler.h"
|
||||
#include "clipboard.h"
|
||||
@@ -38,6 +39,7 @@
|
||||
#include "controller.h"
|
||||
#include "csapi/joining.h"
|
||||
#include "csapi/leaving.h"
|
||||
#include "customemojimodel.h"
|
||||
#include "devicesmodel.h"
|
||||
#include "emojimodel.h"
|
||||
#include "filetypesingleton.h"
|
||||
@@ -50,16 +52,14 @@
|
||||
#include "neochatuser.h"
|
||||
#include "notificationsmanager.h"
|
||||
#include "publicroomlistmodel.h"
|
||||
#include <room.h>
|
||||
#include "roomlistmodel.h"
|
||||
#include "roommanager.h"
|
||||
#include "sortfilterroomlistmodel.h"
|
||||
#include "spellcheckhighlighter.h"
|
||||
#include "userdirectorylistmodel.h"
|
||||
#include "userlistmodel.h"
|
||||
#include "webshortcutmodel.h"
|
||||
#include "spellcheckhighlighter.h"
|
||||
#include "customemojimodel.h"
|
||||
#include "blurhashimageprovider.h"
|
||||
#include <room.h>
|
||||
#ifdef HAVE_COLORSCHEME
|
||||
#include "colorschemer.h"
|
||||
#endif
|
||||
@@ -112,27 +112,28 @@ int main(int argc, char *argv[])
|
||||
about.addAuthor(i18n("Tobias Fella"), QString(), QStringLiteral("fella@posteo.de"));
|
||||
about.setOrganizationDomain("kde.org");
|
||||
|
||||
about.addComponent(QStringLiteral("libQuotient"), i18n("A Qt5 library to write cross-platform clients for Matrix"), QString(), QStringLiteral("https://github.com/quotient-im/libquotient"), KAboutLicense::LGPL_V2_1);
|
||||
about.addComponent(QStringLiteral("libQuotient"),
|
||||
i18n("A Qt5 library to write cross-platform clients for Matrix"),
|
||||
QString(),
|
||||
QStringLiteral("https://github.com/quotient-im/libquotient"),
|
||||
KAboutLicense::LGPL_V2_1);
|
||||
|
||||
KAboutData::setApplicationData(about);
|
||||
QGuiApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("org.kde.neochat")));
|
||||
|
||||
#ifdef HAVE_KDBUSADDONS
|
||||
KDBusService service(KDBusService::Unique);
|
||||
service.connect(&service,
|
||||
&KDBusService::activateRequested,
|
||||
&RoomManager::instance(),
|
||||
[](const QStringList &arguments, const QString &workingDirectory) {
|
||||
Q_UNUSED(workingDirectory);
|
||||
if(arguments.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
auto args = arguments;
|
||||
args.removeFirst();
|
||||
for (const auto &arg : args) {
|
||||
RoomManager::instance().openResource(arg);
|
||||
}
|
||||
});
|
||||
service.connect(&service, &KDBusService::activateRequested, &RoomManager::instance(), [](const QStringList &arguments, const QString &workingDirectory) {
|
||||
Q_UNUSED(workingDirectory);
|
||||
if (arguments.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
auto args = arguments;
|
||||
args.removeFirst();
|
||||
for (const auto &arg : args) {
|
||||
RoomManager::instance().openResource(arg);
|
||||
}
|
||||
});
|
||||
#endif
|
||||
|
||||
#ifdef NEOCHAT_FLATPAK
|
||||
|
||||
@@ -87,7 +87,7 @@ void ThumbnailResponse::prepareResult()
|
||||
errorStr.clear();
|
||||
} else if (job->error() == BaseJob::Abandoned) {
|
||||
errorStr = i18n("Image request has been cancelled");
|
||||
//qDebug() << "ThumbnailResponse: cancelled for" << mediaId;
|
||||
// qDebug() << "ThumbnailResponse: cancelled for" << mediaId;
|
||||
} else {
|
||||
errorStr = job->errorString();
|
||||
qWarning() << "ThumbnailResponse: no valid image for" << mediaId << "-" << errorStr;
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
#include <QQmlEngine> // for qmlRegisterType()
|
||||
#include <QTimeZone>
|
||||
|
||||
#include <KLocalizedString>
|
||||
#include <KFormat>
|
||||
#include <KLocalizedString>
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
@@ -184,7 +184,7 @@ void MessageEventModel::setRoom(NeoChatRoom *room)
|
||||
beginRemoveRows({}, i, i);
|
||||
});
|
||||
connect(m_currentRoom, &Room::pendingEventDiscarded, this, &MessageEventModel::endRemoveRows);
|
||||
connect(m_currentRoom, &Room::readMarkerMoved, this, [=](const QString &fromEventId, const QString &toEventId){
|
||||
connect(m_currentRoom, &Room::readMarkerMoved, this, [=](const QString &fromEventId, const QString &toEventId) {
|
||||
Q_UNUSED(fromEventId);
|
||||
moveReadMarker(toEventId);
|
||||
});
|
||||
@@ -370,7 +370,6 @@ int MessageEventModel::rowCount(const QModelIndex &parent) const
|
||||
} else {
|
||||
return m_currentRoom->timelineSize();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool MessageEventModel::canFetchMore(const QModelIndex &parent) const
|
||||
@@ -388,7 +387,6 @@ void MessageEventModel::fetchMore(const QModelIndex &parent)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline QVariantMap userAtEvent(NeoChatUser *user, NeoChatRoom *room, const RoomEvent &evt)
|
||||
{
|
||||
Q_UNUSED(evt)
|
||||
@@ -415,22 +413,22 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const
|
||||
bool isPending = row < timelineBaseIndex();
|
||||
|
||||
if (m_lastReadEventIndex.row() == row) {
|
||||
switch(role) {
|
||||
switch (role) {
|
||||
case EventTypeRole:
|
||||
return QStringLiteral("readMarker");
|
||||
case TimeRole:
|
||||
{
|
||||
const QDateTime eventDate = data(index(m_lastReadEventIndex.row() + 1, 0), TimeRole).toDateTime();
|
||||
const KFormat format;
|
||||
return format.formatRelativeDateTime(eventDate, QLocale::ShortFormat);
|
||||
}
|
||||
case TimeRole: {
|
||||
const QDateTime eventDate = data(index(m_lastReadEventIndex.row() + 1, 0), TimeRole).toDateTime();
|
||||
const KFormat format;
|
||||
return format.formatRelativeDateTime(eventDate, QLocale::ShortFormat);
|
||||
}
|
||||
case SpecialMarksRole:
|
||||
return EventStatus::Hidden;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto timelineIt = m_currentRoom->messageEvents().crbegin() + std::max(0, row - timelineBaseIndex() - (m_lastReadEventIndex.isValid() && m_lastReadEventIndex.row() < row ? 1 : 0));
|
||||
const auto timelineIt = m_currentRoom->messageEvents().crbegin()
|
||||
+ std::max(0, row - timelineBaseIndex() - (m_lastReadEventIndex.isValid() && m_lastReadEventIndex.row() < row ? 1 : 0));
|
||||
const auto pendingIt = m_currentRoom->pendingEvents().crbegin() + std::min(row, timelineBaseIndex());
|
||||
const auto &evt = isPending ? **pendingIt : **timelineIt;
|
||||
|
||||
@@ -684,12 +682,11 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const
|
||||
content = QVariant::fromValue(e->image().originalJson);
|
||||
}
|
||||
|
||||
return QVariantMap{
|
||||
{"eventId", replyEventId},
|
||||
{"display", m_currentRoom->eventToString(replyEvt, Qt::RichText)},
|
||||
{"content", content},
|
||||
{"type", type},
|
||||
{"author", userAtEvent(static_cast<NeoChatUser *>(m_currentRoom->user(replyEvt.senderId())), m_currentRoom, evt)}};
|
||||
return QVariantMap{{"eventId", replyEventId},
|
||||
{"display", m_currentRoom->eventToString(replyEvt, Qt::RichText)},
|
||||
{"content", content},
|
||||
{"type", type},
|
||||
{"author", userAtEvent(static_cast<NeoChatUser *>(m_currentRoom->user(replyEvt.senderId())), m_currentRoom, evt)}};
|
||||
}
|
||||
|
||||
if (role == ShowAuthorRole) {
|
||||
@@ -759,7 +756,7 @@ int MessageEventModel::eventIDToIndex(const QString &eventID) const
|
||||
{
|
||||
const auto it = m_currentRoom->findInTimeline(eventID);
|
||||
if (it == m_currentRoom->historyEdge()) {
|
||||
//qWarning() << "Trying to find inexistent event:" << eventID;
|
||||
// qWarning() << "Trying to find inexistent event:" << eventID;
|
||||
return -1;
|
||||
}
|
||||
return it - m_currentRoom->messageEvents().rbegin() + timelineBaseIndex();
|
||||
|
||||
@@ -275,15 +275,13 @@ QVariantList NeoChatRoom::getUsers(const QString &keyword) const
|
||||
return matchedList;
|
||||
}
|
||||
|
||||
QVariantMap NeoChatRoom::getUser(const QString& userID) const
|
||||
QVariantMap NeoChatRoom::getUser(const QString &userID) const
|
||||
{
|
||||
NeoChatUser user(userID, connection());
|
||||
return QVariantMap {
|
||||
{ QStringLiteral("id"), user.id() },
|
||||
{ QStringLiteral("displayName"), user.displayname(this) },
|
||||
{ QStringLiteral("avatarMediaId"), user.avatarMediaId(this) },
|
||||
{ QStringLiteral("color"), user.color() }
|
||||
};
|
||||
return QVariantMap{{QStringLiteral("id"), user.id()},
|
||||
{QStringLiteral("displayName"), user.displayname(this)},
|
||||
{QStringLiteral("avatarMediaId"), user.avatarMediaId(this)},
|
||||
{QStringLiteral("color"), user.color()}};
|
||||
}
|
||||
|
||||
QUrl NeoChatRoom::urlToMxcUrl(const QUrl &mxcUrl)
|
||||
@@ -328,7 +326,7 @@ QString NeoChatRoom::eventToString(const RoomEvent &evt, Qt::TextFormat format,
|
||||
htmlBody.replace(utils::strikethroughRegExp, "<s>\\1</s>");
|
||||
|
||||
auto url = connection()->homeserver();
|
||||
auto base = url.scheme() + QStringLiteral("://") + url.host() + (url.port() != -1 ? ':'+QString::number(url.port()) : QString());
|
||||
auto base = url.scheme() + QStringLiteral("://") + url.host() + (url.port() != -1 ? ':' + QString::number(url.port()) : QString());
|
||||
htmlBody.replace(utils::mxcImageRegExp, QStringLiteral(R"(<img \1 src="%1/_matrix/media/r0/download/\2/\3" \4 > )").arg(base));
|
||||
|
||||
return htmlBody;
|
||||
@@ -472,7 +470,7 @@ void NeoChatRoom::changeAvatar(const QUrl &localFile)
|
||||
{
|
||||
const auto job = connection()->uploadFile(localFile.toLocalFile());
|
||||
#ifdef QUOTIENT_07
|
||||
if(isJobPending(job)) {
|
||||
if (isJobPending(job)) {
|
||||
#else
|
||||
if (isJobRunning(job)) {
|
||||
#endif
|
||||
@@ -553,7 +551,7 @@ QString msgTypeToString(MessageEventType msgType)
|
||||
}
|
||||
}
|
||||
|
||||
QString NeoChatRoom::preprocessText(const QString& text)
|
||||
QString NeoChatRoom::preprocessText(const QString &text)
|
||||
{
|
||||
return markdownToHTML(text);
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
#endif
|
||||
|
||||
#include "controller.h"
|
||||
#include "roommanager.h"
|
||||
#include "neochatconfig.h"
|
||||
#include "roommanager.h"
|
||||
|
||||
NotificationsManager &NotificationsManager::instance()
|
||||
{
|
||||
|
||||
@@ -353,7 +353,7 @@ QVariant RoomListModel::data(const QModelIndex &index, int role) const
|
||||
if (room->isDirectChat()) {
|
||||
return RoomType::Direct;
|
||||
}
|
||||
const RoomCreateEvent* creationEvent = room->creation();
|
||||
const RoomCreateEvent *creationEvent = room->creation();
|
||||
QJsonObject contentJson = creationEvent->contentJson();
|
||||
QJsonObject::const_iterator typeIter = contentJson.find("type");
|
||||
if (typeIter != contentJson.end()) {
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||
|
||||
#include "roommanager.h"
|
||||
#include "neochatroom.h"
|
||||
#include "neochatconfig.h"
|
||||
#include "controller.h"
|
||||
#include <QDesktopServices>
|
||||
#include <QStandardPaths>
|
||||
#include "neochatconfig.h"
|
||||
#include "neochatroom.h"
|
||||
#include <KConfigGroup>
|
||||
#include <KLocalizedString>
|
||||
#include <QDesktopServices>
|
||||
#include <QStandardPaths>
|
||||
#include <csapi/joining.h>
|
||||
#include <utility>
|
||||
|
||||
@@ -22,7 +22,8 @@ RoomManager::RoomManager(QObject *parent)
|
||||
}
|
||||
|
||||
RoomManager::~RoomManager()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
RoomManager &RoomManager::instance()
|
||||
{
|
||||
@@ -37,10 +38,9 @@ NeoChatRoom *RoomManager::currentRoom() const
|
||||
|
||||
void RoomManager::openResource(const QString &idOrUri, const QString &action)
|
||||
{
|
||||
Uri uri { idOrUri };
|
||||
Uri uri{idOrUri};
|
||||
if (!uri.isValid()) {
|
||||
Q_EMIT warning(i18n("Malformed or empty Matrix id"),
|
||||
i18n("%1 is not a correct Matrix identifier", idOrUri));
|
||||
Q_EMIT warning(i18n("Malformed or empty Matrix id"), i18n("%1 is not a correct Matrix identifier", idOrUri));
|
||||
return;
|
||||
}
|
||||
auto account = Controller::instance().activeConnection();
|
||||
@@ -57,8 +57,7 @@ void RoomManager::openResource(const QString &idOrUri, const QString &action)
|
||||
|
||||
const auto result = visitResource(account, uri);
|
||||
if (result == Quotient::CouldNotResolve) {
|
||||
Q_EMIT warning(i18n("Room not found"),
|
||||
i18n("There's no room %1 in the room list. Check the spelling and the account.", idOrUri));
|
||||
Q_EMIT warning(i18n("Room not found"), i18n("There's no room %1 in the room list. Check the spelling and the account.", idOrUri));
|
||||
} else { // Invalid cases should have been eliminated earlier
|
||||
Q_ASSERT(result == Quotient::UriResolved);
|
||||
}
|
||||
@@ -89,13 +88,12 @@ void RoomManager::loadInitialRoom()
|
||||
|
||||
openRoomForActiveConnection();
|
||||
|
||||
connect(&Controller::instance(), &Controller::activeConnectionChanged,
|
||||
this, &RoomManager::openRoomForActiveConnection);
|
||||
connect(&Controller::instance(), &Controller::activeConnectionChanged, this, &RoomManager::openRoomForActiveConnection);
|
||||
}
|
||||
|
||||
void RoomManager::openRoomForActiveConnection()
|
||||
{
|
||||
if(!Controller::instance().activeConnection()) {
|
||||
if (!Controller::instance().activeConnection()) {
|
||||
return;
|
||||
}
|
||||
// Read from last open room
|
||||
@@ -110,8 +108,7 @@ void RoomManager::openRoomForActiveConnection()
|
||||
if (!roomId.isEmpty()) {
|
||||
// Here we can cast because the controller has been configured to
|
||||
// return NeoChatRoom instead of simple Quotient::Room
|
||||
const auto room = qobject_cast<NeoChatRoom *>(
|
||||
Controller::instance().activeConnection()->room(roomId));
|
||||
const auto room = qobject_cast<NeoChatRoom *>(Controller::instance().activeConnection()->room(roomId));
|
||||
|
||||
if (room) {
|
||||
enterRoom(room);
|
||||
@@ -144,7 +141,7 @@ void RoomManager::openWindow(NeoChatRoom *room)
|
||||
Q_EMIT openRoomInNewWindow(room);
|
||||
}
|
||||
|
||||
UriResolveResult RoomManager::visitUser(User* user, const QString &action)
|
||||
UriResolveResult RoomManager::visitUser(User *user, const QString &action)
|
||||
{
|
||||
if (action == "mention" || action.isEmpty()) {
|
||||
// send it has QVariantMap because the properties in the
|
||||
@@ -186,12 +183,10 @@ void RoomManager::visitRoom(Room *room, const QString &eventId)
|
||||
}
|
||||
}
|
||||
|
||||
void RoomManager::joinRoom(Quotient::Connection *account,
|
||||
const QString &roomAliasOrId,
|
||||
const QStringList &viaServers)
|
||||
void RoomManager::joinRoom(Quotient::Connection *account, const QString &roomAliasOrId, const QStringList &viaServers)
|
||||
{
|
||||
account->joinRoom(QUrl::toPercentEncoding(roomAliasOrId), viaServers);
|
||||
connectSingleShot(account, &Quotient::Connection::newRoom, this, [=](Quotient::Room *room){
|
||||
connectSingleShot(account, &Quotient::Connection::newRoom, this, [=](Quotient::Room *room) {
|
||||
enterRoom(dynamic_cast<NeoChatRoom *>(room));
|
||||
});
|
||||
}
|
||||
@@ -199,8 +194,7 @@ void RoomManager::joinRoom(Quotient::Connection *account,
|
||||
bool RoomManager::visitNonMatrix(const QUrl &url)
|
||||
{
|
||||
if (!QDesktopServices::openUrl(url)) {
|
||||
Q_EMIT warning(i18n("No application for the link"),
|
||||
i18n("Your operating system could not find an application for the link."));
|
||||
Q_EMIT warning(i18n("No application for the link"), i18n("Your operating system could not find an application for the link."));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -215,7 +209,7 @@ void RoomManager::reset()
|
||||
|
||||
void RoomManager::leaveRoom(NeoChatRoom *room)
|
||||
{
|
||||
if(m_lastCurrentRoom && room->id() == m_lastCurrentRoom->id()) {
|
||||
if (m_lastCurrentRoom && room->id() == m_lastCurrentRoom->id()) {
|
||||
m_lastCurrentRoom = nullptr;
|
||||
}
|
||||
if (m_currentRoom && m_currentRoom->id() == room->id()) {
|
||||
|
||||
@@ -3,13 +3,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <KConfig>
|
||||
#include <QObject>
|
||||
#include <uriresolver.h>
|
||||
#include <KConfig>
|
||||
|
||||
class NeoChatRoom;
|
||||
|
||||
namespace Quotient {
|
||||
namespace Quotient
|
||||
{
|
||||
class Room;
|
||||
class User;
|
||||
}
|
||||
@@ -53,8 +54,7 @@ public:
|
||||
|
||||
// Overrided methods from UriResolverBase
|
||||
UriResolveResult visitUser(User *user, const QString &action) override;
|
||||
void joinRoom(Quotient::Connection *account, const QString &roomAliasOrId,
|
||||
const QStringList &viaServers) override;
|
||||
void joinRoom(Quotient::Connection *account, const QString &roomAliasOrId, const QStringList &viaServers) override;
|
||||
Q_INVOKABLE void visitRoom(Quotient::Room *room, const QString &eventId) override;
|
||||
Q_INVOKABLE bool visitNonMatrix(const QUrl &url) override;
|
||||
|
||||
|
||||
@@ -79,10 +79,12 @@ SpellcheckHighlighter::SpellcheckHighlighter(QObject *parent)
|
||||
: QSyntaxHighlighter(parent)
|
||||
#ifndef Q_OS_ANDROID
|
||||
, mSpellchecker{new Sonnet::Speller()}
|
||||
, mLanguageGuesser{new Sonnet::GuessLanguage()}
|
||||
, mLanguageGuesser
|
||||
{
|
||||
new Sonnet::GuessLanguage()
|
||||
}
|
||||
#endif
|
||||
, m_document(nullptr)
|
||||
, m_cursorPosition(-1)
|
||||
, m_document(nullptr), m_cursorPosition(-1)
|
||||
{
|
||||
// Danger red from our color scheme
|
||||
mErrorFormat.setForeground(QColor(0xED, 0x15, 0x15));
|
||||
@@ -232,7 +234,7 @@ QStringList SpellcheckHighlighter::suggestions(int mousePosition, int max)
|
||||
}
|
||||
|
||||
return suggestions;
|
||||
#else
|
||||
#else
|
||||
return QStringList();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ void UserListModel::setRoom(Quotient::Room *room)
|
||||
}
|
||||
for (User *user : qAsConst(m_users)) {
|
||||
#ifdef QUOTIENT_07
|
||||
connect(user, &User::defaultAvatarChanged, this, [=](){
|
||||
connect(user, &User::defaultAvatarChanged, this, [=]() {
|
||||
avatarChanged(user, m_currentRoom);
|
||||
});
|
||||
#else
|
||||
@@ -154,7 +154,7 @@ void UserListModel::userAdded(Quotient::User *user)
|
||||
m_users.insert(pos, user);
|
||||
endInsertRows();
|
||||
#ifdef QUOTIENT_07
|
||||
connect(user, &User::defaultAvatarChanged, this, [=](){
|
||||
connect(user, &User::defaultAvatarChanged, this, [=]() {
|
||||
avatarChanged(user, m_currentRoom);
|
||||
});
|
||||
#else
|
||||
|
||||
@@ -5,13 +5,12 @@
|
||||
#include "webshortcutmodel.h"
|
||||
|
||||
#ifdef HAVE_KIO
|
||||
#include <KUriFilter>
|
||||
#include <KIO/CommandLauncherJob>
|
||||
#include <KUriFilter>
|
||||
#endif
|
||||
#include <KStringHandler>
|
||||
|
||||
struct KWebShortcutModelPrivate
|
||||
{
|
||||
struct KWebShortcutModelPrivate {
|
||||
QString selectedText;
|
||||
#ifdef HAVE_KIO
|
||||
KUriFilterData filterData;
|
||||
@@ -29,7 +28,6 @@ KWebShortcutModel::~KWebShortcutModel()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
QString KWebShortcutModel::selectedText() const
|
||||
{
|
||||
return d->selectedText;
|
||||
@@ -101,12 +99,12 @@ QVariant KWebShortcutModel::data(const QModelIndex &index, int role) const
|
||||
|
||||
#ifdef HAVE_KIO
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
return d->searchProviders[index.row()];
|
||||
case Qt::DecorationRole:
|
||||
return d->filterData.iconNameForPreferredSearchProvider(d->searchProviders[index.row()]);
|
||||
case Qt::EditRole:
|
||||
return d->filterData.queryForPreferredSearchProvider(d->searchProviders[index.row()]);
|
||||
case Qt::DisplayRole:
|
||||
return d->searchProviders[index.row()];
|
||||
case Qt::DecorationRole:
|
||||
return d->filterData.iconNameForPreferredSearchProvider(d->searchProviders[index.row()]);
|
||||
case Qt::EditRole:
|
||||
return d->filterData.queryForPreferredSearchProvider(d->searchProviders[index.row()]);
|
||||
}
|
||||
#endif
|
||||
return {};
|
||||
@@ -115,10 +113,10 @@ QVariant KWebShortcutModel::data(const QModelIndex &index, int role) const
|
||||
void KWebShortcutModel::trigger(const QString &data)
|
||||
{
|
||||
#ifdef HAVE_KIO
|
||||
KUriFilterData filterData(data);
|
||||
if (KUriFilter::self()->filterSearchUri(filterData, KUriFilter::WebShortcutFilter)) {
|
||||
KUriFilterData filterData(data);
|
||||
if (KUriFilter::self()->filterSearchUri(filterData, KUriFilter::WebShortcutFilter)) {
|
||||
Q_EMIT openUrl(filterData.uri().url());
|
||||
}
|
||||
}
|
||||
#else
|
||||
Q_UNUSED(data);
|
||||
#endif
|
||||
@@ -127,7 +125,7 @@ void KWebShortcutModel::trigger(const QString &data)
|
||||
void KWebShortcutModel::configureWebShortcuts()
|
||||
{
|
||||
#ifdef HAVE_KIO
|
||||
auto job = new KIO::CommandLauncherJob("kcmshell5", QStringList() << "webshortcuts", this);
|
||||
job->exec();
|
||||
auto job = new KIO::CommandLauncherJob("kcmshell5", QStringList() << "webshortcuts", this);
|
||||
job->exec();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -62,6 +62,7 @@ public:
|
||||
Q_SIGNALS:
|
||||
void selectedTextChanged();
|
||||
void openUrl(const QUrl &url);
|
||||
|
||||
private:
|
||||
std::unique_ptr<KWebShortcutModelPrivate> d;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user