remove dumb template stuff
This commit is contained in:
@@ -301,7 +301,7 @@ void ChatWindow::StartReplying(Snowflake message_id) {
|
|||||||
m_is_replying = true;
|
m_is_replying = true;
|
||||||
m_input->StartReplying();
|
m_input->StartReplying();
|
||||||
if (author.has_value())
|
if (author.has_value())
|
||||||
m_input_indicator->SetCustomMarkup("Replying to " + author->GetUsernameEscapedBold<false>());
|
m_input_indicator->SetCustomMarkup("Replying to " + author->GetUsernameEscapedBold());
|
||||||
else
|
else
|
||||||
m_input_indicator->SetCustomMarkup("Replying...");
|
m_input_indicator->SetCustomMarkup("Replying...");
|
||||||
}
|
}
|
||||||
|
@@ -62,7 +62,7 @@ FriendPickerDialogItem::FriendPickerDialogItem(Snowflake user_id)
|
|||||||
, m_layout(Gtk::ORIENTATION_HORIZONTAL) {
|
, m_layout(Gtk::ORIENTATION_HORIZONTAL) {
|
||||||
auto user = *Abaddon::Get().GetDiscordClient().GetUser(user_id);
|
auto user = *Abaddon::Get().GetDiscordClient().GetUser(user_id);
|
||||||
|
|
||||||
m_name.set_markup(user.GetUsernameEscapedBold<false>());
|
m_name.set_markup(user.GetUsernameEscapedBold());
|
||||||
m_name.set_single_line_mode(true);
|
m_name.set_single_line_mode(true);
|
||||||
|
|
||||||
m_avatar.property_pixbuf() = Abaddon::Get().GetImageManager().GetPlaceholder(32);
|
m_avatar.property_pixbuf() = Abaddon::Get().GetImageManager().GetPlaceholder(32);
|
||||||
|
@@ -89,14 +89,6 @@ std::string UserData::GetDisplayName() const {
|
|||||||
return Username;
|
return Username;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string UserData::GetUsername() const {
|
|
||||||
if (IsPomelo()) {
|
|
||||||
return Username;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Username + "#" + Discriminator;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string UserData::GetDisplayNameEscaped() const {
|
std::string UserData::GetDisplayNameEscaped() const {
|
||||||
return Glib::Markup::escape_text(GetDisplayName());
|
return Glib::Markup::escape_text(GetDisplayName());
|
||||||
}
|
}
|
||||||
@@ -105,11 +97,34 @@ std::string UserData::GetDisplayNameEscapedBold() const {
|
|||||||
return "<b>" + Glib::Markup::escape_text(GetDisplayName()) + "</b>";
|
return "<b>" + Glib::Markup::escape_text(GetDisplayName()) + "</b>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string UserData::GetUsername() const {
|
||||||
|
if (IsPomelo()) {
|
||||||
|
return Username;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Username + "#" + Discriminator;
|
||||||
|
}
|
||||||
|
|
||||||
std::string UserData::GetUsernameEscaped() const {
|
std::string UserData::GetUsernameEscaped() const {
|
||||||
if (IsPomelo()) {
|
if (IsPomelo()) {
|
||||||
return GetDisplayNameEscaped();
|
return Glib::Markup::escape_text(Username);
|
||||||
}
|
}
|
||||||
return Glib::Markup::escape_text(GetDisplayName()) + "#" + Discriminator;
|
|
||||||
|
return Glib::Markup::escape_text(Username) + "#" + Discriminator;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string UserData::GetUsernameEscapedBold() const {
|
||||||
|
if (IsPomelo()) {
|
||||||
|
return "<b>" + Glib::Markup::escape_text(Username) + "</b>";
|
||||||
|
}
|
||||||
|
return "<b>" + Glib::Markup::escape_text(Username) + "</b>#" + Discriminator;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string UserData::GetUsernameEscapedBoldAt() const {
|
||||||
|
if (IsPomelo()) {
|
||||||
|
return "<b>@" + Glib::Markup::escape_text(Username) + "</b>";
|
||||||
|
}
|
||||||
|
return "<b>@" + Glib::Markup::escape_text(Username) + "</b>#" + Discriminator;
|
||||||
}
|
}
|
||||||
|
|
||||||
void from_json(const nlohmann::json &j, UserData &m) {
|
void from_json(const nlohmann::json &j, UserData &m) {
|
||||||
|
@@ -84,17 +84,6 @@ struct UserData {
|
|||||||
[[nodiscard]] std::string GetDisplayNameEscapedBold() const;
|
[[nodiscard]] std::string GetDisplayNameEscapedBold() const;
|
||||||
[[nodiscard]] std::string GetUsername() const;
|
[[nodiscard]] std::string GetUsername() const;
|
||||||
[[nodiscard]] std::string GetUsernameEscaped() const;
|
[[nodiscard]] std::string GetUsernameEscaped() const;
|
||||||
template<bool with_at>
|
[[nodiscard]] std::string GetUsernameEscapedBold() const;
|
||||||
[[nodiscard]] inline std::string GetUsernameEscapedBold() const {
|
[[nodiscard]] std::string GetUsernameEscapedBoldAt() const;
|
||||||
// stupid microoptimization (nanooptimization) that shouldnt exist
|
|
||||||
if constexpr (with_at) {
|
|
||||||
std::string r = "<b>@" + Glib::Markup::escape_text(Username) + "</b>";
|
|
||||||
if (!IsPomelo()) r += "#" + Discriminator;
|
|
||||||
return r;
|
|
||||||
} else {
|
|
||||||
std::string r = "<b>" + Glib::Markup::escape_text(Username) + "</b>";
|
|
||||||
if (!IsPomelo()) r += "#" + Discriminator;
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
@@ -76,15 +76,15 @@ void HandleUserMentions(const Glib::RefPtr<Gtk::TextBuffer> &buf, Snowflake chan
|
|||||||
if (plain) {
|
if (plain) {
|
||||||
replacement = "@" + user->GetUsername();
|
replacement = "@" + user->GetUsername();
|
||||||
} else {
|
} else {
|
||||||
replacement = user->GetUsernameEscapedBold<true>();
|
replacement = user->GetUsernameEscapedBoldAt();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const auto role_id = user->GetHoistedRole(*channel->GuildID, true);
|
const auto role_id = user->GetHoistedRole(*channel->GuildID, true);
|
||||||
const auto role = discord.GetRole(role_id);
|
const auto role = discord.GetRole(role_id);
|
||||||
if (!role.has_value())
|
if (!role.has_value())
|
||||||
replacement = user->GetUsernameEscapedBold<true>();
|
replacement = user->GetUsernameEscapedBoldAt();
|
||||||
else
|
else
|
||||||
replacement = "<span color=\"#" + IntToCSSColor(role->Color) + "\">" + user->GetUsernameEscapedBold<true>() + "</span>";
|
replacement = "<span color=\"#" + IntToCSSColor(role->Color) + "\">" + user->GetUsernameEscapedBoldAt() + "</span>";
|
||||||
}
|
}
|
||||||
|
|
||||||
// regex returns byte positions and theres no straightforward way in the c++ bindings to deal with that :(
|
// regex returns byte positions and theres no straightforward way in the c++ bindings to deal with that :(
|
||||||
|
@@ -38,7 +38,7 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) {
|
|||||||
Glib::ustring user_markup = "<b>Unknown User</b>";
|
Glib::ustring user_markup = "<b>Unknown User</b>";
|
||||||
if (entry.UserID.has_value()) {
|
if (entry.UserID.has_value()) {
|
||||||
if (auto user = discord.GetUser(*entry.UserID); user.has_value())
|
if (auto user = discord.GetUser(*entry.UserID); user.has_value())
|
||||||
user_markup = discord.GetUser(*entry.UserID)->GetUsernameEscapedBold<false>();
|
user_markup = discord.GetUser(*entry.UserID)->GetUsernameEscapedBold();
|
||||||
}
|
}
|
||||||
|
|
||||||
// spaghetti moment
|
// spaghetti moment
|
||||||
|
@@ -150,9 +150,9 @@ void GuildSettingsMembersListItem::UpdateColor() {
|
|||||||
const auto user = *discord.GetUser(UserID);
|
const auto user = *discord.GetUser(UserID);
|
||||||
if (auto color_id = discord.GetMemberHoistedRole(GuildID, UserID, true); color_id.IsValid()) {
|
if (auto color_id = discord.GetMemberHoistedRole(GuildID, UserID, true); color_id.IsValid()) {
|
||||||
auto role = *discord.GetRole(color_id);
|
auto role = *discord.GetRole(color_id);
|
||||||
m_name.set_markup("<span color='#" + IntToCSSColor(role.Color) + "'>" + user.GetUsernameEscapedBold<false>() + "</span>");
|
m_name.set_markup("<span color='#" + IntToCSSColor(role.Color) + "'>" + user.GetUsernameEscapedBold() + "</span>");
|
||||||
} else
|
} else
|
||||||
m_name.set_markup(user.GetUsernameEscapedBold<false>());
|
m_name.set_markup(user.GetUsernameEscapedBold());
|
||||||
}
|
}
|
||||||
|
|
||||||
GuildSettingsMembersPaneInfo::GuildSettingsMembersPaneInfo(Snowflake guild_id)
|
GuildSettingsMembersPaneInfo::GuildSettingsMembersPaneInfo(Snowflake guild_id)
|
||||||
|
@@ -22,7 +22,7 @@ MutualFriendItem::MutualFriendItem(const UserData &user)
|
|||||||
img.LoadFromURL(user.GetAvatarURL("png", "32"), sigc::track_obj(cb, *this));
|
img.LoadFromURL(user.GetAvatarURL("png", "32"), sigc::track_obj(cb, *this));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_name.set_markup(user.GetUsernameEscapedBold<false>());
|
m_name.set_markup(user.GetUsernameEscapedBold());
|
||||||
|
|
||||||
m_name.set_valign(Gtk::ALIGN_CENTER);
|
m_name.set_valign(Gtk::ALIGN_CENTER);
|
||||||
add(m_avatar);
|
add(m_avatar);
|
||||||
|
Reference in New Issue
Block a user