Skip to content

Commit

Permalink
Avoid using static non-constexpr string in struct
Browse files Browse the repository at this point in the history
-Wclazy-non-pod-global-static
  • Loading branch information
alex1701c committed Oct 13, 2024
1 parent 3319fb9 commit 7bc6779
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions src/core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ struct Config {
// General config keys
constexpr static const auto ConfigFileName = "emojirunnerrc";
constexpr static const auto RelativeConfigFolder = "/.config/krunnerplugins/";
const static QString SharedEmojiFileName;
const static QString CustomEmojiFilePath;
constexpr static QLatin1String SharedEmojiFileName{"emojirunner/emojis.json"};
constexpr static const auto RootGroup = "Config";
constexpr static const auto GlobalSearch = "globalSearch";
constexpr static const auto PasteAction = "pasteAction";
Expand All @@ -32,6 +31,11 @@ struct Config {
constexpr static const auto CustomCategory = "Custom";
constexpr static const auto SmileysEmotionsCategory = "Smileys & Emotion";
constexpr static const auto DisabledCategories = "disabledCategories";

static QString emojiFilePath()
{
return QDir::homePath() + QLatin1String("/.local/share/emojirunner/customemojis.json");
}
};

// Keys of the emoji json object
Expand All @@ -44,8 +48,5 @@ struct JSONEmoji {
constexpr static const auto IosVersion = "ios_version";
constexpr static const auto Tags = "tags";
};

const QString Config::CustomEmojiFilePath = QDir::homePath() + "/.local/share/emojirunner/customemojis.json";
const QString Config::SharedEmojiFileName = "emojirunner/emojis.json";
}
#endif // EMOJIRUNNER_CONFIG_H
2 changes: 1 addition & 1 deletion src/core/FileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ QList<EmojiCategory> FileReader::getEmojiCategories(bool getAllEmojis) const
}

// Read custom emojis
QFile customEmojis(Config::CustomEmojiFilePath);
QFile customEmojis(Config::emojiFilePath());
if (customEmojis.exists() && customEmojis.open(QFile::ReadOnly)) {
auto customEmojiMap = parseEmojiFile(getAllEmojis, customEmojis);
// Combine the two maps
Expand Down
2 changes: 1 addition & 1 deletion src/runner/emojirunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ EmojiRunner::EmojiRunner(QObject *parent, const KPluginMetaData &pluginMetaData,
{
Q_UNUSED(args)
// Add file watcher for config
watcher.addPath(Config::CustomEmojiFilePath);
watcher.addPath(Config::emojiFilePath());
connect(&watcher, &QFileSystemWatcher::fileChanged, this, [this](const QString &path) {
watcher.addPath(path);
reloadConfiguration();
Expand Down

0 comments on commit 7bc6779

Please sign in to comment.