From 295dbcb4c38b1e324ab478004b6b20c4dfe62d7d Mon Sep 17 00:00:00 2001 From: Christophe Deschamps Date: Fri, 3 Oct 2025 10:25:05 +0200 Subject: [PATCH] Theme colors via config ui|theme_main_color --- Linphone/core/setting/SettingsCore.cpp | 7 ++ Linphone/core/setting/SettingsCore.hpp | 3 + Linphone/data/image/radio_off.svg | 11 ---- Linphone/data/image/radio_on.svg | 12 ---- Linphone/model/setting/SettingsModel.cpp | 13 ++++ Linphone/model/setting/SettingsModel.hpp | 2 + Linphone/view/CMakeLists.txt | 1 + Linphone/view/Control/Button/Slider.qml | 4 +- .../Page/Layout/Chat/EphemeralSettings.qml | 14 ++-- Linphone/view/Style/AppIcons.qml | 2 - Linphone/view/Style/DefaultStyle.qml | 16 +++-- Linphone/view/Style/Themes.qml | 65 +++++++++++++++++++ 12 files changed, 107 insertions(+), 43 deletions(-) delete mode 100644 Linphone/data/image/radio_off.svg delete mode 100644 Linphone/data/image/radio_on.svg create mode 100644 Linphone/view/Style/Themes.qml diff --git a/Linphone/core/setting/SettingsCore.cpp b/Linphone/core/setting/SettingsCore.cpp index d8df64f0e..17fb467d9 100644 --- a/Linphone/core/setting/SettingsCore.cpp +++ b/Linphone/core/setting/SettingsCore.cpp @@ -140,6 +140,9 @@ SettingsCore::SettingsCore(QObject *parent) : QObject(parent) { INIT_CORE_MEMBER(DisableCommandLine, settingsModel) INIT_CORE_MEMBER(DisableCallForward, settingsModel) INIT_CORE_MEMBER(CallForwardToAddress, settingsModel) + + INIT_CORE_MEMBER(ThemeMainColor, settingsModel) + INIT_CORE_MEMBER(ThemeAboutPictureUrl, settingsModel) } SettingsCore::SettingsCore(const SettingsCore &settingsCore) { @@ -452,6 +455,10 @@ void SettingsCore::setSelf(QSharedPointer me) { disableCallForward, DisableCallForward) DEFINE_CORE_GETSET_CONNECT(mSettingsModelConnection, SettingsCore, SettingsModel, settingsModel, QString, callForwardToAddress, CallForwardToAddress) + DEFINE_CORE_GETSET_CONNECT(mSettingsModelConnection, SettingsCore, SettingsModel, settingsModel, QString, + themeAboutPictureUrl, ThemeAboutPictureUrl) + DEFINE_CORE_GETSET_CONNECT(mSettingsModelConnection, SettingsCore, SettingsModel, settingsModel, QString, + themeMainColor, ThemeMainColor) auto coreModelConnection = SafeConnection::create(me, CoreModel::getInstance()); diff --git a/Linphone/core/setting/SettingsCore.hpp b/Linphone/core/setting/SettingsCore.hpp index d525b3af1..66290a104 100644 --- a/Linphone/core/setting/SettingsCore.hpp +++ b/Linphone/core/setting/SettingsCore.hpp @@ -252,6 +252,9 @@ public: DECLARE_CORE_GETSET_MEMBER(QString, callForwardToAddress, CallForwardToAddress) DECLARE_CORE_GET_CONSTANT(QFont, emojiFont, EmojiFont) DECLARE_CORE_GET_CONSTANT(QFont, textMessageFont, TextMessageFont) + // Theme + DECLARE_CORE_GETSET_MEMBER(QString, themeMainColor, ThemeMainColor) + DECLARE_CORE_GETSET_MEMBER(QString, themeAboutPictureUrl, ThemeAboutPictureUrl) signals: diff --git a/Linphone/data/image/radio_off.svg b/Linphone/data/image/radio_off.svg deleted file mode 100644 index 788989b7f..000000000 --- a/Linphone/data/image/radio_off.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/Linphone/data/image/radio_on.svg b/Linphone/data/image/radio_on.svg deleted file mode 100644 index 962733675..000000000 --- a/Linphone/data/image/radio_on.svg +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/Linphone/model/setting/SettingsModel.cpp b/Linphone/model/setting/SettingsModel.cpp index 377571ee2..640f6b01a 100644 --- a/Linphone/model/setting/SettingsModel.cpp +++ b/Linphone/model/setting/SettingsModel.cpp @@ -897,6 +897,9 @@ void SettingsModel::notifyConfigReady(){ DEFINE_NOTIFY_CONFIG_READY(usernameOnlyForCardDAVLookupsInCalls, UsernameOnlyForCardDAVLookupsInCalls) DEFINE_NOTIFY_CONFIG_READY(commandLine, CommandLine) DEFINE_NOTIFY_CONFIG_READY(disableCommandLine, DisableCommandLine) + DEFINE_NOTIFY_CONFIG_READY(themeMainColor, ThemeMainColor) + DEFINE_NOTIFY_CONFIG_READY(themeAboutPictureUrl, ThemeAboutPictureUrl) + } DEFINE_GETSET_CONFIG(SettingsModel, bool, Bool, disableChatFeature, DisableChatFeature, "disable_chat_feature", false) @@ -1042,4 +1045,14 @@ DEFINE_GETSET_CONFIG(SettingsModel, DisableCallForward, "disable_call_forward", true) +DEFINE_GETSET_CONFIG_STRING(SettingsModel, + themeMainColor, + ThemeMainColor, + "theme_main_color", + "orange") +DEFINE_GETSET_CONFIG_STRING(SettingsModel, + themeAboutPictureUrl, + ThemeAboutPictureUrl, + "theme_about_picture_url", + "") // clang-format on diff --git a/Linphone/model/setting/SettingsModel.hpp b/Linphone/model/setting/SettingsModel.hpp index 64ab6cc9c..862661d41 100644 --- a/Linphone/model/setting/SettingsModel.hpp +++ b/Linphone/model/setting/SettingsModel.hpp @@ -213,6 +213,8 @@ public: DECLARE_GETSET(bool, disableCallForward, DisableCallForward) DECLARE_GETSET(QString, callForwardToAddress, CallForwardToAddress) DECLARE_GETSET(QString, chatNotificationSoundPath, ChatNotificationSoundPath) + DECLARE_GETSET(QString, themeMainColor, ThemeMainColor) + DECLARE_GETSET(QString, themeAboutPictureUrl, ThemeAboutPictureUrl) signals: void logsUploadUrlChanged(); diff --git a/Linphone/view/CMakeLists.txt b/Linphone/view/CMakeLists.txt index e63776d9c..48d6cfed7 100644 --- a/Linphone/view/CMakeLists.txt +++ b/Linphone/view/CMakeLists.txt @@ -194,6 +194,7 @@ list(APPEND _LINPHONEAPP_QML_SINGLETONS view/Style/DefaultStyle.qml view/Style/FileViewStyle.qml view/Style/Typography.qml + view/Style/Themes.qml ) set(_LINPHONEAPP_QML_FILES ${_LINPHONEAPP_QML_FILES} PARENT_SCOPE) diff --git a/Linphone/view/Control/Button/Slider.qml b/Linphone/view/Control/Button/Slider.qml index 5132d7896..4fa26a020 100644 --- a/Linphone/view/Control/Button/Slider.qml +++ b/Linphone/view/Control/Button/Slider.qml @@ -27,8 +27,8 @@ Control.Slider { height: parent.height gradient: Gradient { orientation: Gradient.Horizontal - GradientStop { position: 0.0; color: "#FF9E79" } - GradientStop { position: 1.0; color: "#FE5E00" } + GradientStop { position: 0.0; color: DefaultStyle.main1_300 } + GradientStop { position: 1.0; color: DefaultStyle.main1_500_main } } radius: Math.round(40 * DefaultStyle.dp) } diff --git a/Linphone/view/Page/Layout/Chat/EphemeralSettings.qml b/Linphone/view/Page/Layout/Chat/EphemeralSettings.qml index 8eb5fb9f0..10269bb4b 100644 --- a/Linphone/view/Page/Layout/Chat/EphemeralSettings.qml +++ b/Linphone/view/Page/Layout/Chat/EphemeralSettings.qml @@ -99,7 +99,8 @@ ColumnLayout { delegate: ColumnLayout { Layout.fillWidth: true Layout.leftMargin: Math.round(8 * DefaultStyle.dp) - Control.RadioButton { + RadioButton { + color: DefaultStyle.main1_500_main enabled: modelData.disabled !== true opacity: modelData.disabled !== true ? 1.0 : 0.5 checked: modelData.lifetime === mainItem.selectedLifetime @@ -110,19 +111,12 @@ ColumnLayout { text: modelData.title color: DefaultStyle.main2_600 font: Typography.p1 - leftPadding: Math.round(8 * DefaultStyle.dp) + leftPadding: Math.round(20 * DefaultStyle.dp) wrapMode: Text.NoWrap elide: Text.ElideRight anchors.left: ico.right } - indicator: Image { - id: ico - source: parent.checked ? AppIcons.radioOn : AppIcons.radioOff - width: Math.round(24 * DefaultStyle.dp) - height: Math.round(24 * DefaultStyle.dp) - fillMode: Image.PreserveAspectFit - anchors.verticalCenter: parent.verticalCenter - } + } Rectangle { //visible: index < (model.count - 1) diff --git a/Linphone/view/Style/AppIcons.qml b/Linphone/view/Style/AppIcons.qml index 66d383204..324f1873b 100644 --- a/Linphone/view/Style/AppIcons.qml +++ b/Linphone/view/Style/AppIcons.qml @@ -157,7 +157,5 @@ QtObject { property string pdf: "image://internal/pdf.svg" property string photo: "image://internal/photo.svg" property string ephemeralSettings: "image://internal/ephemeral-settings.svg" - property string radioOn: "image://internal/radio_on.svg" - property string radioOff: "image://internal/radio_off.svg" property string hourglass: "image://internal/hourglass-simple.svg" } diff --git a/Linphone/view/Style/DefaultStyle.qml b/Linphone/view/Style/DefaultStyle.qml index 205b6da1f..0b3185756 100644 --- a/Linphone/view/Style/DefaultStyle.qml +++ b/Linphone/view/Style/DefaultStyle.qml @@ -1,14 +1,18 @@ pragma Singleton import QtQuick import Linphone +import SettingsCpp QtObject { - property color main1_100: "#FFEACB" - property color main1_200: "#FFD098" - property color main1_300: "#FFB266" - property color main1_500_main: "#FE5E00" - property color main1_600: "#DA4400" - property color main1_700: "#B72D00" + + property var currentTheme: Themes.themes[SettingsCpp.themeMainColor] + + property color main1_100: currentTheme.main100 + property color main1_200: currentTheme.main200 + property color main1_300: currentTheme.main300 + property color main1_500_main: currentTheme.main500 + property color main1_600: currentTheme.main600 + property color main1_700: currentTheme.main700 property color main2_0: "#FAFEFF" property color main2_100: "#EEF6F8" diff --git a/Linphone/view/Style/Themes.qml b/Linphone/view/Style/Themes.qml new file mode 100644 index 000000000..769f279d8 --- /dev/null +++ b/Linphone/view/Style/Themes.qml @@ -0,0 +1,65 @@ +pragma Singleton +import QtQuick + +QtObject { + property var themes: { + return { + "orange": { + "main100": "#FFEACB", + "main200": "#FFD098", + "main300": "#FFB266", + "main500": "#FF5E00", + "main600": "#DA4400", + "main700": "#B72D00" + }, + "yellow": { + "main100": "#FFF5D6", + "main200": "#FFEFB2", + "main300": "#FFE799", + "main500": "#F5BC00", + "main600": "#C69300", + "main700": "#A37D00" + }, + "green": { + "main100": "#DCF9E7", + "main200": "#BDF0CF", + "main300": "#A8F0C2", + "main500": "#25D366", + "main600": "#1FA352", + "main700": "#1C9C4B" + }, + "blue": { + "main100": "#D6F4FF", + "main200": "#B2E9FF", + "main300": "#99E4FF", + "main500": "#00AFF0", + "main600": "#008CC0", + "main700": "#0078A3" + }, + "red": { + "main100": "#FBE1DA", + "main200": "#F8C1B6", + "main300": "#F5B53A", + "main500": "#E14318", + "main600": "#C23814", + "main700": "#A63211" + }, + "pink": { + "main100": "#FFD6F1", + "main200": "#FFB8E8", + "main300": "#FF99DD", + "main500": "#FF00A9", + "main600": "#D60090", + "main700": "#B8007A" + }, + "purple": { + "main100": "#FFD6FF", + "main200": "#F0B3F0", + "main300": "#FF99FF", + "main500": "#800080", + "main600": "#660066", + "main700": "#520052" + } + } + } +}