From d4bba3e9b084d2a692ffc90606f22e709f40123a Mon Sep 17 00:00:00 2001 From: Fatih Uzunoglu <fuzun54@outlook.com> Date: Thu, 3 Apr 2025 22:27:14 +0300 Subject: [PATCH 1/2] qt: make use of `QStringBuilder` in `ControlbarProfileModel::save()` This was unfortunately forgotten in 04507065. I used `%` instead of `+` even though defining `QT_USE_QSTRINGBUILDER` (where we do) makes `+` behave like `%`, to explicitly request to use `QStringBuilder` noting the amount of additions done. --- .../toolbar/controlbar_profile_model.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/modules/gui/qt/dialogs/toolbar/controlbar_profile_model.cpp b/modules/gui/qt/dialogs/toolbar/controlbar_profile_model.cpp index 12959d6054b9..aab83cd0ee6f 100644 --- a/modules/gui/qt/dialogs/toolbar/controlbar_profile_model.cpp +++ b/modules/gui/qt/dialogs/toolbar/controlbar_profile_model.cpp @@ -726,16 +726,14 @@ void ControlbarProfileModel::save(bool clearDirty) const return ret; }; - { - val += SETTINGS_PROFILE_SEPARATOR; - val += QString::number(identifier); - val += SETTINGS_CONFIGURATION_SEPARATOR; - val += join(serializedModels[0]); - val += SETTINGS_CONFIGURATION_SEPARATOR; - val += join(serializedModels[1]); - val += SETTINGS_CONFIGURATION_SEPARATOR; - val += join(serializedModels[2]); - } + val += SETTINGS_PROFILE_SEPARATOR % + QString::number(identifier) % + SETTINGS_CONFIGURATION_SEPARATOR % + join(serializedModels[0]) % + SETTINGS_CONFIGURATION_SEPARATOR % + join(serializedModels[1]) % + SETTINGS_CONFIGURATION_SEPARATOR % + join(serializedModels[2]); } if (clearDirty) -- GitLab From 30545194671b90b17c1f8fa61cd57ccc69964a43 Mon Sep 17 00:00:00 2001 From: Fatih Uzunoglu <fuzun54@outlook.com> Date: Thu, 3 Apr 2025 22:44:32 +0300 Subject: [PATCH 2/2] qt: switch to constexpr from preprocessor definitions in `controlbar_profile_model.cpp` --- .../toolbar/controlbar_profile_model.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/modules/gui/qt/dialogs/toolbar/controlbar_profile_model.cpp b/modules/gui/qt/dialogs/toolbar/controlbar_profile_model.cpp index aab83cd0ee6f..96d2800a9263 100644 --- a/modules/gui/qt/dialogs/toolbar/controlbar_profile_model.cpp +++ b/modules/gui/qt/dialogs/toolbar/controlbar_profile_model.cpp @@ -25,14 +25,16 @@ #include "player/control_list_model.hpp" #include "player/player_controlbar_model.hpp" -#define SETTINGS_KEY_SELECTEDPROFILE "SelectedProfile" -#define SETTINGS_ARRAYNAME_PROFILES "Profiles" -#define SETTINGS_KEY_NAME "Name" -#define SETTINGS_KEY_MODEL "Model" - -#define SETTINGS_CONTROL_SEPARATOR QChar(',') -#define SETTINGS_CONFIGURATION_SEPARATOR QChar('|') -#define SETTINGS_PROFILE_SEPARATOR QChar('$') +// NOTE: QSettings started to accept QAnyStringView with Qt 6.4, +// so instead of a QString(Literal), use QLatin1String(View): +constexpr QLatin1String SETTINGS_KEY_SELECTEDPROFILE {"SelectedProfile"}; +constexpr QLatin1String SETTINGS_ARRAYNAME_PROFILES {"Profiles"}; +constexpr QLatin1String SETTINGS_KEY_NAME {"Name"}; +constexpr QLatin1String SETTINGS_KEY_MODEL {"Model"}; + +constexpr QChar SETTINGS_CONTROL_SEPARATOR {','}; +constexpr QChar SETTINGS_CONFIGURATION_SEPARATOR {'|'}; +constexpr QChar SETTINGS_PROFILE_SEPARATOR {'$'}; decltype (ControlbarProfileModel::m_defaults) ControlbarProfileModel::m_defaults = -- GitLab