show pomelo names in profile window

This commit is contained in:
ouwou
2023-06-13 20:40:41 -04:00
parent bfc5b0e682
commit a4a8293a0e
6 changed files with 54 additions and 32 deletions

View File

@@ -226,32 +226,33 @@ Used in guild settings popup:
Used in profile popup:
| Selector | Description |
|------------------------------|---------------------------------------------------------|
| `.mutual-friend-item` | Applied to every item in the mutual friends list |
| `.mutual-friend-item-name` | Name in mutual friend item |
| `.mutual-friend-item-avatar` | Avatar in mutual friend item |
| `.mutual-guild-item` | Applied to every item in the mutual guilds list |
| `.mutual-guild-item-name` | Name in mutual guild item |
| `.mutual-guild-item-icon` | Icon in mutual guild item |
| `.mutual-guild-item-nick` | User nickname in mutual guild item |
| `.profile-connection` | Applied to every item in the user connections list |
| `.profile-connection-label` | Label in profile connection item |
| `.profile-connection-check` | Checkmark in verified profile connection items |
| `.profile-connections` | Container for profile connections |
| `.profile-notes` | Container for notes in profile window |
| `.profile-notes-label` | Label that says "NOTE" |
| `.profile-notes-text` | Actual note text |
| `.profile-info-pane` | Applied to container for info section of profile popup |
| `.profile-info-created` | Label for creation date of profile |
| `.user-profile-window` | |
| `.profile-main-container` | Inner container for profile |
| `.profile-avatar` | |
| `.profile-username` | |
| `.profile-switcher` | Buttons used to switch viewed section of profile |
| `.profile-stack` | Container for profile info that can be switched between |
| `.profile-badges` | Container for badges |
| `.profile-badge` | |
| Selector | Description |
|--------------------------------|------------------------------------------------------------|
| `.mutual-friend-item` | Applied to every item in the mutual friends list |
| `.mutual-friend-item-name` | Name in mutual friend item |
| `.mutual-friend-item-avatar` | Avatar in mutual friend item |
| `.mutual-guild-item` | Applied to every item in the mutual guilds list |
| `.mutual-guild-item-name` | Name in mutual guild item |
| `.mutual-guild-item-icon` | Icon in mutual guild item |
| `.mutual-guild-item-nick` | User nickname in mutual guild item |
| `.profile-connection` | Applied to every item in the user connections list |
| `.profile-connection-label` | Label in profile connection item |
| `.profile-connection-check` | Checkmark in verified profile connection items |
| `.profile-connections` | Container for profile connections |
| `.profile-notes` | Container for notes in profile window |
| `.profile-notes-label` | Label that says "NOTE" |
| `.profile-notes-text` | Actual note text |
| `.profile-info-pane` | Applied to container for info section of profile popup |
| `.profile-info-created` | Label for creation date of profile |
| `.user-profile-window` | |
| `.profile-main-container` | Inner container for profile |
| `.profile-avatar` | |
| `.profile-username` | User's display name (username for backwards compatibility) |
| `.profile-username-nondisplay` | User's actual username |
| `.profile-switcher` | Buttons used to switch viewed section of profile |
| `.profile-stack` | Container for profile info that can be switched between |
| `.profile-badges` | Container for badges |
| `.profile-badge` | |
### Settings

View File

@@ -237,6 +237,10 @@
font-size: 20px;
}
.profile-username-nondisplay {
margin-left: 10px;
}
.profile-badge {
margin-right: 10px;
}

View File

@@ -89,6 +89,14 @@ std::string UserData::GetName() const {
return Username;
}
std::string UserData::GetUsername() const {
if (IsPomelo()) {
return Username;
}
return Username + "#" + Discriminator;
}
std::string UserData::GetEscapedName() const {
return Glib::Markup::escape_text(GetName());
}

View File

