diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-03-08 02:14:17 -0500 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-03-08 02:14:17 -0500 |
commit | 40726a7cd6d958718e4853dd51be77b66992fb44 (patch) | |
tree | 6b705f3d2d73fadc9aa0119a8840e6f08be33330 /windows | |
parent | 447e3f8d387017da65a008e9bc060d29b413cc3b (diff) | |
download | abaddon-portaudio-40726a7cd6d958718e4853dd51be77b66992fb44.tar.gz abaddon-portaudio-40726a7cd6d958718e4853dd51be77b66992fb44.zip |
modify role color
Diffstat (limited to 'windows')
-rw-r--r-- | windows/guildsettings/rolespane.cpp | 46 | ||||
-rw-r--r-- | windows/guildsettings/rolespane.hpp | 2 |
2 files changed, 45 insertions, 3 deletions
diff --git a/windows/guildsettings/rolespane.cpp b/windows/guildsettings/rolespane.cpp index d92dc14..311e775 100644 --- a/windows/guildsettings/rolespane.cpp +++ b/windows/guildsettings/rolespane.cpp @@ -170,11 +170,13 @@ void GuildSettingsRolesPaneRolesListItem::UpdateItem(const RoleData &role) { GuildSettingsRolesPaneInfo::GuildSettingsRolesPaneInfo(Snowflake guild_id) : GuildID(guild_id) - , m_layout(Gtk::ORIENTATION_VERTICAL) { + , m_layout(Gtk::ORIENTATION_VERTICAL) + , m_meta(Gtk::ORIENTATION_HORIZONTAL) { set_propagate_natural_height(true); set_propagate_natural_width(true); - Abaddon::Get().GetDiscordClient().signal_role_update().connect(sigc::mem_fun(*this, &GuildSettingsRolesPaneInfo::OnRoleUpdate)); + auto &discord = Abaddon::Get().GetDiscordClient(); + discord.signal_role_update().connect(sigc::mem_fun(*this, &GuildSettingsRolesPaneInfo::OnRoleUpdate)); const auto cb = [this](GdkEventKey *e) -> bool { if (e->keyval == GDK_KEY_Return) @@ -192,6 +194,23 @@ GuildSettingsRolesPaneInfo::GuildSettingsRolesPaneInfo(Snowflake guild_id) m_role_name.set_margin_start(5); m_role_name.set_margin_end(5); + m_color_button.set_margin_top(5); + m_color_button.set_margin_bottom(5); + m_color_button.set_margin_start(5); + m_color_button.set_margin_end(5); + + m_color_button.signal_color_set().connect([this, &discord]() { + const auto color = m_color_button.get_rgba(); + const auto cb = [this, &discord](bool success) { + if (!success) { + m_color_button.set_rgba(IntToRGBA(discord.GetRole(RoleID)->Color)); + Gtk::MessageDialog dlg("Failed to set role color", false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); + dlg.run(); + } + }; + discord.ModifyRoleColor(GuildID, RoleID, color, cb); + }); + int left_ypos = 0; int right_ypos = 0; @@ -257,9 +276,13 @@ GuildSettingsRolesPaneInfo::GuildSettingsRolesPaneInfo(Snowflake guild_id) // clang-format on - m_layout.add(m_role_name); + m_meta.add(m_role_name); + m_meta.add(m_color_button); + m_layout.add(m_meta); m_layout.add(m_grid); add(m_layout); + m_meta.show(); + m_color_button.show(); m_role_name.show(); m_layout.show(); m_grid.show(); @@ -271,6 +294,14 @@ void GuildSettingsRolesPaneInfo::SetRole(const RoleData &role) { it = m_update_connections.erase(it); } + if (role.Color != 0) { + m_color_button.set_rgba(IntToRGBA(role.Color)); + } else { + static Gdk::RGBA trans; + trans.set_alpha(0.0); + m_color_button.set_rgba(trans); + } + m_role_name.set_text(role.Name); RoleID = role.ID; @@ -285,6 +316,15 @@ void GuildSettingsRolesPaneInfo::OnRoleUpdate(Snowflake guild_id, Snowflake role if (guild_id != GuildID || role_id != RoleID) return; const auto role = *Abaddon::Get().GetDiscordClient().GetRole(RoleID); m_role_name.set_text(role.Name); + + if (role.Color != 0) { + m_color_button.set_rgba(IntToRGBA(role.Color)); + } else { + static Gdk::RGBA trans; + trans.set_alpha(0.0); + m_color_button.set_rgba(trans); + } + m_perms = role.Permissions; for (const auto [perm, btn] : m_perm_items) btn->set_active((role.Permissions & perm) == perm); diff --git a/windows/guildsettings/rolespane.hpp b/windows/guildsettings/rolespane.hpp index 15f16cc..f2ff988 100644 --- a/windows/guildsettings/rolespane.hpp +++ b/windows/guildsettings/rolespane.hpp @@ -77,7 +77,9 @@ private: std::vector<sigc::connection> m_update_connections; Gtk::Box m_layout; + Gtk::Box m_meta; Gtk::Entry m_role_name; + Gtk::ColorButton m_color_button; Gtk::Grid m_grid; std::unordered_map<Permission, GuildSettingsRolesPanePermItem *> m_perm_items; |