diff --git a/linphone-app/src/components/notifier/Notifier.cpp b/linphone-app/src/components/notifier/Notifier.cpp index 5786c2378..16de945bc 100644 --- a/linphone-app/src/components/notifier/Notifier.cpp +++ b/linphone-app/src/components/notifier/Notifier.cpp @@ -120,6 +120,10 @@ Notifier::~Notifier () { delete[] mComponents; } +int Notifier::getNotificationOrigin() { + return CoreManager::getInstance()->getSettingsModel()->getNotificationOrigin(); +} + // ----------------------------------------------------------------------------- QObject *Notifier::createNotification (Notifier::NotificationType type, QVariantMap data) { @@ -167,15 +171,24 @@ QObject *Notifier::createNotification (Notifier::NotificationType type, QVariant int * screenHeightOffset = &mScreenHeightOffset[screen->name()]; // Access optimization QRect availableGeometry = screen->availableGeometry(); - int heightOffset = availableGeometry.y() + (availableGeometry.height() - subWindow->height());//*screen->devicePixelRatio(); when using manual scaler + int heightOffset = availableGeometry.y() + (((getNotificationOrigin() & Top) != Top ) + ? (availableGeometry.height() - subWindow->height())//*screen->devicePixelRatio(); when using manual scaler + : 0); if(showAsTool) subWindow->setProperty("showAsTool",true); subWindow->setX(availableGeometry.x()+ (availableGeometry.width()-subWindow->property("width").toInt()));//*screen->devicePixelRatio()); when using manual scaler - subWindow->setY(heightOffset-(*screenHeightOffset % heightOffset)); + int newScreenHeightOffset = (subWindow->height() + *screenHeightOffset) + NotificationSpacing; + if(((getNotificationOrigin() & Top) == Top )){ + subWindow->setY(heightOffset+(*screenHeightOffset)); + if (newScreenHeightOffset + heightOffset > availableGeometry.height()) + newScreenHeightOffset = 0; + }else{ + subWindow->setY(heightOffset-(*screenHeightOffset % heightOffset)); + if (newScreenHeightOffset - heightOffset + availableGeometry.y() >= 0) + newScreenHeightOffset = 0; + } + *screenHeightOffset = newScreenHeightOffset; - *screenHeightOffset = (subWindow->height() + *screenHeightOffset) + NotificationSpacing; - if (*screenHeightOffset - heightOffset + availableGeometry.y() >= 0) - *screenHeightOffset = 0; // if(primaryScreen != screen){ //Useful when doing manual scaling jobs. Need to implement scaler in GUI objects // //subwindow->setProperty("xScale", (double)screen->availableVirtualGeometry().width()/availableGeometry.width() ); diff --git a/linphone-app/src/components/notifier/Notifier.hpp b/linphone-app/src/components/notifier/Notifier.hpp index 655c41ef8..8c0830f6f 100644 --- a/linphone-app/src/components/notifier/Notifier.hpp +++ b/linphone-app/src/components/notifier/Notifier.hpp @@ -54,6 +54,12 @@ public: RecordingCompleted }; + enum NotificationOrigin{ + BottomRight = 0, + Top = 1, + Left = 2 + }; + void notifyReceivedMessages (const std::list> &messages); void notifyReceivedReactions(const QList, std::shared_ptr>> &reactions); void notifyReceivedFileMessage (const std::shared_ptr &message, const std::shared_ptr &content); @@ -62,6 +68,8 @@ public: void notifySnapshotWasTaken (const QString &filePath); void notifyRecordingCompleted (const QString &filePath); + static int getNotificationOrigin(); + public slots: void deleteNotificationOnTimeout(QVariant notification); void deleteNotification (QVariant notification); diff --git a/linphone-app/src/components/settings/SettingsModel.cpp b/linphone-app/src/components/settings/SettingsModel.cpp index ef5fbbc78..d8ca0ff24 100644 --- a/linphone-app/src/components/settings/SettingsModel.cpp +++ b/linphone-app/src/components/settings/SettingsModel.cpp @@ -36,6 +36,7 @@ #include "SettingsModel.hpp" #include "components/assistant/AssistantModel.hpp" #include "components/core/CoreManager.hpp" +#include "components/notifier/Notifier.hpp" #include "components/tunnel/TunnelModel.hpp" #include "include/LinphoneApp/PluginNetworkHelper.hpp" #include "utils/Constants.hpp" @@ -553,7 +554,7 @@ void SettingsModel::startEchoCancellerCalibration() { CoreManager::getInstance()->getCore()->startEchoCancellerCalibration(); } -int SettingsModel::getEchoCancellationCalibration()const { +int SettingsModel::getEchoCancellationCalibration() const { return CoreManager::getInstance()->getCore()->getEchoCancellationCalibration(); } // ----------------------------------------------------------------------------- @@ -1043,7 +1044,6 @@ void SettingsModel::setChatNotificationSoundEnabled(bool status) { mConfig->setInt(UiSection, "chat_sound_notification_enabled", status); emit chatNotificationSoundEnabledChanged(status); } - // ----------------------------------------------------------------------------- QString SettingsModel::getChatNotificationSoundPath() const { @@ -1057,6 +1057,16 @@ void SettingsModel::setChatNotificationSoundPath(const QString &path) { emit chatNotificationSoundPathChanged(cleanedPath); } +int SettingsModel::getNotificationOrigin() const { + return mConfig->getInt(UiSection, "notification_origin", +#ifdef __APPLE__ + Notifier::NotificationOrigin::Top +#else + Notifier::NotificationOrigin::BottomRight +#endif + ); +} + // ----------------------------------------------------------------------------- QString SettingsModel::getFileTransferUrl() const { diff --git a/linphone-app/src/components/settings/SettingsModel.hpp b/linphone-app/src/components/settings/SettingsModel.hpp index 2a9e035b5..5703ba742 100644 --- a/linphone-app/src/components/settings/SettingsModel.hpp +++ b/linphone-app/src/components/settings/SettingsModel.hpp @@ -531,6 +531,8 @@ public: QString getChatNotificationSoundPath() const; void setChatNotificationSoundPath(const QString &path); + int getNotificationOrigin() const; + QString getFileTransferUrl() const; void setFileTransferUrl(const QString &url);