@@ -80,6 +80,7 @@ struct UserData {
[[nodiscard]] Snowflake GetHoistedRole(Snowflake guild_id, bool with_color = false) const;
[[nodiscard]] std::string GetMention() const;
[[nodiscard]] std::string GetName() const;
[[nodiscard]] std::string GetUsername() const;
[[nodiscard]] std::string GetEscapedName() const;
[[nodiscard]] std::string GetEscapedBoldName() const;
[[nodiscard]] std::string GetEscapedString() const;

View File

@@ -5,6 +5,7 @@ ProfileWindow::ProfileWindow(Snowflake user_id)
, m_main(Gtk::ORIENTATION_VERTICAL)
, m_upper(Gtk::ORIENTATION_HORIZONTAL)
, m_badges(Gtk::ORIENTATION_HORIZONTAL)
, m_name_box(Gtk::ORIENTATION_VERTICAL)
, m_pane_info(user_id)
, m_pane_guilds(user_id)
, m_pane_friends(user_id) {
@@ -15,14 +16,15 @@ ProfileWindow::ProfileWindow(Snowflake user_id)
set_name("user-profile");
set_default_size(450, 375);
set_title(user.Username + "#" + user.Discriminator);
set_title(user.GetUsername());
set_position(Gtk::WIN_POS_CENTER);
get_style_context()->add_class("app-window");
get_style_context()->add_class("app-popup");
get_style_context()->add_class("user-profile-window");
m_main.get_style_context()->add_class("profile-main-container");
m_avatar.get_style_context()->add_class("profile-avatar");
m_username.get_style_context()->add_class("profile-username");
m_displayname.get_style_context()->add_class("profile-username");
m_username.get_style_context()->add_class("profile-username-nondisplay");
m_switcher.get_style_context()->add_class("profile-switcher");
m_stack.get_style_context()->add_class("profile-stack");
m_badges.get_style_context()->add_class("profile-badges");
@@ -31,8 +33,8 @@ ProfileWindow::ProfileWindow(Snowflake user_id)
m_scroll.set_vexpand(true);
m_scroll.set_propagate_natural_height(true);
if (user.HasAvatar())
AddPointerCursor(m_avatar_ev);
if (user.HasAvatar()) AddPointerCursor(m_avatar_ev);
m_avatar_ev.signal_button_release_event().connect([user](GdkEventButton *event) -> bool {
if (event->type == GDK_BUTTON_RELEASE && event->button == GDK_BUTTON_PRIMARY) {
if (user.HasAnimatedAvatar())
@@ -62,7 +64,8 @@ ProfileWindow::ProfileWindow(Snowflake user_id)
img.LoadFromURL(user.GetAvatarURL("png", "64"), sigc::track_obj(cb, *this));
}
m_username.set_markup(user.GetEscapedString());
m_displayname.set_markup(user.GetEscapedName());
m_username.set_label(user.GetUsername());
m_switcher.set_stack(m_stack);
m_switcher.set_halign(Gtk::ALIGN_START);
@@ -79,10 +82,13 @@ ProfileWindow::ProfileWindow(Snowflake user_id)
m_upper.set_halign(Gtk::ALIGN_START);
m_avatar.set_halign(Gtk::ALIGN_START);
m_displayname.set_halign(Gtk::ALIGN_START);
m_username.set_halign(Gtk::ALIGN_START);
m_avatar_ev.add(m_avatar);
m_upper.add(m_avatar_ev);
m_upper.add(m_username);
m_upper.add(m_name_box);
m_name_box.add(m_displayname);
m_name_box.add(m_username);
m_badges_scroll.add(m_badges);
m_upper.add(m_badges_scroll);
m_main.add(m_upper);

View File

@@ -16,9 +16,11 @@ private:
Gtk::Box m_main;
Gtk::Box m_upper;
Gtk::Box m_badges;
Gtk::Box m_name_box;
Gtk::ScrolledWindow m_badges_scroll;
Gtk::EventBox m_avatar_ev;
Gtk::Image m_avatar;
Gtk::Label m_displayname;
Gtk::Label m_username;
Gtk::ScrolledWindow m_scroll;
Gtk::Stack m_stack;