string: use better name

This commit is contained in:
Yuhang Zhao 2023-07-29 16:17:13 +08:00
parent c6ca6cc794
commit 2f7a104ebd
3 changed files with 22 additions and 24 deletions

View File

@ -132,23 +132,23 @@ QT_END_NAMESPACE
# endif
#endif
#ifndef FRAMELESSHELPER_BYTEARRAY_VIEW
# define FRAMELESSHELPER_BYTEARRAY_VIEW(ba) ba
#ifndef FRAMELESSHELPER_BYTEARRAY
# define FRAMELESSHELPER_BYTEARRAY(ba) ba
#endif
#ifndef FRAMELESSHELPER_STRING_VIEW
#ifndef FRAMELESSHELPER_STRING
# if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
# define FRAMELESSHELPER_STRING_VIEW(str) str##_L1
# define FRAMELESSHELPER_STRING(str) str##_L1
# else
# define FRAMELESSHELPER_STRING_VIEW(str) QLatin1String(str)
# define FRAMELESSHELPER_STRING(str) QLatin1String(str)
# endif
#endif
#ifndef FRAMELESSHELPER_STRING_VIEW_TYPE
#ifndef FRAMELESSHELPER_STRING_TYPE
# if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
# define FRAMELESSHELPER_STRING_VIEW_TYPE QLatin1StringView
# define FRAMELESSHELPER_STRING_TYPE QLatin1StringView
# else
# define FRAMELESSHELPER_STRING_VIEW_TYPE QLatin1String
# define FRAMELESSHELPER_STRING_TYPE QLatin1String
# endif
#endif
@ -162,12 +162,12 @@ QT_END_NAMESPACE
#ifndef FRAMELESSHELPER_BYTEARRAY_CONSTANT2
# define FRAMELESSHELPER_BYTEARRAY_CONSTANT2(name, ba) \
[[maybe_unused]] static constexpr const auto k##name = FRAMELESSHELPER_BYTEARRAY_VIEW(ba);
[[maybe_unused]] static constexpr const auto k##name = FRAMELESSHELPER_BYTEARRAY(ba);
#endif
#ifndef FRAMELESSHELPER_STRING_CONSTANT2
# define FRAMELESSHELPER_STRING_CONSTANT2(name, str) \
[[maybe_unused]] static constexpr const auto k##name = FRAMELESSHELPER_STRING_VIEW(str);
[[maybe_unused]] static constexpr const auto k##name = FRAMELESSHELPER_STRING(str);
#endif
#ifndef FRAMELESSHELPER_BYTEARRAY_CONSTANT

View File

@ -48,8 +48,6 @@ static Q_LOGGING_CATEGORY(lcFramelessConfig, "wangwenx190.framelesshelper.core.f
using namespace Global;
FRAMELESSHELPER_STRING_CONSTANT2(ConfigFileName, ".framelesshelper.ini")
struct FramelessConfigEntry
{
const char *env = nullptr;
@ -133,7 +131,7 @@ void FramelessConfig::reload(const bool force)
return nullptr;
}
const QDir appDir(QCoreApplication::applicationDirPath());
return std::make_unique<QSettings>(appDir.filePath(kConfigFileName), QSettings::IniFormat);
return std::make_unique<QSettings>(appDir.filePath(FRAMELESSHELPER_STRING_LITERAL(".framelesshelper.ini")), QSettings::IniFormat);
}();
for (int i = 0; i != OptionCount; ++i) {
const bool envVar = (!g_framelessConfigData()->disableEnvVar

View File

@ -66,18 +66,18 @@ static constexpr const std::array<ULONG_PTR, 10> g_registryKeyMap =
static constexpr const auto registryKeyCount = std::size(g_registryKeyMap);
static_assert(registryKeyCount == (static_cast<int>(RegistryRootKey::PerformanceNlsText) + 1));
[[maybe_unused]] static constexpr const std::array<FRAMELESSHELPER_STRING_VIEW_TYPE, registryKeyCount> g_registryStrMap =
[[maybe_unused]] static constexpr const std::array<FRAMELESSHELPER_STRING_TYPE, registryKeyCount> g_registryStrMap =
{
FRAMELESSHELPER_STRING_VIEW("HKEY_CLASSES_ROOT"),
FRAMELESSHELPER_STRING_VIEW("HKEY_CURRENT_USER"),
FRAMELESSHELPER_STRING_VIEW("HKEY_LOCAL_MACHINE"),
FRAMELESSHELPER_STRING_VIEW("HKEY_USERS"),
FRAMELESSHELPER_STRING_VIEW("HKEY_PERFORMANCE_DATA"),
FRAMELESSHELPER_STRING_VIEW("HKEY_CURRENT_CONFIG"),
FRAMELESSHELPER_STRING_VIEW("HKEY_DYN_DATA"),
FRAMELESSHELPER_STRING_VIEW("HKEY_CURRENT_USER_LOCAL_SETTINGS"),
FRAMELESSHELPER_STRING_VIEW("HKEY_PERFORMANCE_TEXT"),
FRAMELESSHELPER_STRING_VIEW("HKEY_PERFORMANCE_NLSTEXT")
FRAMELESSHELPER_STRING("HKEY_CLASSES_ROOT"),
FRAMELESSHELPER_STRING("HKEY_CURRENT_USER"),
FRAMELESSHELPER_STRING("HKEY_LOCAL_MACHINE"),
FRAMELESSHELPER_STRING("HKEY_USERS"),
FRAMELESSHELPER_STRING("HKEY_PERFORMANCE_DATA"),
FRAMELESSHELPER_STRING("HKEY_CURRENT_CONFIG"),
FRAMELESSHELPER_STRING("HKEY_DYN_DATA"),
FRAMELESSHELPER_STRING("HKEY_CURRENT_USER_LOCAL_SETTINGS"),
FRAMELESSHELPER_STRING("HKEY_PERFORMANCE_TEXT"),
FRAMELESSHELPER_STRING("HKEY_PERFORMANCE_NLSTEXT")
};
RegistryKey::RegistryKey(const RegistryRootKey root, const QString &key, QObject *parent) : QObject(parent)