summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2023-06-13 20:40:41 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2023-06-13 20:40:41 -0400
commita4a8293a0e9dc2e7023cc5f407eb78a505f22129 (patch)
tree9f3f2b5246086606e31804480d31122ff0d4e264
parentbfc5b0e682852173e03d703b1098530fd65a0dd4 (diff)
downloadabaddon-portaudio-a4a8293a0e9dc2e7023cc5f407eb78a505f22129.tar.gz
abaddon-portaudio-a4a8293a0e9dc2e7023cc5f407eb78a505f22129.zip
show pomelo names in profile window
-rw-r--r--README.md53
-rw-r--r--res/css/main.css4
-rw-r--r--src/discord/user.cpp8
-rw-r--r--src/discord/user.hpp1
-rw-r--r--src/windows/profilewindow.cpp18
-rw-r--r--src/windows/profilewindow.hpp2
6 files changed, 54 insertions, 32 deletions
diff --git a/README.md b/README.md
index c66af60..70996b2 100644
--- a/README.md
+++ b/README.md
@@ -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
diff --git a/res/css/main.css b/res/css/main.css
index dcbdf4f..12ce4d6 100644
--- a/res/css/main.css
+++ b/res/css/main.css
@@ -237,6 +237,10 @@
font-size: 20px;
}
+.profile-username-nondisplay {
+ margin-left: 10px;
+}
+
.profile-badge {
margin-right: 10px;
}
diff --git a/src/discord/user.cpp b/src/discord/user.cpp
index 7fbcdca..06073ad 100644
--- a/src/discord/user.cpp
+++ b/src/discord/user.cpp
@@ -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());
}
diff --git a/src/discord/user.hpp b/src/discord/user.hpp
index e88371a..05acd05 100644
--- a/src/discord/user.hpp
+++ b/src/discord/user.hpp
@@ -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;
diff --git a/src/windows/profilewindow.cpp b/src/windows/profilewindow.cpp
index 3d5f140..1469e49 100644
--- a/src/windows/profilewindow.cpp
+++ b/src/windows/profilewindow.cpp
@@ -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);
diff --git a/src/windows/profilewindow.hpp b/src/windows/profilewindow.hpp
index 2052e7b..fbc30e0 100644
--- a/src/windows/profilewindow.hpp
+++ b/src/windows/profilewindow.hpp
@@ -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;