1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-07-19 15:05:40 +02:00

misc: fix clazy warnings

Fix some warnings, and possible some bugs related to bad QObject::connects.

Gitlab: #938
Change-Id: Id4ca9a48b929e7c59df8cf20c6df3504c7971b4c
This commit is contained in:
Andreas Traczyk 2023-05-16 14:02:14 -04:00
parent bb5805fbc5
commit 05a09a8202
35 changed files with 367 additions and 372 deletions

View file

@ -53,7 +53,7 @@ AudioDeviceModel::data(const QModelIndex& index, int role) const
case Qt::DisplayRole:
case Role::DeviceName: {
auto deviceName = devices_.at(index.row());
QRegularExpression re("{{(.*?)}}");
const static QRegularExpression re("{{(.*?)}}");
QRegularExpressionMatch match = re.match(deviceName);
if (match.hasMatch() && re.captureCount() > 0) {
deviceName.replace(match.captured(0), QObject::tr(match.captured(1).toUtf8()));

View file

@ -177,7 +177,7 @@ AvAdapter::captureAllScreens()
QPainter painter(&final);
final.fill(Qt::black);
for (auto scr : scrs) {
for (const auto& scr : scrs) {
painter.drawPixmap(currentPoint, 0, scr.width(), scr.height(), scr);
currentPoint += scr.width();
}
@ -208,7 +208,7 @@ AvAdapter::shareScreenArea(unsigned x, unsigned y, unsigned width, unsigned heig
// xrectsel will freeze all displays too fast so that the call
// context menu will not be closed even closed signal is emitted
// use timer to wait until popup is closed
QTimer::singleShot(100, [=]() mutable {
QTimer::singleShot(100, this, [=]() mutable {
x = y = width = height = 0;
xrectsel(&x, &y, &width, &height);
auto resource = lrcInstance_->getCurrentCallModel()->getDisplay(getScreenNumber(),
@ -296,16 +296,18 @@ AvAdapter::stopSharing(const QString& source)
if (!source.isEmpty() && !callId.isEmpty()) {
if (source.startsWith(libjami::Media::VideoProtocolPrefix::DISPLAY)) {
qDebug() << "Stopping display: " << source;
lrcInstance_->getCurrentCallModel()->removeMedia(callId,
libjami::Media::Details::MEDIA_TYPE_VIDEO,
libjami::Media::VideoProtocolPrefix::DISPLAY,
muteCamera_);
lrcInstance_->getCurrentCallModel()
->removeMedia(callId,
libjami::Media::Details::MEDIA_TYPE_VIDEO,
libjami::Media::VideoProtocolPrefix::DISPLAY,
muteCamera_);
} else {
qDebug() << "Stopping file: " << source;
lrcInstance_->getCurrentCallModel()->removeMedia(callId,
libjami::Media::Details::MEDIA_TYPE_VIDEO,
libjami::Media::VideoProtocolPrefix::FILE,
muteCamera_);
lrcInstance_->getCurrentCallModel()
->removeMedia(callId,
libjami::Media::Details::MEDIA_TYPE_VIDEO,
libjami::Media::VideoProtocolPrefix::FILE,
muteCamera_);
}
}
}

View file

@ -26,33 +26,12 @@ BannedListModel::BannedListModel(QObject* parent)
{
connect(this, &BannedListModel::lrcInstanceChanged, [this]() {
if (lrcInstance_ && lrcInstance_->getCurrentContactModel()) {
connect(
lrcInstance_->getCurrentContactModel(),
&ContactModel::bannedStatusChanged,
// Listen for account change and reconnect to the new account contact model.
connect(lrcInstance_,
&LRCInstance::currentAccountIdChanged,
this,
[&](const QString& uri, bool banned) {
if (banned) {
beginInsertRows(QModelIndex(), rowCount(), rowCount());
bannedlist_.append(uri);
endInsertRows();
set_count(rowCount());
} else {
auto it = std::find_if(bannedlist_.begin(),
bannedlist_.end(),
[&uri](const auto& c) { return uri == c; });
if (it != bannedlist_.end()) {
auto elementIndex = std::distance(bannedlist_.begin(), it);
beginRemoveRows(QModelIndex(), elementIndex, elementIndex);
bannedlist_.remove(elementIndex);
endRemoveRows();
set_count(rowCount());
}
}
},
Qt::UniqueConnection);
}
reset();
&BannedListModel::setupForAccount);
setupForAccount();
});
}
@ -66,16 +45,6 @@ BannedListModel::rowCount(const QModelIndex& parent) const
return 0;
}
int
BannedListModel::columnCount(const QModelIndex& parent) const
{
Q_UNUSED(parent);
/*
* Only need one column.
*/
return 1;
}
QVariant
BannedListModel::data(const QModelIndex& index, int role) const
{
@ -123,13 +92,6 @@ BannedListModel::index(int row, int column, const QModelIndex& parent) const
return QModelIndex();
}
QModelIndex
BannedListModel::parent(const QModelIndex& child) const
{
Q_UNUSED(child);
return QModelIndex();
}
Qt::ItemFlags
BannedListModel::flags(const QModelIndex& index) const
{
@ -148,3 +110,38 @@ BannedListModel::reset()
endResetModel();
set_count(rowCount());
}
void
BannedListModel::setupForAccount()
{
if (lrcInstance_ && lrcInstance_->getCurrentContactModel()) {
connect(lrcInstance_->getCurrentContactModel(),
&ContactModel::bannedStatusChanged,
this,
&BannedListModel::onBannedStatusChanged,
Qt::UniqueConnection);
}
reset();
}
void
BannedListModel::onBannedStatusChanged(const QString& uri, bool banned)
{
if (banned) {
beginInsertRows(QModelIndex(), rowCount(), rowCount());
bannedlist_.append(uri);
endInsertRows();
set_count(rowCount());
} else {
auto it = std::find_if(bannedlist_.begin(), bannedlist_.end(), [&uri](const auto& c) {
return uri == c;
});
if (it != bannedlist_.end()) {
auto elementIndex = std::distance(bannedlist_.begin(), it);
beginRemoveRows(QModelIndex(), elementIndex, elementIndex);
bannedlist_.remove(elementIndex);
endRemoveRows();
set_count(rowCount());
}
}
}

View file

@ -32,25 +32,22 @@ public:
explicit BannedListModel(QObject* parent = nullptr);
~BannedListModel();
/*
* QAbstractListModel override.
*/
// QAbstractListModel override.
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
int columnCount(const QModelIndex& parent) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
/*
* Override role name as access point in qml.
*/
QHash<int, QByteArray> roleNames() const override;
QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex& child) const;
Qt::ItemFlags flags(const QModelIndex& index) const;
QModelIndex index(int row,
int column = 0,
const QModelIndex& parent = QModelIndex()) const override;
Qt::ItemFlags flags(const QModelIndex& index) const override;
/*
* This function is to reset the model when there's new account added.
*/
// This function is to reset the model when there's new account added.
void reset();
private Q_SLOTS:
void setupForAccount();
void onBannedStatusChanged(const QString& uri, bool banned);
private:
QList<QString> bannedlist_;
};

View file

@ -72,6 +72,7 @@ CallAdapter::CallAdapter(SystemTray* systemTray, LRCInstance* instance, QObject*
// notification responses (gnu/linux currently)
connect(systemTray_,
&SystemTray::answerCallActivated,
this,
[this](const QString& accountId, const QString& convUid) {
acceptACall(accountId, convUid);
Q_EMIT lrcInstance_->notificationClicked();
@ -81,6 +82,7 @@ CallAdapter::CallAdapter(SystemTray* systemTray, LRCInstance* instance, QObject*
});
connect(systemTray_,
&SystemTray::declineCallActivated,
this,
[this](const QString& accountId, const QString& convUid) {
hangUpACall(accountId, convUid);
});
@ -134,10 +136,10 @@ CallAdapter::onCallStatusChanged(const QString& accountId, const QString& callId
// handle notifications
if (call.status == lrc::api::call::Status::IN_PROGRESS) {
// Call answered and in progress; close the notification
systemTray_->hideNotification(QString("%1;%2").arg(accountId).arg(convInfo.uid));
systemTray_->hideNotification(QString("%1;%2").arg(accountId, convInfo.uid));
} else if (call.status == lrc::api::call::Status::ENDED) {
// Call ended; close the notification
if (systemTray_->hideNotification(QString("%1;%2").arg(accountId).arg(convInfo.uid))
if (systemTray_->hideNotification(QString("%1;%2").arg(accountId, convInfo.uid))
&& call.startTime.time_since_epoch().count() == 0) {
// This was a missed call; show a missed call notification
auto convAvatar = Utils::conversationAvatar(lrcInstance_,
@ -146,11 +148,11 @@ CallAdapter::onCallStatusChanged(const QString& accountId, const QString& callId
accountId);
auto& accInfo = lrcInstance_->getAccountInfo(accountId);
auto from = accInfo.conversationModel->title(convInfo.uid);
auto notifId = QString("%1;%2").arg(accountId).arg(convInfo.uid);
auto notifId = QString("%1;%2").arg(accountId, convInfo.uid);
systemTray_->showNotification(notifId,
tr("Missed call"),
tr("Missed call with %1").arg(from),
NotificationType::CHAT,
SystemTray::NotificationType::CHAT,
Utils::QImageToByteArray(convAvatar));
}
}
@ -449,11 +451,11 @@ CallAdapter::showNotification(const QString& accountId, const QString& convUid)
#ifdef Q_OS_LINUX
auto convAvatar = Utils::conversationAvatar(lrcInstance_, convUid, QSize(50, 50), accountId);
auto notifId = QString("%1;%2").arg(accountId).arg(convUid);
auto notifId = QString("%1;%2").arg(accountId, convUid);
systemTray_->showNotification(notifId,
tr("Incoming call"),
tr("%1 is calling you").arg(title),
NotificationType::CALL,
SystemTray::NotificationType::CALL,
Utils::QImageToByteArray(convAvatar));
#else
auto onClicked = [this, accountId, convUid]() {
@ -544,7 +546,7 @@ CallAdapter::setActiveStream(const QString& uri, const QString& deviceId, const
auto participants = participantsModel.getParticipants();
decltype(participants) activeParticipants = {};
bool removeActive = false;
for (auto part : participants) {
for (const auto& part : participants) {
auto isParticipant = part.uri == uri && part.device == deviceId
&& part.sinkId == streamId;
if (part.active && !isParticipant)
@ -957,21 +959,21 @@ CallAdapter::updateAdvancedInformation()
bool
CallAdapter::takeScreenshot(const QImage& image, const QString& path)
{
QString name = QString("%1 %2")
.arg(tr("Screenshot"))
QString name = QString("%1 %2").arg(tr("Screenshot"),
#ifdef WIN32
.arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HHmmss"));
QDateTime::currentDateTime().toString("yyyy-MM-dd HHmmss")
#else
.arg(QDateTime::currentDateTime().toString(Qt::ISODate));
QDateTime::currentDateTime().toString(Qt::ISODate)
#endif
);
bool fileAlreadyExists = true;
int nb = 0;
QString filePath = QString("%1%2.png").arg(path).arg(name);
QString filePath = QString("%1%2.png").arg(path, name);
while (fileAlreadyExists) {
filePath = QString("%1%2.png").arg(path).arg(name);
filePath = QString("%1%2.png").arg(path, name);
if (nb)
filePath = QString("%1(%2).png").arg(filePath).arg(QString::number(nb));
filePath = QString("%1(%2).png").arg(filePath, QString::number(nb));
QFileInfo check_file(filePath);
fileAlreadyExists = check_file.exists() && check_file.isFile();
nb++;

View file

@ -76,7 +76,7 @@ class CallParticipantsModel : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(LayoutType conferenceLayout READ conferenceLayout NOTIFY layoutChanged)
Q_PROPERTY(LayoutType conferenceLayout READ conferenceLayout NOTIFY conferenceLayoutChanged)
QML_RO_PROPERTY(int, count)
public:
@ -98,18 +98,18 @@ public:
void setConferenceLayout(int layout, const QString& callId)
{
auto newLayout = static_cast<LayoutType>(layout);
if (callId == callId_ && newLayout != layout_) {
layout_ = newLayout;
Q_EMIT layoutChanged();
if (callId == callId_ && newLayout != conferenceLayout_) {
conferenceLayout_ = newLayout;
Q_EMIT conferenceLayoutChanged();
}
}
LayoutType conferenceLayout()
{
return layout_;
return conferenceLayout_;
}
Q_SIGNALS:
void layoutChanged();
void conferenceLayoutChanged();
private:
LRCInstance* lrcInstance_ {nullptr};
@ -117,5 +117,5 @@ private:
std::mutex participantsMtx_;
QList<CallParticipant::Item> participants_ {};
QString callId_;
LayoutType layout_;
LayoutType conferenceLayout_;
};

View file

@ -28,7 +28,10 @@ ContactAdapter::ContactAdapter(LRCInstance* instance, QObject* parent)
selectableProxyModel_.reset(new SelectableProxyModel(this));
if (lrcInstance_) {
connectSignals();
connect(lrcInstance_, &LRCInstance::currentAccountIdChanged, [this] { connectSignals(); });
connect(lrcInstance_,
&LRCInstance::currentAccountIdChanged,
this,
&ContactAdapter::connectSignals);
}
}
@ -246,20 +249,27 @@ ContactAdapter::removeContact(const QString& peerUri, bool banContact)
void
ContactAdapter::connectSignals()
{
if (lrcInstance_->getCurrentContactModel()) {
connect(lrcInstance_->getCurrentContactModel(),
&ContactModel::bannedStatusChanged,
this,
&ContactAdapter::bannedStatusChanged,
Qt::UniqueConnection);
connect(
lrcInstance_->getCurrentContactModel(),
if (!lrcInstance_->getCurrentContactModel()) {
qWarning() << Q_FUNC_INFO << "No contact model";
return;
}
connect(lrcInstance_->getCurrentContactModel(),
&ContactModel::bannedStatusChanged,
this,
&ContactAdapter::bannedStatusChanged,
Qt::UniqueConnection);
connect(lrcInstance_->getCurrentContactModel(),
&ContactModel::modelUpdated,
this,
[&](const auto& uri) {
// Refresh contacts shown
selectableProxyModel_->invalidate();
},
&ContactAdapter::onModelUpdated,
Qt::UniqueConnection);
}
}
void
ContactAdapter::onModelUpdated(const QString& uri)
{
Q_UNUSED(uri)
// Refresh contacts shown
selectableProxyModel_->invalidate();
}

View file

@ -95,6 +95,10 @@ public:
Q_SIGNALS:
void bannedStatusChanged(const QString& uri, bool banned);
void defaultModeratorsUpdated();
private Q_SLOTS:
void onModelUpdated(const QString& uri);
private:
SmartListModel::Type listModeltype_;
@ -105,7 +109,4 @@ private:
bool hasDifferentMembers(const VectorString& currentMembers,
const VectorString& convMembers) const;
Q_SIGNALS:
void defaultModeratorsUpdated();
};

View file

@ -85,18 +85,21 @@ ConversationsAdapter::ConversationsAdapter(SystemTray* systemTray,
// notification responses
connect(systemTray_,
&SystemTray::openConversationActivated,
this,
[this](const QString& accountId, const QString& convUid) {
Q_EMIT lrcInstance_->notificationClicked();
lrcInstance_->selectConversation(convUid, accountId);
});
connect(systemTray_,
&SystemTray::acceptPendingActivated,
this,
[this](const QString& accountId, const QString& convUid) {
auto& accInfo = lrcInstance_->getAccountInfo(accountId);
accInfo.conversationModel->acceptConversationRequest(convUid);
});
connect(systemTray_,
&SystemTray::refusePendingActivated,
this,
[this](const QString& accountId, const QString& convUid) {
auto& accInfo = lrcInstance_->getAccountInfo(accountId);
accInfo.conversationModel->removeConversation(convUid);
@ -178,11 +181,11 @@ ConversationsAdapter::onNewUnreadInteraction(const QString& accountId,
interaction.authorUri,
QSize(50, 50),
accountId);
auto notifId = QString("%1;%2;%3").arg(accountId).arg(convUid).arg(interactionId);
auto notifId = QString("%1;%2;%3").arg(accountId, convUid, interactionId);
systemTray_->showNotification(notifId,
tr("%1 received a new message").arg(to),
from + ": " + body_,
NotificationType::CHAT,
SystemTray::NotificationType::CHAT,
Utils::QImageToByteArray(contactPhoto));
#else
@ -207,7 +210,7 @@ ConversationsAdapter::onNewReadInteraction(const QString& accountId,
{
#ifdef Q_OS_LINUX
// hide notification
auto notifId = QString("%1;%2;%3").arg(accountId).arg(convUid).arg(interactionId);
auto notifId = QString("%1;%2;%3").arg(accountId, convUid, interactionId);
systemTray_->hideNotification(notifId);
#else
Q_UNUSED(accountId)
@ -238,11 +241,11 @@ ConversationsAdapter::onNewTrustRequest(const QString& accountId,
if (preferences["ignoreNotifications"] == "true")
return;
auto contactPhoto = Utils::contactPhoto(lrcInstance_, peerUri, QSize(50, 50), accountId);
auto notifId = QString("%1;%2").arg(accountId).arg(conv);
auto notifId = QString("%1;%2").arg(accountId, conv);
systemTray_->showNotification(notifId,
tr("%1 received a new trust request").arg(to),
"New request from " + from,
NotificationType::REQUEST,
SystemTray::NotificationType::REQUEST,
Utils::QImageToByteArray(contactPhoto));
}
#else
@ -257,7 +260,7 @@ ConversationsAdapter::onTrustRequestTreated(const QString& accountId, const QStr
{
#ifdef Q_OS_LINUX
// hide notification
auto notifId = QString("%1;%2").arg(accountId).arg(peerUri);
auto notifId = QString("%1;%2").arg(accountId, peerUri);
systemTray_->hideNotification(notifId);
#else
Q_UNUSED(accountId)

View file

@ -37,19 +37,12 @@ CurrentAccount::CurrentAccount(LRCInstance* lrcInstance,
this,
&CurrentAccount::onAccountUpdated);
connect(lrcInstance_->getCurrentContactModel(),
&ContactModel::bannedStatusChanged,
connect(lrcInstance_,
&LRCInstance::currentAccountIdChanged,
this,
[&](const auto&, auto) {
set_hasBannedContacts(
lrcInstance_->getCurrentAccountInfo().contactModel->getBannedContacts().size());
},
Qt::UniqueConnection);
&CurrentAccount::setupForAccount);
connect(lrcInstance_, &LRCInstance::currentAccountIdChanged, [this] { updateData(); });
updateData();
setupForAccount();
}
void
@ -94,6 +87,17 @@ CurrentAccount::get_isLocalModeratorsEnabled()
return isLocalModeratorsEnabled_;
}
void
CurrentAccount::setupForAccount()
{
connect(lrcInstance_->getCurrentContactModel(),
&ContactModel::bannedStatusChanged,
this,
&CurrentAccount::onBannedStatusChanged,
Qt::UniqueConnection);
updateData();
}
void
CurrentAccount::onAccountUpdated(const QString& id)
{
@ -103,6 +107,15 @@ CurrentAccount::onAccountUpdated(const QString& id)
updateData();
}
void
CurrentAccount::onBannedStatusChanged(const QString& contactUri, bool banned)
{
Q_UNUSED(contactUri)
Q_UNUSED(banned)
set_hasBannedContacts(
lrcInstance_->getCurrentAccountInfo().contactModel->getBannedContacts().size());
}
void
CurrentAccount::updateData()
{

View file

@ -211,7 +211,9 @@ Q_SIGNALS:
private Q_SLOTS:
void updateData();
void setupForAccount();
void onAccountUpdated(const QString& id);
void onBannedStatusChanged(const QString& contactUri, bool banned);
private:
bool isAllModeratorsEnabled_;

View file

@ -33,7 +33,7 @@ DBusErrorHandler::errorCallback()
Q_EMIT showDaemonReconnectPopup(true);
QTimer::singleShot(2500, [this]() {
QTimer::singleShot(2500, this, [this]() {
if ((!lrc::api::Lrc::isConnected()) || (!lrc::api::Lrc::dbusIsValid())) {
qDebug() << "Could not reconnect to the daemon";
Q_EMIT daemonReconnectFailed();

View file

@ -21,23 +21,23 @@
#pragma once
namespace JamiAvatarTheme {
static const QColor defaultAvatarColor_ = {"#ff9e9e9e"}; // Grey
static const QColor defaultAvatarColor_ = {0x9e, 0x9e, 0x9e}; // Grey
static const QColor avatarColors_[] {
{"#fff44336"}, // Red
{"#ffe91e63"}, // Pink
{"#ff9c27b0"}, // Purple
{"#ff673ab7"}, // Deep Purple
{"#ff3f51b5"}, // Indigo
{"#ff2196f3"}, // Blue
{"#ff00bcd4"}, // Cyan
{"#ff009688"}, // Teal
{"#ff4caf50"}, // Green
{"#ff8bc34a"}, // Light Green
{"#ff9e9e9e"}, // Grey
{"#ffcddc39"}, // Lime
{"#ffffc107"}, // Amber
{"#ffff5722"}, // Deep Orange
{"#ff795548"}, // Brown
{"#ff607d8b"} // Blue Grey
{0xf4, 0x43, 0x24}, // Red
{0xe9, 0x1e, 0x63}, // Pink
{0x9c, 0x27, 0xb0}, // Purple
{0x67, 0x3a, 0xb7}, // Deep Purple
{0x3f, 0x51, 0xb5}, // Indigo
{0x21, 0x96, 0xf3}, // Blue
{0x00, 0xbc, 0xd4}, // Cyan
{0x00, 0x96, 0x88}, // Teal
{0x4c, 0xaf, 0x50}, // Green
{0x8b, 0xc3, 0x4a}, // Light Green
{0x9e, 0x9e, 0x9e}, // Grey
{0xcd, 0xdc, 0x39}, // Lime
{0xff, 0xc1, 0x07}, // Amber
{0xff, 0x57, 0x22}, // Deep Orange
{0x79, 0x55, 0x48}, // Brown
{0x60, 0x7d, 0x8b} // Blue Grey
};
} // namespace JamiAvatarTheme

View file

@ -58,7 +58,7 @@ LRCInstance::LRCInstance(migrateCallback willMigrateCb,
set_currentAccountAvatarSet(!profileInfo.avatar.isEmpty());
});
connect(&accountModel(), &AccountModel::profileUpdated, [this](const QString& id) {
connect(&accountModel(), &AccountModel::profileUpdated, this, [this](const QString& id) {
if (id != currentAccountId_)
return;

View file

@ -78,22 +78,33 @@ ScreenInfo::setCurrentFocusWindow(QWindow* window)
currentFocusWindow_ = window;
set_devicePixelRatio(currentFocusWindow_->screen()->devicePixelRatio());
disconnect(devicePixelRatioConnection_);
disconnect(currentFocusWindowScreenConnection_);
currentFocusWindowScreenConnection_
= connect(currentFocusWindow_, &QWindow::screenChanged, [this] {
currentFocusWindowScreen_ = currentFocusWindow_->screen();
set_devicePixelRatio(currentFocusWindowScreen_->devicePixelRatio());
devicePixelRatioConnection_ = connect(
currentFocusWindowScreen_, &QScreen::physicalDotsPerInchChanged, [this] {
set_devicePixelRatio(currentFocusWindowScreen_->devicePixelRatio());
});
});
QObject::connect(currentFocusWindow_,
&QWindow::screenChanged,
this,
&ScreenInfo::onScreenChanged,
Qt::UniqueConnection);
}
}
void
ScreenInfo::onScreenChanged()
{
currentFocusWindowScreen_ = currentFocusWindow_->screen();
set_devicePixelRatio(currentFocusWindowScreen_->devicePixelRatio());
QObject::connect(currentFocusWindowScreen_,
&QScreen::physicalDotsPerInchChanged,
this,
&ScreenInfo::onPhysicalDotsPerInchChanged,
Qt::UniqueConnection);
}
void
ScreenInfo::onPhysicalDotsPerInchChanged()
{
set_devicePixelRatio(currentFocusWindowScreen_->devicePixelRatio());
}
MainApplication::MainApplication(int& argc, char** argv)
: QApplication(argc, argv)
{
@ -170,7 +181,7 @@ MainApplication::init()
lrcInstance_.get(),
&LRCInstance::quitEngineRequested,
this,
[this] { engine_->quit(); },
[this] { Q_EMIT engine_->quit(); },
Qt::DirectConnection);
auto downloadPath = settingsManager_->getValue(Settings::Key::DownloadPath);

View file

@ -46,10 +46,11 @@ class ScreenInfo : public QObject
public:
void setCurrentFocusWindow(QWindow* window);
private:
QMetaObject::Connection currentFocusWindowScreenConnection_;
QMetaObject::Connection devicePixelRatioConnection_;
private Q_SLOTS:
void onScreenChanged();
void onPhysicalDotsPerInchChanged();
private:
QWindow* currentFocusWindow_ {nullptr};
QScreen* currentFocusWindowScreen_ {nullptr};
};

View file

@ -223,9 +223,9 @@ Popup {
model: PreferenceItemListModel {
id: handlerPickerPrefsModel
lrcInstance: LRCInstance
accountId_: LRCInstance.currentAccountId
mediaHandlerName_: handlerName
pluginId_: pluginId
accountId: LRCInstance.currentAccountId
mediaHandlerName: handlerName
pluginId: root.pluginId
}
delegate: PreferenceItemDelegate {
@ -248,7 +248,7 @@ Popup {
lrcInstance: LRCInstance
preferenceKey: PreferenceKey
accountId_: LRCInstance.currentAccountId
accountId: LRCInstance.currentAccountId
pluginId: PluginId
}

View file

@ -21,10 +21,7 @@
#include "lrcinstance.h"
#include "api/account.h"
#include "api/contact.h"
#include "api/conversation.h"
#include "api/codecmodel.h"
#include "api/devicemodel.h"
MediaCodecListModel::MediaCodecListModel(QObject* parent)
: AbstractListModelBase(parent)
@ -50,7 +47,7 @@ MediaCodecListModel::rowCount(const QModelIndex& parent) const
auto videoCodecListOld = lrcInstance_->getCurrentAccountInfo()
.codecModel->getVideoCodecs();
for (auto codec : videoCodecListOld) {
for (const auto& codec : videoCodecListOld) {
if (codec.name.length()) {
realCodecList.append(codec);
}
@ -62,16 +59,6 @@ MediaCodecListModel::rowCount(const QModelIndex& parent) const
return 0;
}
int
MediaCodecListModel::columnCount(const QModelIndex& parent) const
{
Q_UNUSED(parent);
/*
* Only need one column.
*/
return 1;
}
QVariant
MediaCodecListModel::data(const QModelIndex& index, int role) const
{
@ -82,7 +69,7 @@ MediaCodecListModel::data(const QModelIndex& index, int role) const
QList<lrc::api::Codec> videoCodecList = lrcInstance_->getCurrentAccountInfo()
.codecModel->getVideoCodecs();
for (auto codec : videoCodecList) {
for (const auto& codec : videoCodecList) {
if (codec.name.length()) {
mediaCodecList.append(codec);
}
@ -130,13 +117,6 @@ MediaCodecListModel::index(int row, int column, const QModelIndex& parent) const
return QModelIndex();
}
QModelIndex
MediaCodecListModel::parent(const QModelIndex& child) const
{
Q_UNUSED(child);
return QModelIndex();
}
Qt::ItemFlags
MediaCodecListModel::flags(const QModelIndex& index) const
{
@ -164,5 +144,8 @@ MediaCodecListModel::mediaType()
void
MediaCodecListModel::setMediaType(int mediaType)
{
mediaType_ = mediaType;
if (mediaType_ != mediaType) {
mediaType_ = mediaType;
Q_EMIT mediaTypeChanged();
}
}

View file

@ -23,7 +23,7 @@
class MediaCodecListModel : public AbstractListModelBase
{
Q_OBJECT
Q_PROPERTY(int mediaType READ mediaType WRITE setMediaType)
Q_PROPERTY(int mediaType READ mediaType WRITE setMediaType NOTIFY mediaTypeChanged)
public:
enum MediaType { VIDEO, AUDIO };
enum Role { MediaCodecName = Qt::UserRole + 1, IsEnabled, MediaCodecID, Samplerate };
@ -32,25 +32,23 @@ public:
explicit MediaCodecListModel(QObject* parent = nullptr);
~MediaCodecListModel();
/*
* QAbstractListModel override.
*/
// QAbstractListModel override.
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
int columnCount(const QModelIndex& parent) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
/*
* Override role name as access point in qml.
*/
QHash<int, QByteArray> roleNames() const override;
QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex& child) const;
Qt::ItemFlags flags(const QModelIndex& index) const;
QModelIndex index(int row,
int column = 0,
const QModelIndex& parent = QModelIndex()) const override;
Qt::ItemFlags flags(const QModelIndex& index) const override;
Q_INVOKABLE void reset();
int mediaType();
void setMediaType(int mediaType);
Q_SIGNALS:
void mediaTypeChanged();
private:
int mediaType_;
};

View file

@ -341,8 +341,8 @@ MessagesAdapter::onPaste()
// Extract the local paths of the files.
for (int i = 0; i < urlList.size(); ++i) {
// Trim file:// or file:/// from url.
QString filePath = urlList.at(i).toString().remove(
QRegularExpression("^file:\\/{2,3}"));
const static QRegularExpression fileSchemeRe("^file:\\/{2,3}");
QString filePath = urlList.at(i).toString().remove(fileSchemeRe);
Q_EMIT newFilePasted(filePath);
}
} else {
@ -658,7 +658,8 @@ MessagesAdapter::getMediaInfo(const QString& msg)
}
static const QRegExp vPattern("(video/)(avi|mov|webm|webp|rmvb)$", Qt::CaseInsensitive);
vPattern.indexIn(mime.name());
QString type = vPattern.capturedTexts().size() == 3 ? vPattern.capturedTexts()[1] : "";
auto captured = vPattern.capturedTexts();
QString type = captured.size() == 3 ? captured[1] : "";
if (!type.isEmpty()) {
return {
{"isVideo", true},
@ -668,7 +669,8 @@ MessagesAdapter::getMediaInfo(const QString& msg)
} else {
static const QRegExp aPattern("(audio/)(ogg|flac|wav|mpeg|mp3)$", Qt::CaseInsensitive);
aPattern.indexIn(mime.name());
type = aPattern.capturedTexts().size() == 3 ? aPattern.capturedTexts()[1] : "";
captured = aPattern.capturedTexts();
type = captured.size() == 3 ? captured[1] : "";
if (!type.isEmpty()) {
return {
{"isVideo", false},
@ -684,9 +686,10 @@ bool
MessagesAdapter::isRemoteImage(const QString& msg)
{
// TODO: test if all these open in the AnimatedImage component
QRegularExpression pattern("[^\\s]+(.*?)\\.(jpg|jpeg|png|gif|apng|webp|avif|flif)$",
QRegularExpression::CaseInsensitiveOption);
QRegularExpressionMatch match = pattern.match(msg);
const static QRegularExpression
imageRe("[^\\s]+(.*?)\\.(jpg|jpeg|png|gif|apng|webp|avif|flif)$",
QRegularExpression::CaseInsensitiveOption);
QRegularExpressionMatch match = imageRe.match(msg);
return match.hasMatch();
}

View file

@ -114,7 +114,7 @@ PluginListModel::addPlugin()
return;
int index = 0;
for (auto item : newList) {
for (const auto& item : newList) {
if (installedPlugins_.indexOf(item) == -1)
break;
index++;
@ -126,17 +126,19 @@ PluginListModel::addPlugin()
}
void
PluginListModel::filterPlugins(VectorString& list)
PluginListModel::filterPlugins(VectorString& list) const
{
if (!lrcInstance_ || !filterAccount_)
return;
for (auto it = list.begin(); it != list.end();) {
auto prefs = lrcInstance_->pluginModel()
.getPluginPreferences(*it, lrcInstance_->get_currentAccountId());
if (prefs.empty()) {
it = list.erase(it);
} else
it++;
}
const auto accountId = lrcInstance_->get_currentAccountId();
list.erase(std::remove_if(list.begin(), // clazy:exclude=strict-iterators
list.end(),
[&](const QString& pluginName) -> bool {
const auto prefs = lrcInstance_->pluginModel()
.getPluginPreferences(pluginName,
accountId);
return prefs.empty();
}),
list.cend());
}

View file

@ -53,6 +53,6 @@ public:
Q_INVOKABLE void addPlugin();
private:
void filterPlugins(VectorString& list);
void filterPlugins(VectorString& list) const;
VectorString installedPlugins_ {};
};

View file

@ -36,8 +36,8 @@ PluginListPreferenceModel::populateLists()
if (pluginId_.isEmpty())
return;
auto preferences = lrcInstance_->pluginModel().getPluginPreferences(pluginId_, "");
if (!accountId__.isEmpty())
preferences.append(lrcInstance_->pluginModel().getPluginPreferences(pluginId_, accountId__));
if (!accountId_.isEmpty())
preferences.append(lrcInstance_->pluginModel().getPluginPreferences(pluginId_, accountId_));
for (const auto& preference : preferences) {
if (preference["key"] == preferenceKey_) {
if (preference.find("entries") != preference.end()
@ -61,14 +61,6 @@ PluginListPreferenceModel::rowCount(const QModelIndex& parent) const
return 0;
}
int
PluginListPreferenceModel::columnCount(const QModelIndex& parent) const
{
Q_UNUSED(parent);
/// Only need one column.
return 1;
}
QVariant
PluginListPreferenceModel::data(const QModelIndex& index, int role) const
{

View file

@ -25,11 +25,12 @@
class PluginListPreferenceModel : public AbstractListModelBase
{
Q_OBJECT
Q_PROPERTY(QString preferenceNewValue READ preferenceNewValue WRITE setPreferenceNewValue)
Q_PROPERTY(QString pluginId READ pluginId WRITE setPluginId)
Q_PROPERTY(QString preferenceNewValue READ preferenceNewValue WRITE setPreferenceNewValue NOTIFY
preferenceNewValueChanged)
Q_PROPERTY(QString pluginId READ pluginId WRITE setPluginId NOTIFY pluginIdChanged)
QML_PROPERTY(QString, preferenceKey)
QML_PROPERTY(int, idx)
QML_PROPERTY(QString, accountId_)
QML_PROPERTY(QString, accountId)
public:
enum Role { PreferenceValue = Qt::UserRole + 1, PreferenceEntryValue };
Q_ENUM(Role)
@ -37,43 +38,40 @@ public:
explicit PluginListPreferenceModel(QObject* parent = nullptr);
~PluginListPreferenceModel();
/*
* QAbstractListModel override.
*/
// QAbstractListModel override.
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
int columnCount(const QModelIndex& parent) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
/*
* Override role name as access point in qml.
*/
QHash<int, QByteArray> roleNames() const override;
/*
* This function is to reset the model when there's new account added.
*/
// This function is to reset the model when there's new account added.
Q_INVOKABLE void reset();
/*
* This function is to get the current preference value
*/
// This function is to get the current preference value.
Q_INVOKABLE int getCurrentSettingIndex();
Q_INVOKABLE void populateLists();
void setPreferenceNewValue(const QString preferenceNewValue)
{
preferenceNewValue_ = preferenceNewValue;
if (preferenceNewValue_ != preferenceNewValue) {
preferenceNewValue_ = preferenceNewValue;
Q_EMIT preferenceNewValueChanged();
}
}
void setPluginId(const QString pluginId)
{
pluginId_ = pluginId;
populateLists();
if (pluginId_ != pluginId) {
pluginId_ = pluginId;
populateLists();
Q_EMIT pluginIdChanged();
}
}
QString preferenceCurrentValue()
{
return lrcInstance_->pluginModel().getPluginPreferencesValues(pluginId_,
accountId__)[preferenceKey_];
accountId_)[preferenceKey_];
}
QString preferenceNewValue()
@ -87,9 +85,13 @@ public:
return pluginId_;
}
Q_SIGNALS:
void preferenceNewValueChanged();
void pluginIdChanged();
private:
QString pluginId_ = "";
QString preferenceNewValue_ = "";
QString pluginId_ {};
QString preferenceNewValue_ {};
QStringList preferenceValuesList_;
QStringList preferenceList_;
};

View file

@ -95,21 +95,19 @@ PositionManager::isConvSharingPosition(const QString& accountId, const QString&
void
PositionManager::loadPreviousLocations(QString& accountId)
{
QVariantMap shareInfo;
for (auto it = objectListSharingUris_.begin(); it != objectListSharingUris_.end(); it++) {
if (it.key().first == accountId) {
QJsonObject jsonObj;
jsonObj.insert("type", QJsonValue("Position"));
jsonObj.insert("lat", it.value()->getLatitude().toString());
jsonObj.insert("long", it.value()->getLongitude().toString());
QJsonDocument doc(jsonObj);
QString strJson(doc.toJson(QJsonDocument::Compact));
// parse the position from json
QVariantMap positionReceived = parseJsonPosition(it.key().first,
it.key().second,
strJson);
addPositionToMap(it.key(), positionReceived);
if (it.key().first != accountId) {
continue;
}
QJsonObject jsonObj;
jsonObj.insert("type", QJsonValue("Position"));
jsonObj.insert("lat", it.value()->getLatitude().toString());
jsonObj.insert("long", it.value()->getLongitude().toString());
QJsonDocument doc(jsonObj);
QString strJson(doc.toJson(QJsonDocument::Compact));
// parse the position from json
QVariantMap positionReceived = parseJsonPosition(it.key().first, it.key().second, strJson);
addPositionToMap(it.key(), positionReceived);
}
}
@ -177,7 +175,7 @@ PositionManager::onWatchdogTimeout()
if (it != objectListSharingUris_.cend()) {
QString stopMsg("{\"type\":\"Stop\"}");
onPositionReceived(it.key().first, it.key().second, stopMsg, -1, "");
makeVisibleSharingButton(it.key().first);
Q_EMIT makeVisibleSharingButton(it.key().first);
}
}
@ -211,9 +209,10 @@ PositionManager::stopSharingPosition(QString accountId, const QString convId)
key = qMakePair(accountId, it->second);
stopPositionTimers(key);
sendStopMessage(accountId, it->second);
it = positionShareConvIds_.erase(it);
} else
it = positionShareConvIds_.erase(it); // clazy:exclude=strict-iterators
} else {
++it;
}
}
} else {
stopPositionTimers(key);
@ -313,7 +312,6 @@ PositionManager::setMapActive(QString key)
QString
PositionManager::getAvatar(const QString& accountId, const QString& uri)
{
QString avatarBase64;
QByteArray ba;
QBuffer bu(&ba);
@ -373,8 +371,8 @@ PositionManager::stopPositionTimers(PositionKey key)
if (key == PositionKey()) {
mapTimerCountDown_.clear();
} else {
auto it = mapTimerCountDown_.find(key);
if (it != mapTimerCountDown_.end()) {
auto it = mapTimerCountDown_.constFind(key);
if (it != mapTimerCountDown_.cend()) {
mapTimerCountDown_.erase(it);
}
if (!mapTimerCountDown_.size())
@ -409,11 +407,11 @@ PositionManager::showNotification(const QString& accountId,
auto body = tr("%1 is sharing their location").arg(bestName);
#ifdef Q_OS_LINUX
auto contactPhoto = Utils::contactPhoto(lrcInstance_, from, QSize(50, 50), accountId);
auto notifId = QString("%1;%2;%3").arg(accountId).arg(convId).arg(from);
auto notifId = QString("%1;%2;%3").arg(accountId, convId, from);
systemTray_->showNotification(notifId,
tr("Location sharing"),
body,
NotificationType::CHAT,
SystemTray::NotificationType::CHAT,
Utils::QImageToByteArray(contactPhoto));
#else
@ -441,7 +439,7 @@ PositionManager::onNewAccount()
for (auto it = mapStatus_.begin(); it != mapStatus_.end();) {
if (it.value() == false) {
Q_EMIT closeMap(it.key());
it = mapStatus_.erase(it);
it = mapStatus_.erase(it); // clazy:exclude=strict-iterators
Q_EMIT mapStatusChanged();
} else {
it++;
@ -564,8 +562,8 @@ void
PositionManager::removePositionFromMemory(PositionKey key, QVariantMap positionReceived)
{
// Remove
auto it = objectListSharingUris_.find(key);
if (it != objectListSharingUris_.end()) {
auto it = objectListSharingUris_.constFind(key);
if (it != objectListSharingUris_.cend()) {
// free memory
it.value()->deleteLater();
// delete value
@ -596,7 +594,8 @@ PositionManager::onPositionReceived(const QString& accountId,
const uint64_t& timestamp,
const QString& daemonId)
{
// handlers variables
Q_UNUSED(timestamp)
Q_UNUSED(daemonId)
// parse the position from json
QVariantMap positionReceived = parseJsonPosition(accountId, peerId, body);

View file

@ -48,14 +48,6 @@ PreferenceItemListModel::rowCount(const QModelIndex& parent) const
return 0;
}
int
PreferenceItemListModel::columnCount(const QModelIndex& parent) const
{
Q_UNUSED(parent);
/// Only need one column.
return 1;
}
QVariant
PreferenceItemListModel::data(const QModelIndex& index, int role) const
{
@ -71,7 +63,7 @@ PreferenceItemListModel::data(const QModelIndex& index, int role) const
auto details = preferenceList_.at(index.row());
preferenceCurrent = lrcInstance_->pluginModel()
.getPluginPreferencesValues(pluginId__, accountId__)[details["key"]];
.getPluginPreferencesValues(pluginId_, accountId_)[details["key"]];
auto it = mapType.find(details["type"]);
if (it != mapType.end()) {
type = mapType[details["type"]];
@ -88,10 +80,9 @@ PreferenceItemListModel::data(const QModelIndex& index, int role) const
}
}
const auto dependsOn = details["dependsOn"].split(",");
const auto preferences = lrcInstance_->pluginModel().getPluginPreferences(pluginId__,
accountId__);
const auto prefValues = lrcInstance_->pluginModel().getPluginPreferencesValues(pluginId__,
accountId__);
const auto preferences = lrcInstance_->pluginModel().getPluginPreferences(pluginId_, accountId_);
const auto prefValues = lrcInstance_->pluginModel().getPluginPreferencesValues(pluginId_,
accountId_);
bool enabled = true;
for (auto& preference : preferences) {
auto key = preference["key"];
@ -119,7 +110,7 @@ PreferenceItemListModel::data(const QModelIndex& index, int role) const
case Role::PreferenceType:
return QVariant(type);
case Role::PluginId:
return QVariant(pluginId__);
return QVariant(pluginId_);
case Role::PreferenceCurrentValue:
return QVariant(preferenceCurrent);
case Role::CurrentPath:
@ -162,19 +153,23 @@ PreferenceItemListModel::reset()
}
QString
PreferenceItemListModel::pluginId_() const
PreferenceItemListModel::pluginId() const
{
return pluginId__;
return pluginId_;
}
void
PreferenceItemListModel::setPluginId(const QString& pluginId)
{
beginResetModel();
pluginId__ = pluginId;
preferenceList_.clear();
preferencesCount();
endResetModel();
if (pluginId_ != pluginId) {
beginResetModel();
pluginId_ = pluginId;
preferenceList_.clear();
preferencesCount();
endResetModel();
Q_EMIT pluginIdChanged();
}
}
int
@ -182,23 +177,22 @@ PreferenceItemListModel::preferencesCount()
{
if (!preferenceList_.isEmpty())
return preferenceList_.size();
if (mediaHandlerName__.isEmpty()) {
auto preferences = lrcInstance_->pluginModel().getPluginPreferences(pluginId__, accountId__);
if (category__ != "all")
if (mediaHandlerName_.isEmpty()) {
auto preferences = lrcInstance_->pluginModel().getPluginPreferences(pluginId_, accountId_);
if (category_ != "all")
for (auto& preference : preferences) {
if (preference["category"] == category__)
if (preference["category"] == category_)
preferenceList_.push_back(preference);
}
else
preferenceList_ = preferences;
return preferenceList_.size();
} else {
auto preferences = lrcInstance_->pluginModel().getPluginPreferences(pluginId__, "");
preferences.append(
lrcInstance_->pluginModel().getPluginPreferences(pluginId__, accountId__));
auto preferences = lrcInstance_->pluginModel().getPluginPreferences(pluginId_, "");
preferences.append(lrcInstance_->pluginModel().getPluginPreferences(pluginId_, accountId_));
for (auto& preference : preferences) {
QStringList scopeList = preference["scope"].split(",");
if (scopeList.contains(mediaHandlerName__))
if (scopeList.contains(mediaHandlerName_))
preferenceList_.push_back(preference);
}
return preferenceList_.size();

View file

@ -26,10 +26,10 @@ class PreferenceItemListModel : public AbstractListModelBase
{
Q_OBJECT
Q_PROPERTY(QString pluginId_ READ pluginId_ WRITE setPluginId)
QML_PROPERTY(QString, category_)
QML_PROPERTY(QString, mediaHandlerName_)
QML_PROPERTY(QString, accountId_)
Q_PROPERTY(QString pluginId READ pluginId WRITE setPluginId NOTIFY pluginIdChanged)
QML_PROPERTY(QString, category)
QML_PROPERTY(QString, mediaHandlerName)
QML_PROPERTY(QString, accountId)
public:
enum Role {
PreferenceKey = Qt::UserRole + 1,
@ -58,28 +58,23 @@ public:
explicit PreferenceItemListModel(QObject* parent = nullptr);
~PreferenceItemListModel();
/*
* QAbstractListModel override.
*/
// QAbstractListModel override.
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
int columnCount(const QModelIndex& parent) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
/*
* Override role name as access point in qml.
*/
QHash<int, QByteArray> roleNames() const override;
/*
* This function is to reset the model when there's new plugin added or modified.
*/
// This function is to reset the model when there's new plugin added or modified.
Q_INVOKABLE void reset();
QString pluginId_() const;
QString pluginId() const;
void setPluginId(const QString& pluginId);
Q_SIGNALS:
void pluginIdChanged();
private:
int preferencesCount();
QString pluginId__;
QString pluginId_;
VectorMapStringString preferenceList_;
};

View file

@ -117,6 +117,8 @@ ItemDelegate {
PluginPreferencesView {
id: pluginPreferencesView
pluginId: root.pluginId
Layout.fillWidth: true
Layout.leftMargin: JamiTheme.preferredMarginSize
Layout.rightMargin: JamiTheme.preferredMarginSize

View file

@ -27,6 +27,8 @@ Rectangle {
id: root
property string accountId: ""
required property string pluginId
property int count: pluginPreferenceView.count + pluginPreferenceViewCategory.count
implicitHeight: childrenRect.height
@ -127,7 +129,7 @@ Rectangle {
visible: categories.length % 2 === 1
text: categories[categories.length - 1]
highlighted: category === text
highlighted: root.category === text
onClicked: {
root.category = oddCategoryButton.text;
@ -158,11 +160,11 @@ Rectangle {
model: PreferenceItemListModel {
id: preferencesPerCategoryModel
lrcInstance: LRCInstance
category_: category
accountId_: accountId
pluginId_: pluginId
category: root.category
accountId: root.accountId
pluginId: root.pluginId
onCategory_Changed: {
onCategoryChanged: {
this.reset();
}
}
@ -189,7 +191,7 @@ Rectangle {
lrcInstance: LRCInstance
preferenceKey: PreferenceKey
accountId_: accountId
accountId: root.accountId
pluginId: PluginId
}
@ -217,11 +219,11 @@ Rectangle {
model: PreferenceItemListModel {
id: generalPreferencesModel
lrcInstance: LRCInstance
category_: generalCategory
accountId_: accountId
pluginId_: pluginId
category: generalCategory
accountId: root.accountId
pluginId: root.pluginId
onCategory_Changed: {
onCategoryChanged: {
this.reset();
}
}
@ -248,7 +250,7 @@ Rectangle {
lrcInstance: LRCInstance
preferenceKey: PreferenceKey
accountId_: accountId
accountId: root.accountId
pluginId: PluginId
}

View file

@ -26,6 +26,8 @@ import "../../commoncomponents"
Rectangle {
id: root
required property string pluginId
color: "transparent"
visible: false
@ -104,6 +106,7 @@ Rectangle {
id: pluginGeneralSettingsView
visible: false
Layout.fillWidth: true
pluginId: root.pluginId
}
RowLayout {
@ -147,6 +150,7 @@ Rectangle {
visible: false
Layout.fillWidth: true
accountId: LRCInstance.currentAccountId
pluginId: root.pluginId
}
MaterialButton {

View file

@ -107,10 +107,7 @@ SystemTray::SystemTray(AppSettingsManager* settingsManager, QObject* parent)
if (notify_get_server_info(&name, &vendor, &version, &spec)) {
qDebug() << QString("notify server name: %1, vendor: %2, version: %3, spec: %4")
.arg(name)
.arg(vendor)
.arg(version)
.arg(spec);
.arg(name, vendor, version, spec);
}
// check notify server capabilities

View file

@ -22,11 +22,6 @@
#include <functional>
#ifdef Q_OS_LINUX
enum class NotificationType { INVALID, CALL, REQUEST, CHAT };
Q_ENUMS(NotificationType)
#endif // Q_OS_LINUX
class AppSettingsManager;
class SystemTray final : public QSystemTrayIcon
@ -34,6 +29,11 @@ class SystemTray final : public QSystemTrayIcon
Q_OBJECT
public:
#ifdef Q_OS_LINUX
enum NotificationType {INVALID, CALL, REQUEST, CHAT};
Q_ENUM(NotificationType)
#endif // Q_OS_LINUX
explicit SystemTray(AppSettingsManager* settingsManager, QObject* parent = nullptr);
~SystemTray();

View file

@ -480,7 +480,6 @@ Utils::conversationAvatar(LRCInstance* instance,
return avatar;
}
// Else, combine avatars
auto idx = 0;
auto peerAAvatar = getPhoto(members[0]);
auto peerBAvatar = getPhoto(members[1]);
peerAAvatar = Utils::halfCrop(peerAAvatar, true);
@ -712,7 +711,8 @@ Utils::fallbackAvatar(const QString& canonicalUri, const QString& name, const QS
// if a letter was passed, then we paint a letter in the circle,
// otherwise we draw the default avatar icon
QString trimmedName(name);
if (!trimmedName.remove(QRegularExpression("[\\n\\t\\r]")).isEmpty()) {
const static QRegularExpression newlineRe("[\\n\\t\\r]");
if (!trimmedName.remove(newlineRe).isEmpty()) {
auto unicode = trimmedName.toUcs4().at(0);
if (unicode >= 0x1F000 && unicode <= 0x1FFFF) {
// emoticon

View file

@ -132,15 +132,13 @@ const QString
UtilsAdapter::getStyleSheet(const QString& name, const QString& source)
{
auto simplifiedCSS = source.simplified().replace("'", "\"");
QString s = QString::fromLatin1("(function() {"
" var node = document.createElement('style');"
" node.id = '%1';"
" node.innerHTML = '%2';"
" document.head.appendChild(node);"
"})()")
.arg(name)
.arg(simplifiedCSS);
return s;
static auto baseScript = QString::fromLatin1("(function() {"
" var node = document.createElement('style');"
" node.id = '%1';"
" node.innerHTML = '%2';"
" document.head.appendChild(node);"
"})()");
return baseScript.arg(name, simplifiedCSS);
}
const QString
@ -315,20 +313,6 @@ UtilsAdapter::getCallStatusStr(int statusInt)
return lrc::api::call::to_string(status);
}
// returns true if name is valid registered name
bool
UtilsAdapter::validateRegNameForm(const QString& regName)
{
QRegularExpression regExp(" ");
if (regName.size() > 2 && !regName.contains(regExp)) {
return true;
} else {
return false;
}
}
QString
UtilsAdapter::getStringUTF8(QString string)
{
@ -377,15 +361,14 @@ UtilsAdapter::toFileAbsolutepath(QString inputFileName)
QString
UtilsAdapter::getAbsPath(QString path)
{
static auto fileSchemeRe = QRegularExpression("^file:\\/{2,3}");
// Note: this function is used on urls returned from qml-FileDialogs which
// contain 'file:///' for reasons we don't understand.
// TODO: this logic can be refactored into the JamiFileDialog component.
#ifdef Q_OS_WIN
return path.replace(QRegularExpression("^file:\\/{2,3}"), "").replace("\n", "").replace("\r", "");
return path.replace(fileSchemeRe, "").replace("\n", "").replace("\r", "");
#else
return path.replace(QRegularExpression("^file:\\/{2,3}"), "/")
.replace("\n", "")
.replace("\r", "");
return path.replace(fileSchemeRe, "/").replace("\n", "").replace("\r", "");
#endif
}
@ -508,6 +491,7 @@ UtilsAdapter::monitor(const bool& continuous)
debugMessageReceivedConnection_
= QObject::connect(&lrcInstance_->behaviorController(),
&lrc::api::BehaviorController::debugMessageReceived,
this,
[this](const QString& data) {
logList_.append(data);
if (logList_.size() >= LOGSLIMIT) {
@ -549,15 +533,15 @@ UtilsAdapter::supportedLang()
QRegExp regex("jami_client_qt_(.*).qm");
QSet<QString> nativeNames;
for (const auto& f : trFiles) {
auto match = regex.indexIn(f);
if (regex.capturedTexts().size() == 2) {
auto l = regex.capturedTexts()[1];
auto nativeName = QLocale(l).nativeLanguageName();
regex.indexIn(f);
auto captured = regex.capturedTexts();
if (captured.size() == 2) {
auto nativeName = QLocale(captured[1]).nativeLanguageName();
if (nativeName.isEmpty()) // If a locale doesn't have any nativeLanguageName, ignore it.
continue;
// Avoid to show potential duplicates.
if (!nativeNames.contains(nativeName)) {
result[l] = nativeName;
result[captured[1]] = nativeName;
nativeNames.insert(nativeName);
}
}
@ -817,4 +801,4 @@ UtilsAdapter::isRTL()
auto pref = getAppValue(Settings::Key::LANG).toString();
pref == "SYSTEM" ? QLocale::system().name() : pref;
return pref == "ar" || pref == "he" || pref == "fa" || pref == "ur";
}
}

View file

@ -105,7 +105,6 @@ public:
Q_INVOKABLE int getCallStatus(const QString& callId);
Q_INVOKABLE const QString getCallStatusStr(int statusInt);
Q_INVOKABLE QString getStringUTF8(QString string);
Q_INVOKABLE bool validateRegNameForm(const QString& regName);
Q_INVOKABLE QString getRecordQualityString(int value);
Q_INVOKABLE QString getCurrentPath();
Q_INVOKABLE QString stringSimplifier(QString input);