message notification sound #LINQT-1666

This commit is contained in:
Gaelle Braud 2025-08-18 17:21:03 +02:00
parent 90ad29c78e
commit c24cfe135a
6 changed files with 37 additions and 18 deletions

View file

@ -385,6 +385,11 @@ void Notifier::notifyReceivedMessages(const std::shared_ptr<linphone::ChatRoom>
map["chat"] = QVariant::fromValue(chatCore ? new ChatGui(chatCore) : nullptr);
CREATE_NOTIFICATION(Notifier::ReceivedMessage, map)
});
auto settings = SettingsModel::getInstance();
if (settings && !settings->dndEnabled()) {
CoreModel::getInstance()->getCore()->playLocal(
Utils::appStringToCoreString(settings->getChatNotificationSoundPath()));
}
}
}
/*

View file

@ -31,7 +31,7 @@
class VariantList : public AbstractListProxy<QVariant>, public AbstractObject {
Q_OBJECT
Q_PROPERTY(QList<QVariant> model WRITE setModel NOTIFY modelChanged)
Q_PROPERTY(QList<QVariant> model READ getModel WRITE setModel NOTIFY modelChanged)
public:
VariantList(QObject *parent = Q_NULLPTR);
VariantList(QList<QVariant> list, QObject *parent = Q_NULLPTR);

View file

@ -82,7 +82,7 @@ bool LdapModel::getDebug() const {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
return mLdapParamsClone->getDebugLevel() == linphone::Ldap::DebugLevel::Verbose;
}
void LdapModel::setDebug(bool data) {
void LdapModel::setDebug(const bool &data) {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
if (getDebug() != data) {
mLdapParamsClone->setDebugLevel(data ? linphone::Ldap::DebugLevel::Verbose : linphone::Ldap::DebugLevel::Off);

View file

@ -652,7 +652,7 @@ bool SettingsModel::getIpv6Enabled() const {
return CoreModel::getInstance()->getCore()->ipv6Enabled();
}
void SettingsModel::setIpv6Enabled(bool status) {
void SettingsModel::setIpv6Enabled(const bool &status) {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
if (getIpv6Enabled() != status) {
CoreModel::getInstance()->getCore()->enableIpv6(status);
@ -728,7 +728,7 @@ QVariantList SettingsModel::getShortcuts() const {
return shortcuts;
}
void SettingsModel::setShortcuts(QVariantList data) {
void SettingsModel::setShortcuts(const QVariantList &data) {
if (getShortcuts() != data) {
// clean
auto sections = mConfig->getSectionsNamesList();
@ -773,12 +773,23 @@ QString SettingsModel::getCallForwardToAddress() const {
return Utils::coreStringToAppString(mConfig->getString(UiSection, "call_forward_to_address", ""));
}
void SettingsModel::setCallForwardToAddress(QString data) {
void SettingsModel::setCallForwardToAddress(const QString &data) {
if (data == "") disableCallForward();
else enableCallForward(data);
emit(callForwardToAddressChanged(data));
}
QString SettingsModel::getChatNotificationSoundPath() const {
static const string defaultFile = linphone::Factory::get()->getSoundResourcesDir() + "/incoming_chat.wav";
return Utils::coreStringToAppString(mConfig->getString(UiSection, "chat_sound_notification_file", defaultFile));
}
void SettingsModel::setChatNotificationSoundPath(const QString &path) {
QString cleanedPath = QDir::cleanPath(path);
mConfig->setString(UiSection, "chat_sound_notification_file", Utils::appStringToCoreString(cleanedPath));
emit chatNotificationSoundPathChanged(cleanedPath);
}
QFont SettingsModel::getEmojiFont() const {
QString family = Utils::coreStringToAppString(mConfig->getString(
UiSection, "emoji_font", Utils::appStringToCoreString(QFont(Constants::DefaultEmojiFont).family())));

View file

@ -198,6 +198,7 @@ public:
DECLARE_GETSET(bool, disableCommandLine, DisableCommandLine)
DECLARE_GETSET(bool, disableCallForward, DisableCallForward)
DECLARE_GETSET(QString, callForwardToAddress, CallForwardToAddress)
DECLARE_GETSET(QString, chatNotificationSoundPath, ChatNotificationSoundPath)
signals:
void logsUploadUrlChanged();

View file

@ -63,7 +63,7 @@ public:
#define DECLARE_CORE_GETSET_MEMBER(type, x, X) \
Q_PROPERTY(type x MEMBER m##X WRITE set##X NOTIFY x##Changed) \
Q_SIGNAL void set##X(type data); \
Q_SIGNAL void set##X(const type &data); \
Q_SIGNAL void x##Changed(); \
type m##X;
@ -74,14 +74,14 @@ public:
#define DECLARE_CORE_GETSET(type, x, X) \
Q_PROPERTY(type x READ get##X WRITE set##X NOTIFY x##Changed) \
Q_SIGNAL void set##X(type data); \
Q_SIGNAL void set##X(const type &data); \
type get##X() const; \
Q_SIGNAL void x##Changed(); \
type m##X;
#define DECLARE_GUI_GETSET(type, x, X) \
Q_PROPERTY(type x READ get##X WRITE set##X NOTIFY x##Changed) \
void set##X(type data); \
void set##X(const type &data); \
type get##X() const; \
Q_SIGNAL void x##Changed(); \
type m##X;
@ -94,11 +94,13 @@ public:
#define DECLARE_CORE_GET_CONSTANT(type, x, X) \
Q_PROPERTY(type x MEMBER m##X CONSTANT) \
type m##X; \
type get##X() const { return m##X;}
type get##X() const { \
return m##X; \
}
#define DECLARE_GETSET(type, x, X) \
type get##X() const; \
void set##X(type data); \
void set##X(const type &data); \
Q_SIGNAL void x##Changed(type x);
#define INIT_CORE_MEMBER(X, model) m##X = model->get##X();
@ -129,7 +131,7 @@ public:
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); \
return !!mConfig->get##Type(UiSection, key, def); \
} \
void Class::set##X(type data) { \
void Class::set##X(const type &data) { \
if (get##X() != data) { \
mConfig->set##Type(UiSection, key, data); \
emit x##Changed(data); \
@ -141,7 +143,7 @@ public:
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); \
return Utils::coreStringToAppString(mConfig->getString(UiSection, key, def)); \
} \
void Class::set##X(QString data) { \
void Class::set##X(const QString &data) { \
if (get##X() != data) { \
mConfig->setString(UiSection, key, Utils::appStringToCoreString(data)); \
emit x##Changed(data); \
@ -152,14 +154,14 @@ public:
#define DECLARE_GETSET_API(type, x, X) \
type get##X() const; \
void set##X(type data); \
void set##X(const type &data); \
Q_SIGNAL void x##Changed(type x);
#define DEFINE_GET_SET_API(Class, type, x, X) \
type Class::get##X() const { \
return m##X; \
} \
void Class::set##X(type data) { \
void Class::set##X(const type &data) { \
if (get##X() != data) { \
m##X = data; \
emit x##Changed(); \
@ -171,7 +173,7 @@ public:
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); \
return ownerNotNull->get##X(); \
} \
void Class::set##X(type data) { \
void Class::set##X(const type &data) { \
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); \
if (get##X() != data) { \
ownerNotNull->set##X(data); \
@ -196,7 +198,7 @@ public:
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); \
return Utils::coreStringToAppString(ownerNotNull->get##X()); \
} \
void Class::set##X(QString data) { \
void Class::set##X(const QString &data) { \
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); \
if (get##X() != data) { \
ownerNotNull->set##X(Utils::appStringToCoreString(data)); \
@ -209,7 +211,7 @@ public:
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); \
return ownerNotNull->x##Enabled(); \
} \
void Class::set##X(bool data) { \
void Class::set##X(const bool &data) { \
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); \
if (get##X() != data) { \
ownerNotNull->enable##X(data); \
@ -222,7 +224,7 @@ public:
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); \
return ownerNotNull->enabled(); \
} \
void Class::set##X(bool data) { \
void Class::set##X(const bool &data) { \
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); \
if (get##X() != data) { \
ownerNotNull->enable(data); \