Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

Commit

Permalink
string: use better name
Browse files Browse the repository at this point in the history
  • Loading branch information
wangwenx190 committed Jul 29, 2023
1 parent c6ca6cc commit 2f7a104
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 24 deletions.
20 changes: 10 additions & 10 deletions include/FramelessHelper/Core/framelesshelpercore_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/core/framelessconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions src/core/registrykey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2f7a104

Please sign in to comment.