From b677db90483610848e7f6789893ed3db8b226328 Mon Sep 17 00:00:00 2001 From: chris <62446202+5xp@users.noreply.github.com> Date: Sat, 1 Jun 2024 15:46:42 -0500 Subject: [PATCH 1/2] Correct default setting for hideconsole in README (#303) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c2fab19..b1d1a35 100644 --- a/README.md +++ b/README.md @@ -347,7 +347,7 @@ For example, memory_db would be set by adding `memory_db = true` under the line | Setting | Type | Default | Description | |---------------|---------|---------|-------------------------| -| `hideconsole` | boolean | true | Hide console on startup | +| `hideconsole` | boolean | false | Hide console on startup | ### Environment variables From f8e7ea3ca93d919db744b9e30113fe8f5907761e Mon Sep 17 00:00:00 2001 From: Skeevert <45735359+Skeevert@users.noreply.github.com> Date: Mon, 3 Jun 2024 03:10:40 +0300 Subject: [PATCH 2/2] Refactoring: changed user flag enum to enum class (#299) --- src/discord/user.cpp | 60 +++++++++++++++++------------------ src/discord/user.hpp | 3 +- src/windows/profilewindow.cpp | 5 +-- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/discord/user.cpp b/src/discord/user.cpp index 8129273..a5bb0ae 100644 --- a/src/discord/user.cpp +++ b/src/discord/user.cpp @@ -220,34 +220,34 @@ void UserData::update_from_json(const nlohmann::json &j) { } const char *UserData::GetFlagName(uint64_t flag) { - switch (flag) { - case DiscordEmployee: + switch (static_cast(flag)) { + case UserData::EFlags::DiscordEmployee: return "discordstaff"; - case PartneredServerOwner: + case UserData::EFlags::PartneredServerOwner: return "partneredowner"; - case HypeSquadEvents: + case UserData::EFlags::HypeSquadEvents: return "hypesquadevents"; - case BugHunterLevel1: + case UserData::EFlags::BugHunterLevel1: return "discordbughunter"; - case HouseBravery: + case UserData::EFlags::HouseBravery: return "hypesquadbravery"; - case HouseBrilliance: + case UserData::EFlags::HouseBrilliance: return "hypesquadbrilliance"; - case HouseBalance: + case UserData::EFlags::HouseBalance: return "hypesquadbalance"; - case EarlySupporter: + case UserData::EFlags::EarlySupporter: return "earlysupporter"; - case TeamUser: + case UserData::EFlags::TeamUser: return "teamuser"; - case System: + case UserData::EFlags::System: return "system"; - case BugHunterLevel2: + case UserData::EFlags::BugHunterLevel2: return "discordbughunter2"; - case VerifiedBot: + case UserData::EFlags::VerifiedBot: return "verifiedbot"; - case EarlyVerifiedBotDeveloper: + case UserData::EFlags::EarlyVerifiedBotDeveloper: return "earlyverifiedbotdeveloper"; - case CertifiedModerator: + case UserData::EFlags::CertifiedModerator: return "certifiedmoderator"; default: return "unknown"; @@ -255,34 +255,34 @@ const char *UserData::GetFlagName(uint64_t flag) { } const char *UserData::GetFlagReadableName(uint64_t flag) { - switch (flag) { - case DiscordEmployee: + switch (static_cast(flag)) { + case UserData::EFlags::DiscordEmployee: return "Discord Staff"; - case PartneredServerOwner: + case UserData::EFlags::PartneredServerOwner: return "Partnered Server Owner"; - case HypeSquadEvents: + case UserData::EFlags::HypeSquadEvents: return "HypeSquad Events"; - case BugHunterLevel1: + case UserData::EFlags::BugHunterLevel1: return "Discord Bug Hunter"; - case HouseBravery: + case UserData::EFlags::HouseBravery: return "HypeSquad Bravery"; - case HouseBrilliance: + case UserData::EFlags::HouseBrilliance: return "HypeSquad Brilliance"; - case HouseBalance: + case UserData::EFlags::HouseBalance: return "HypeSquad Balance"; - case EarlySupporter: + case UserData::EFlags::EarlySupporter: return "Early Supporter"; - case TeamUser: + case UserData::EFlags::TeamUser: return "Team User"; // ??? - case System: + case UserData::EFlags::System: return "System"; - case BugHunterLevel2: + case UserData::EFlags::BugHunterLevel2: return "Discord Bug Hunter Level 2"; - case VerifiedBot: + case UserData::EFlags::VerifiedBot: return "Verified Bot"; - case EarlyVerifiedBotDeveloper: + case UserData::EFlags::EarlyVerifiedBotDeveloper: return "Early Verified Bot Developer"; - case CertifiedModerator: + case UserData::EFlags::CertifiedModerator: return "Discord Certified Moderator"; default: return ""; diff --git a/src/discord/user.hpp b/src/discord/user.hpp index 3e356a4..6aee6be 100644 --- a/src/discord/user.hpp +++ b/src/discord/user.hpp @@ -11,8 +11,7 @@ enum class EPremiumType { }; struct UserData { - // todo: enum class? (for consistencys sake) - enum { + enum class EFlags : uint64_t { DiscordEmployee = 1 << 0, PartneredServerOwner = 1 << 1, HypeSquadEvents = 1 << 2, diff --git a/src/windows/profilewindow.cpp b/src/windows/profilewindow.cpp index 8c4b67f..4547ae4 100644 --- a/src/windows/profilewindow.cpp +++ b/src/windows/profilewindow.cpp @@ -1,6 +1,7 @@ #include "profilewindow.hpp" #include "abaddon.hpp" +#include "discord/user.hpp" #include "util.hpp" ProfileWindow::ProfileWindow(Snowflake user_id) @@ -116,13 +117,13 @@ void ProfileWindow::OnFetchProfile(const UserProfileData &data) { if (!data.User.PublicFlags.has_value()) return; const auto x = *data.User.PublicFlags; - for (uint64_t i = 1; i <= UserData::MaxFlag; i <<= 1) { + for (uint64_t i = 1; i <= static_cast(UserData::EFlags::MaxFlag); i <<= 1) { if (!(x & i)) continue; const std::string name = UserData::GetFlagName(i); if (name == "unknown") continue; Glib::RefPtr pixbuf; try { - if (name == "verifiedbot") + if (i == static_cast(UserData::EFlags::VerifiedBot)) pixbuf = Gdk::Pixbuf::create_from_file(Abaddon::GetResPath("/checkmark.png"), 24, 24); else pixbuf = Gdk::Pixbuf::create_from_file(Abaddon::GetResPath("/" + name + ".png"), 24, 24);