summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2021-05-26 02:50:22 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2021-05-26 02:50:22 -0400
commit484e21e693d1a5d25c1ef959ba531bc584ef4eba (patch)
tree5b0e1ba2064b21ca51a3712d94d45488fe53256d
parent5d8209cf10e007f087ff9c7ce023d0530a76815b (diff)
downloadabaddon-portaudio-484e21e693d1a5d25c1ef959ba531bc584ef4eba.tar.gz
abaddon-portaudio-484e21e693d1a5d25c1ef959ba531bc584ef4eba.zip
display user bio in profile window
-rw-r--r--discord/user.cpp2
-rw-r--r--discord/user.hpp3
-rw-r--r--windows/profile/userinfopane.cpp36
-rw-r--r--windows/profile/userinfopane.hpp13
-rw-r--r--windows/profilewindow.cpp2
5 files changed, 51 insertions, 5 deletions
diff --git a/discord/user.cpp b/discord/user.cpp
index a0bce0b..d1f6755 100644
--- a/discord/user.cpp
+++ b/discord/user.cpp
@@ -58,6 +58,8 @@ void from_json(const nlohmann::json &j, UserData &m) {
JS_O("mobile", m.IsMobile);
JS_ON("nsfw_allowed", m.IsNSFWAllowed);
JS_ON("phone", m.Phone);
+ JS_ON("bio", m.Bio);
+ JS_ON("banner", m.BannerHash);
}
void to_json(nlohmann::json &j, const UserData &m) {
diff --git a/discord/user.hpp b/discord/user.hpp
index dc3223d..996ba98 100644
--- a/discord/user.hpp
+++ b/discord/user.hpp
@@ -52,6 +52,9 @@ struct UserData {
std::optional<bool> IsMobile;
std::optional<bool> IsNSFWAllowed; // null
std::optional<std::string> Phone; // null?
+ // for now (unserialized)
+ std::optional<std::string> BannerHash; // null
+ std::optional<std::string> Bio; // null
friend void from_json(const nlohmann::json &j, UserData &m);
friend void to_json(nlohmann::json &j, const UserData &m);
diff --git a/windows/profile/userinfopane.cpp b/windows/profile/userinfopane.cpp
index 384f62c..e9309d6 100644
--- a/windows/profile/userinfopane.cpp
+++ b/windows/profile/userinfopane.cpp
@@ -158,6 +158,25 @@ NotesContainer::type_signal_update_note NotesContainer::signal_update_note() {
return m_signal_update_note;
}
+BioContainer::BioContainer()
+ : Gtk::Box(Gtk::ORIENTATION_VERTICAL) {
+ m_label.set_markup("<b>ABOUT ME</b>");
+ m_label.set_halign(Gtk::ALIGN_START);
+ m_bio.set_halign(Gtk::ALIGN_START);
+ m_bio.set_line_wrap(true);
+ m_bio.set_line_wrap_mode(Pango::WRAP_WORD_CHAR);
+
+ m_label.show();
+ m_bio.show();
+
+ add(m_label);
+ add(m_bio);
+}
+
+void BioContainer::SetBio(const std::string &bio) {
+ m_bio.set_text(bio);
+}
+
ProfileUserInfoPane::ProfileUserInfoPane(Snowflake ID)
: Gtk::Box(Gtk::ORIENTATION_VERTICAL)
, UserID(ID) {
@@ -194,12 +213,23 @@ ProfileUserInfoPane::ProfileUserInfoPane(Snowflake ID)
m_conns.set_halign(Gtk::ALIGN_START);
m_conns.set_hexpand(true);
+ m_created.show();
+ m_note.show();
+ m_conns.show();
+
add(m_created);
+ add(m_bio);
add(m_note);
add(m_conns);
- show_all_children();
}
-void ProfileUserInfoPane::SetConnections(const std::vector<ConnectionData> &connections) {
- m_conns.SetConnections(connections);
+void ProfileUserInfoPane::SetProfile(const UserProfileData &data) {
+ if (data.User.Bio.has_value() && *data.User.Bio != "") {
+ m_bio.SetBio(*data.User.Bio);
+ m_bio.show();
+ } else {
+ m_bio.hide();
+ }
+
+ m_conns.SetConnections(data.ConnectedAccounts);
}
diff --git a/windows/profile/userinfopane.hpp b/windows/profile/userinfopane.hpp
index 169ac25..b29cb76 100644
--- a/windows/profile/userinfopane.hpp
+++ b/windows/profile/userinfopane.hpp
@@ -39,16 +39,27 @@ public:
type_signal_update_note signal_update_note();
};
+class BioContainer : public Gtk::Box {
+public:
+ BioContainer();
+ void SetBio(const std::string &bio);
+
+private:
+ Gtk::Label m_label;
+ Gtk::Label m_bio;
+};
+
class ProfileUserInfoPane : public Gtk::Box {
public:
ProfileUserInfoPane(Snowflake ID);
- void SetConnections(const std::vector<ConnectionData> &connections);
+ void SetProfile(const UserProfileData &data);
Snowflake UserID;
private:
Gtk::Label m_created;
+ BioContainer m_bio;
NotesContainer m_note;
ConnectionsContainer m_conns;
};
diff --git a/windows/profilewindow.cpp b/windows/profilewindow.cpp
index d0fefc7..90e98f1 100644
--- a/windows/profilewindow.cpp
+++ b/windows/profilewindow.cpp
@@ -96,7 +96,7 @@ ProfileWindow::ProfileWindow(Snowflake user_id)
}
void ProfileWindow::OnFetchProfile(const UserProfileData &data) {
- m_pane_info.SetConnections(data.ConnectedAccounts);
+ m_pane_info.SetProfile(data);
m_pane_guilds.SetMutualGuilds(data.MutualGuilds);
for (auto child : m_badges.get_children())