From 480704664ef0513f0306f0e39cc4c828a727b320 Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Wed, 20 Aug 2025 10:58:26 +0200 Subject: [PATCH] notifications in navigation bar fix crash macos noification in task bar --- Linphone/core/App.cpp | 40 +++++- Linphone/core/App.hpp | 8 ++ Linphone/core/CMakeLists.txt | 7 +- .../AbstractEventCountNotifier.cpp | 63 ++++++++ .../AbstractEventCountNotifier.hpp | 58 ++++++++ .../EventCountNotifierMacOs.hpp | 40 ++++++ .../EventCountNotifierMacOs.m | 30 ++++ .../EventCountNotifierSystemTrayIcon.cpp | 134 ++++++++++++++++++ .../EventCountNotifierSystemTrayIcon.hpp | 50 +++++++ Linphone/model/core/CoreModel.cpp | 11 ++ Linphone/model/core/CoreModel.hpp | 7 + Linphone/model/setting/SettingsModel.cpp | 14 ++ Linphone/model/setting/SettingsModel.hpp | 5 + Linphone/tool/Utils.cpp | 13 ++ Linphone/tool/Utils.hpp | 2 + Linphone/view/Page/Layout/Main/MainLayout.qml | 3 +- 16 files changed, 475 insertions(+), 10 deletions(-) create mode 100644 Linphone/core/event-count-notifier/AbstractEventCountNotifier.cpp create mode 100644 Linphone/core/event-count-notifier/AbstractEventCountNotifier.hpp create mode 100644 Linphone/core/event-count-notifier/EventCountNotifierMacOs.hpp create mode 100644 Linphone/core/event-count-notifier/EventCountNotifierMacOs.m create mode 100644 Linphone/core/event-count-notifier/EventCountNotifierSystemTrayIcon.cpp create mode 100644 Linphone/core/event-count-notifier/EventCountNotifierSystemTrayIcon.hpp diff --git a/Linphone/core/App.cpp b/Linphone/core/App.cpp index d68c3a703..44d860a48 100644 --- a/Linphone/core/App.cpp +++ b/Linphone/core/App.cpp @@ -93,6 +93,12 @@ #include "tool/request/RequestDialog.hpp" #include "tool/thread/Thread.hpp" +#if defined(Q_OS_MACOS) +#include "core/event-count-notifier/EventCountNotifierMacOs.hpp" +#else +#include "core/event-count-notifier/EventCountNotifierSystemTrayIcon.hpp" +#endif // if defined(Q_OS_MACOS) + DEFINE_ABSTRACT_OBJECT(App) #ifdef Q_OS_LINUX @@ -263,6 +269,7 @@ App::App(int &argc, char *argv[]) // Do not use APPLICATION_NAME here. // The EXECUTABLE_NAME will be used in qt standard paths. It's our goal. QThread::currentThread()->setPriority(QThread::HighPriority); + qDebug() << "app thread is" << QThread::currentThread(); QCoreApplication::setApplicationName(EXECUTABLE_NAME); QApplication::setOrganizationDomain(EXECUTABLE_NAME); QCoreApplication::setApplicationVersion(APPLICATION_SEMVER); @@ -291,6 +298,7 @@ App::App(int &argc, char *argv[]) emit currentDateChanged(); } }); + mEventCountNotifier = new EventCountNotifier(this); mDateUpdateTimer.start(); } @@ -372,6 +380,16 @@ void App::setSelf(QSharedPointer(me)) { }); } }); + + mCoreModelConnection->makeConnectToModel(&CoreModel::unreadNotificationsChanged, [this] { + int n = mEventCountNotifier->getCurrentEventCount(); + mCoreModelConnection->invokeToCore([this, n] { mEventCountNotifier->notifyEventCount(n); }); + }); + mCoreModelConnection->makeConnectToModel(&CoreModel::defaultAccountChanged, [this] { + int n = mEventCountNotifier->getCurrentEventCount(); + mCoreModelConnection->invokeToCore([this, n] { mEventCountNotifier->notifyEventCount(n); }); + }); + //--------------------------------------------------------------------------------------------- mCliModelConnection = SafeConnection::create(me, CliModel::getInstance()); mCliModelConnection->makeConnectToCore(&App::receivedMessage, [this](int, const QByteArray &byteArray) { @@ -400,6 +418,15 @@ QThread *App::getLinphoneThread() { Notifier *App::getNotifier() const { return mNotifier; } + +EventCountNotifier *App::getEventCountNotifier() { + return mEventCountNotifier; +} + +int App::getEventCount() const { + return mEventCountNotifier ? mEventCountNotifier->getEventCount() : 0; +} + //----------------------------------------------------------- // Initializations //----------------------------------------------------------- @@ -613,7 +640,6 @@ static inline bool installLocale(App &app, QTranslator &translator, const QLocal } void App::initLocale() { - // Try to use preferred locale. QString locale; @@ -628,9 +654,9 @@ void App::initLocale() { // Try to use system locale. // #ifdef Q_OS_MACOS - // Use this workaround if there is still an issue about detecting wrong language from system on Mac. Qt doesn't use - // the current system language on QLocale::system(). So we need to get it from user settings and overwrite its - // Locale. + // Use this workaround if there is still an issue about detecting wrong language from system on Mac. Qt doesn't + // use the current system language on QLocale::system(). So we need to get it from user settings and overwrite + // its Locale. // QSettings settings; // QString preferredLanguage = settings.value("AppleLanguages").toStringList().first(); // QStringList qtLocale = QLocale::system().name().split('_'); @@ -640,9 +666,9 @@ void App::initLocale() { // } // QLocale sysLocale = QLocale(qtLocale.join('_')); // #else - QLocale sysLocale(QLocale::system().name()); // Use Locale from name because Qt has a bug where it didn't use the - // QLocale::language (aka : translator.language != locale.language) on - // Mac. #endif + QLocale sysLocale(QLocale::system().name()); // Use Locale from name because Qt has a bug where it didn't use + // the QLocale::language (aka : translator.language != + // locale.language) on Mac. #endif if (installLocale(*this, *mTranslatorCore, sysLocale)) { qDebug() << "installed sys locale" << sysLocale.name(); setLocale(sysLocale.name()); diff --git a/Linphone/core/App.hpp b/Linphone/core/App.hpp index 2655b220a..128d935dd 100644 --- a/Linphone/core/App.hpp +++ b/Linphone/core/App.hpp @@ -54,6 +54,9 @@ public: static QThread *getLinphoneThread(); Notifier *getNotifier() const; + EventCountNotifier *getEventCountNotifier(); + int getEventCount() const; + // App::postModelAsync() => run lambda in model thread and continue. // App::postModelSync() => run lambda in current thread and block connection. template @@ -119,6 +122,10 @@ public: void restart(); bool autoStartEnabled(); void setSysTrayIcon(); + QSystemTrayIcon *getSystemTrayIcon() const { + return mSystemTrayIcon; + } + void updateSysTrayCount(int n); QLocale getLocale(); void onLoggerInitialized(); @@ -184,6 +191,7 @@ private: QCommandLineParser *mParser = nullptr; Thread *mLinphoneThread = nullptr; Notifier *mNotifier = nullptr; + EventCountNotifier *mEventCountNotifier = nullptr; QSystemTrayIcon *mSystemTrayIcon = nullptr; QQuickWindow *mMainWindow = nullptr; QQuickWindow *mCallsWindow = nullptr; diff --git a/Linphone/core/CMakeLists.txt b/Linphone/core/CMakeLists.txt index c40492f8c..7314b6de8 100644 --- a/Linphone/core/CMakeLists.txt +++ b/Linphone/core/CMakeLists.txt @@ -19,6 +19,7 @@ list(APPEND _LINPHONEAPP_SOURCES core/camera/CameraGui.cpp core/camera/CameraDummy.cpp core/camera/PreviewManager.cpp + core/event-count-notifier/AbstractEventCountNotifier.cpp core/fps-counter/FPSCounter.cpp core/friend/FriendCore.cpp core/friend/FriendGui.cpp @@ -99,5 +100,9 @@ else() # Use QDBus for Linux core/singleapplication/SingleApplicationDBusPrivate.hpp core/singleapplication/SingleApplicationDBus.cpp) endif() - +if(APPLE) + list(APPEND _LINPHONEAPP_SOURCES core/event-count-notifier/EventCountNotifierMacOs.m) +else() + list(APPEND _LINPHONEAPP_SOURCES core/event-count-notifier/EventCountNotifierSystemTrayIcon.cpp) +endif() set(_LINPHONEAPP_SOURCES ${_LINPHONEAPP_SOURCES} PARENT_SCOPE) diff --git a/Linphone/core/event-count-notifier/AbstractEventCountNotifier.cpp b/Linphone/core/event-count-notifier/AbstractEventCountNotifier.cpp new file mode 100644 index 000000000..e6fe8cd3f --- /dev/null +++ b/Linphone/core/event-count-notifier/AbstractEventCountNotifier.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2010-2024 Belledonne Communications SARL. + * + * This file is part of linphone-desktop + * (see https://www.linphone.org). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include + +#include "core/App.hpp" +#include "model/core/CoreModel.hpp" +#include "model/setting/SettingsModel.hpp" + +#include "AbstractEventCountNotifier.hpp" + +// ============================================================================= + +using namespace std; + +DEFINE_ABSTRACT_OBJECT(AbstractEventCountNotifier) + +AbstractEventCountNotifier::AbstractEventCountNotifier(QObject *parent) : QObject(parent) { +} + +int AbstractEventCountNotifier::getEventCount() const { + mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); + auto coreModel = CoreModel::getInstance(); + int count = coreModel->getCore()->getMissedCallsCount(); + return count; +} + +int AbstractEventCountNotifier::getCurrentEventCount() const { + mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); + // auto coreModel = CoreModel::getInstance(); + // int count = coreModel->getCore()->getMissedCallsCount(); + // bool filtered = SettingsModel::getInstance()->isSystrayNotificationFiltered(); + // bool global = SettingsModel::getInstance()->isSystrayNotificationGlobal(); + // if (global && !filtered) + return getEventCount(); + // else { + // auto currentAccount = CoreModel::getInstance()->getCore()->getDefaultAccount(); + // if (currentAccount) { + // auto linphoneChatRooms = currentAccount->filterChatRooms(""); + // for (const auto &chatRoom : linphoneChatRooms) { + // count += chatRoom->getUnreadMessagesCount(); + // } + // } + // return count; + // } +} \ No newline at end of file diff --git a/Linphone/core/event-count-notifier/AbstractEventCountNotifier.hpp b/Linphone/core/event-count-notifier/AbstractEventCountNotifier.hpp new file mode 100644 index 000000000..c850d5b49 --- /dev/null +++ b/Linphone/core/event-count-notifier/AbstractEventCountNotifier.hpp @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2010-2024 Belledonne Communications SARL. + * + * This file is part of linphone-desktop + * (see https://www.linphone.org). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef ABSTRACT_EVENT_COUNT_NOTIFIER_H_ +#define ABSTRACT_EVENT_COUNT_NOTIFIER_H_ + +#include +#include +#include +#include + +#include "tool/AbstractObject.hpp" +#include "tool/thread/SafeConnection.hpp" + +// ============================================================================= + +namespace linphone { +class ChatMessage; +} + +class CallModel; +class ChatRoomModel; +class HistoryModel; + +class AbstractEventCountNotifier : public QObject, public AbstractObject { + Q_OBJECT + +public: + AbstractEventCountNotifier(QObject *parent = Q_NULLPTR); + + int getEventCount() const; // global + int getCurrentEventCount() const; // Current account + +protected: + virtual void notifyEventCount(int n) = 0; + +private: + DECLARE_ABSTRACT_OBJECT +}; + +#endif // ABSTRACT_EVENT_COUNT_NOTIFIER_H_ diff --git a/Linphone/core/event-count-notifier/EventCountNotifierMacOs.hpp b/Linphone/core/event-count-notifier/EventCountNotifierMacOs.hpp new file mode 100644 index 000000000..7911413a8 --- /dev/null +++ b/Linphone/core/event-count-notifier/EventCountNotifierMacOs.hpp @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2010-2024 Belledonne Communications SARL. + * + * This file is part of linphone-desktop + * (see https://www.linphone.org). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef EVENT_COUNT_NOTIFIER_MAC_OS_H_ +#define EVENT_COUNT_NOTIFIER_MAC_OS_H_ + +#include "AbstractEventCountNotifier.hpp" + +// ============================================================================= + +extern "C" void notifyEventCountMacOs(int n); + +class EventCountNotifier : public AbstractEventCountNotifier { +public: + EventCountNotifier(QObject *parent = Q_NULLPTR) : AbstractEventCountNotifier(parent) { + } + + void notifyEventCount(int n) override { + notifyEventCountMacOs(n); + } +}; + +#endif // EVENT_COUNT_NOTIFIER_MAC_OS_H_ diff --git a/Linphone/core/event-count-notifier/EventCountNotifierMacOs.m b/Linphone/core/event-count-notifier/EventCountNotifierMacOs.m new file mode 100644 index 000000000..7d5d777b1 --- /dev/null +++ b/Linphone/core/event-count-notifier/EventCountNotifierMacOs.m @@ -0,0 +1,30 @@ +/* + * EventCountNotifierMacOs.m + * Copyright (C) 2017-2018 Belledonne Communications, Grenoble, France + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Created on: June 30, 2017 + * Author: Ghislain MARY + */ + +#import + +// ============================================================================= + +void notifyEventCountMacOs (int n) { + NSString *badgeStr = (n > 0) ? [NSString stringWithFormat:@"%d", n] : @""; + [[NSApp dockTile] setBadgeLabel:badgeStr]; +} diff --git a/Linphone/core/event-count-notifier/EventCountNotifierSystemTrayIcon.cpp b/Linphone/core/event-count-notifier/EventCountNotifierSystemTrayIcon.cpp new file mode 100644 index 000000000..c099b49eb --- /dev/null +++ b/Linphone/core/event-count-notifier/EventCountNotifierSystemTrayIcon.cpp @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2010-2024 Belledonne Communications SARL. + * + * This file is part of linphone-desktop + * (see https://www.linphone.org). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include +#include + +#include "core/App.hpp" +#include "model/core/CoreModel.hpp" +#include "model/setting/SettingsModel.hpp" +#include "tool/Constants.hpp" +#include "tool/Utils.hpp" + +#include "EventCountNotifierSystemTrayIcon.hpp" + +// ============================================================================= + +namespace { +constexpr int IconWidth = 256; +constexpr int IconHeight = 256; + +constexpr int IconCounterBackgroundRadius = 100; +constexpr int IconCounterBlinkInterval = 1000; +constexpr int IconCounterTextPixelSize = 144; +} // namespace + +DEFINE_ABSTRACT_OBJECT(EventCountNotifier) + +QSharedPointer EventCountNotifier::create(QObject *parent) { + auto sharedPointer = QSharedPointer(new EventCountNotifier(parent), &QObject::deleteLater); + sharedPointer->setSelf(sharedPointer); + sharedPointer->moveToThread(App::getInstance()->thread()); + return sharedPointer; +} + +EventCountNotifier::EventCountNotifier(QObject *parent) : AbstractEventCountNotifier(parent) { + QSvgRenderer renderer((QString(Constants::WindowIconPath))); + if (!renderer.isValid()) qFatal("Invalid SVG Image."); + + QPixmap buf(IconWidth, IconHeight); + buf.fill(QColor(Qt::transparent)); + + QPainter painter(&buf); + renderer.render(&painter); + + mBuf = new QPixmap(buf); + mBufWithCounter = new QPixmap(); + + mBlinkTimer = new QTimer(this); + mBlinkTimer->setInterval(IconCounterBlinkInterval); + connect(mBlinkTimer, &QTimer::timeout, this, &EventCountNotifier::update); +} + +void EventCountNotifier::setSelf(QSharedPointer me) { +} + +EventCountNotifier::~EventCountNotifier() { + delete mBuf; + delete mBufWithCounter; +} + +// ----------------------------------------------------------------------------- + +void EventCountNotifier::notifyEventCount(int n) { + mustBeInMainThread(log().arg(Q_FUNC_INFO)); + n = n > 99 ? 99 : n; + QSystemTrayIcon *sysTrayIcon = App::getInstance()->getSystemTrayIcon(); + if (!sysTrayIcon) return; + + if (!n) { + mBlinkTimer->stop(); + sysTrayIcon->setIcon(QIcon(*mBuf)); + return; + } + + *mBufWithCounter = *mBuf; + QPainter p(mBufWithCounter); + + const int width = mBufWithCounter->width(); + const int height = mBufWithCounter->height(); + + // Draw background. + { + p.setBrush(QColor(Utils::getDefaultStyleColor("main1_100"))); + p.drawEllipse(QPointF(width / 2, height / 2), IconCounterBackgroundRadius, IconCounterBackgroundRadius); + } + + // Draw text. + { + QFont font = p.font(); + font.setPixelSize(IconCounterTextPixelSize); + + p.setFont(font); + p.setPen(QPen(QColor(Utils::getDefaultStyleColor("main1_500_main")))); + p.drawText(QRect(0, 0, width, height), Qt::AlignCenter, QString::number(n)); + } + + // Change counter. + mBlinkTimer->stop(); + auto coreModel = CoreModel::getInstance(); + if (!coreModel->isInitialized() || SettingsModel::getInstance()->isSystrayNotificationBlinkEnabled()) + mBlinkTimer->start(); + mDisplayCounter = true; + update(); +} + +void EventCountNotifier::update() { + mustBeInMainThread(log().arg(Q_FUNC_INFO)); + QSystemTrayIcon *sysTrayIcon = App::getInstance()->getSystemTrayIcon(); + if (sysTrayIcon) { + sysTrayIcon->setIcon(QIcon(mDisplayCounter ? *mBufWithCounter : *mBuf)); + } + mDisplayCounter = !mDisplayCounter; +} diff --git a/Linphone/core/event-count-notifier/EventCountNotifierSystemTrayIcon.hpp b/Linphone/core/event-count-notifier/EventCountNotifierSystemTrayIcon.hpp new file mode 100644 index 000000000..6606a03d4 --- /dev/null +++ b/Linphone/core/event-count-notifier/EventCountNotifierSystemTrayIcon.hpp @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2010-2024 Belledonne Communications SARL. + * + * This file is part of linphone-desktop + * (see https://www.linphone.org). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef EVENT_COUNT_NOTIFIER_SYSTEM_TRAY_ICON_H_ +#define EVENT_COUNT_NOTIFIER_SYSTEM_TRAY_ICON_H_ + +#include "AbstractEventCountNotifier.hpp" + +// ============================================================================= + +class QTimer; + +class EventCountNotifier : public AbstractEventCountNotifier { +public: + static QSharedPointer create(QObject *parent = Q_NULLPTR); + EventCountNotifier(QObject *parent = Q_NULLPTR); + void setSelf(QSharedPointer me); + ~EventCountNotifier(); + + void notifyEventCount(int n) override; + +private: + const QPixmap *mBuf = nullptr; + QPixmap *mBufWithCounter = nullptr; + QTimer *mBlinkTimer = nullptr; + bool mDisplayCounter = false; + QSharedPointer> mCoreModelConnection; + void update(); + + DECLARE_ABSTRACT_OBJECT +}; + +#endif // EVENT_COUNT_NOTIFIER_SYSTEM_TRAY_ICON_H_ diff --git a/Linphone/model/core/CoreModel.cpp b/Linphone/model/core/CoreModel.cpp index f7d048dce..cad02b390 100644 --- a/Linphone/model/core/CoreModel.cpp +++ b/Linphone/model/core/CoreModel.cpp @@ -34,6 +34,12 @@ #include "model/tool/ToolModel.hpp" #include "tool/Utils.hpp" +#if defined(Q_OS_MACOS) +#include "core/event-count-notifier/EventCountNotifierMacOs.hpp" +#else +#include "core/event-count-notifier/EventCountNotifierSystemTrayIcon.hpp" +#endif // if defined(Q_OS_MACOS) + // ============================================================================= DEFINE_ABSTRACT_OBJECT(CoreModel) @@ -129,9 +135,14 @@ void CoreModel::start() { mMagicSearch->setSelf(mMagicSearch); connect(mMagicSearch.get(), &MagicSearchModel::searchResultsReceived, this, [this] { emit magicSearchResultReceived(mMagicSearch->mLastSearch); }); + mStarted = true; } // ----------------------------------------------------------------------------- +bool CoreModel::isInitialized() const { + return mStarted; +} + std::shared_ptr CoreModel::getInstance() { return gCoreModel; } diff --git a/Linphone/model/core/CoreModel.hpp b/Linphone/model/core/CoreModel.hpp index a1783b699..c1039a500 100644 --- a/Linphone/model/core/CoreModel.hpp +++ b/Linphone/model/core/CoreModel.hpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -39,6 +40,9 @@ // ============================================================================= +class AbstractEventCountNotifier; +class EventCountNotifier; + class CoreModel : public ::Listener, public linphone::CoreListener, public AbstractObject { @@ -52,6 +56,8 @@ public: std::shared_ptr getCore(); std::shared_ptr getLogger(); + bool isInitialized() const; + void start(); void setConfigPath(QString path); @@ -89,6 +95,7 @@ private: QTimer *mIterateTimer = nullptr; QMap mOpenIdConnections; std::shared_ptr mMagicSearch; + bool mStarted = false; void setPathBeforeCreation(); void setPathsAfterCreation(); diff --git a/Linphone/model/setting/SettingsModel.cpp b/Linphone/model/setting/SettingsModel.cpp index 2c2dc82dc..be9343d01 100644 --- a/Linphone/model/setting/SettingsModel.cpp +++ b/Linphone/model/setting/SettingsModel.cpp @@ -726,6 +726,20 @@ QString SettingsModel::getDefaultDomain() const { mConfig->getString(SettingsModel::AppSection, "default_domain", "sip.linphone.org")); } +bool SettingsModel::isSystrayNotificationBlinkEnabled() const { + return !!mConfig->getInt(UiSection, "systray_notification_blink", 1); +} + +bool SettingsModel::isSystrayNotificationGlobal() const { + return !!mConfig->getInt(UiSection, "systray_notification_global", 1); +} + +bool SettingsModel::isSystrayNotificationFiltered() const { + return !!mConfig->getInt(UiSection, "systray_notification_filtered", 0); +} +bool SettingsModel::getLimeIsSupported() const { + return CoreModel::getInstance()->getCore()->limeX3DhAvailable(); +} // clang-format off void SettingsModel::notifyConfigReady(){ DEFINE_NOTIFY_CONFIG_READY(disableChatFeature, DisableChatFeature) diff --git a/Linphone/model/setting/SettingsModel.hpp b/Linphone/model/setting/SettingsModel.hpp index e28d207bf..3aaf27ff5 100644 --- a/Linphone/model/setting/SettingsModel.hpp +++ b/Linphone/model/setting/SettingsModel.hpp @@ -157,6 +157,11 @@ public: static bool clearLocalLdapFriendsUponStartup(const std::shared_ptr &config); + bool isSystrayNotificationBlinkEnabled() const; + bool isSystrayNotificationGlobal() const; + bool isSystrayNotificationFiltered() const; + bool getLimeIsSupported() const; + // UI DECLARE_GETSET(bool, disableChatFeature, DisableChatFeature) DECLARE_GETSET(bool, disableMeetingsFeature, DisableMeetingsFeature) diff --git a/Linphone/tool/Utils.cpp b/Linphone/tool/Utils.cpp index c847c9175..714e5a9a5 100644 --- a/Linphone/tool/Utils.cpp +++ b/Linphone/tool/Utils.cpp @@ -36,10 +36,13 @@ #include #include +#include #include #include #include #include +#include +#include #include #include #include @@ -551,6 +554,16 @@ QString Utils::getOsProduct() { return product + "/" + version; } +QColor Utils::getDefaultStyleColor(const QString &colorName) { + mustBeInMainThread(sLog().arg(Q_FUNC_INFO)); + static QObject *defaultStyleSingleton = nullptr; + if (!defaultStyleSingleton) { + QQmlComponent component(App::getInstance()->mEngine, QUrl("qrc:/qt/qml/Linphone/view/Style/DefaultStyle.qml")); + defaultStyleSingleton = component.create(); + } + return QQmlProperty::read(defaultStyleSingleton, colorName).value(); +} + QString Utils::getCountryName(const QLocale::Territory &p_country) { QString countryName; switch (p_country) { diff --git a/Linphone/tool/Utils.hpp b/Linphone/tool/Utils.hpp index 784d37d3c..ae155ab91 100644 --- a/Linphone/tool/Utils.hpp +++ b/Linphone/tool/Utils.hpp @@ -146,6 +146,8 @@ public: static QString getApplicationProduct(); static QString getOsProduct(); + static QColor getDefaultStyleColor(const QString &colorName); + static QList> getDownloadableVideoPayloadTypes(); static void checkDownloadedCodecsUpdates(); diff --git a/Linphone/view/Page/Layout/Main/MainLayout.qml b/Linphone/view/Page/Layout/Main/MainLayout.qml index b9b4bf7c8..f36ffdb10 100644 --- a/Linphone/view/Page/Layout/Main/MainLayout.qml +++ b/Linphone/view/Page/Layout/Main/MainLayout.qml @@ -460,8 +460,7 @@ Item { icon.height: Math.round(32 * DefaultStyle.dp) text: qsTr("settings_title") icon.source: AppIcons.settings - onClicked: openContextualMenuComponent( - settingsPageComponent) + onClicked: openContextualMenuComponent(settingsPageComponent) KeyNavigation.up: visibleChildren.length != 0 ? settingsMenuButton.getPreviousItem( 2) : null