diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2022-04-05 22:01:53 -0400 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2022-04-05 22:01:53 -0400 |
commit | 49685c39895af67d7ffcc50fdc02150b6ee44f72 (patch) | |
tree | 5c5c262f95a30e58582a285b467d05954ff5f35c /src/windows | |
parent | 9767e1e7fdef9262211ec676b4f0d4c30ff10649 (diff) | |
download | abaddon-portaudio-49685c39895af67d7ffcc50fdc02150b6ee44f72.tar.gz abaddon-portaudio-49685c39895af67d7ffcc50fdc02150b6ee44f72.zip |
fix up a bunch of clang-tidy stuff
mostly changing references, which i hope doesnt break stuff with models (TreeRow, iterators) since they gave me some strange problems in the past
Diffstat (limited to 'src/windows')
-rw-r--r-- | src/windows/guildsettings/auditlogpane.cpp | 90 | ||||
-rw-r--r-- | src/windows/guildsettings/banspane.cpp | 4 | ||||
-rw-r--r-- | src/windows/guildsettings/emojispane.cpp | 12 | ||||
-rw-r--r-- | src/windows/guildsettings/infopane.cpp | 8 | ||||
-rw-r--r-- | src/windows/guildsettings/invitespane.cpp | 4 | ||||
-rw-r--r-- | src/windows/guildsettings/memberspane.cpp | 12 | ||||
-rw-r--r-- | src/windows/guildsettings/rolespane.cpp | 12 | ||||
-rw-r--r-- | src/windows/mainwindow.cpp | 8 | ||||
-rw-r--r-- | src/windows/mainwindow.hpp | 2 | ||||
-rw-r--r-- | src/windows/profile/userinfopane.cpp | 12 | ||||
-rw-r--r-- | src/windows/profilewindow.cpp | 2 | ||||
-rw-r--r-- | src/windows/threadswindow.cpp | 2 | ||||
-rw-r--r-- | src/windows/threadswindow.hpp | 2 |
13 files changed, 84 insertions, 86 deletions
diff --git a/src/windows/guildsettings/auditlogpane.cpp b/src/windows/guildsettings/auditlogpane.cpp index 08f99da..868a18f 100644 --- a/src/windows/guildsettings/auditlogpane.cpp +++ b/src/windows/guildsettings/auditlogpane.cpp @@ -30,7 +30,7 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) { auto &discord = Abaddon::Get().GetDiscordClient(); auto guild = *discord.GetGuild(GuildID); for (const auto &entry : data.Entries) { - if (entry.TargetID == "") continue; + if (entry.TargetID.empty()) continue; auto expander = Gtk::manage(new Gtk::Expander); auto label = Gtk::manage(new Gtk::Label); @@ -56,7 +56,7 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) { if (entry.Changes.has_value()) for (const auto &change : *entry.Changes) { if (change.Key == "icon_hash") { - extra_markup.push_back("Set the server icon"); + extra_markup.emplace_back("Set the server icon"); } else if (change.Key == "name") { auto new_name = change.NewValue; if (new_name.has_value()) @@ -64,7 +64,7 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) { Glib::Markup::escape_text(new_name->get<std::string>()) + "</b>"); else - extra_markup.push_back("Set the server name"); + extra_markup.emplace_back("Set the server name"); } } } break; @@ -82,8 +82,8 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) { Glib::Markup::escape_text(change.NewValue->get<std::string>()) + "</b>"); else if (change.Key == "nsfw" && change.NewValue.has_value()) - extra_markup.push_back((*change.NewValue ? "Marked" : "Unmarked") + - " the channel as NSFW"s); + extra_markup.emplace_back((*change.NewValue ? "Marked" : "Unmarked") + + " the channel as NSFW"s); } } break; @@ -119,16 +119,16 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) { Glib::Markup::escape_text(change.NewValue->get<std::string>()) + "</b>"); else - extra_markup.push_back("Cleared the topic"); + extra_markup.emplace_back("Cleared the topic"); } else if (change.Key == "nsfw" && change.NewValue.has_value()) { - extra_markup.push_back((*change.NewValue ? "Marked" : "Unmarked") + " the channel as NSFW"s); + extra_markup.emplace_back((*change.NewValue ? "Marked" : "Unmarked") + " the channel as NSFW"s); } else if (change.Key == "rate_limit_per_user" && change.NewValue.has_value()) { const int secs = change.NewValue->get<int>(); if (secs == 0) - extra_markup.push_back("Disabled slowmode"); + extra_markup.emplace_back("Disabled slowmode"); else - extra_markup.push_back("Set slowmode to <b>" + - std::to_string(secs) + " seconds</b>"); + extra_markup.emplace_back("Set slowmode to <b>" + + std::to_string(secs) + " seconds</b>"); } } } break; @@ -186,9 +186,9 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) { " pruned <b>" + *entry.Options->MembersRemoved + "</b> members"; - extra_markup.push_back("For <b>" + - *entry.Options->DeleteMemberDays + - " days</b> of inactivity"); + extra_markup.emplace_back("For <b>" + + *entry.Options->DeleteMemberDays + + " days</b> of inactivity"); } break; case AuditLogActionType::MEMBER_BAN_ADD: { const auto target_user = discord.GetUser(entry.TargetID); @@ -213,13 +213,11 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) { if (entry.Changes.has_value()) for (const auto &change : *entry.Changes) { if (change.Key == "deaf" && change.NewValue.has_value()) - extra_markup.push_back( - (change.NewValue->get<bool>() ? "<b>Deafened</b>"s : "<b>Undeafened</b>"s) + - " them"); + extra_markup.emplace_back((change.NewValue->get<bool>() ? "<b>Deafened</b>"s : "<b>Undeafened</b>"s) + + " them"); else if (change.Key == "mute" && change.NewValue.has_value()) - extra_markup.push_back( - (change.NewValue->get<bool>() ? "<b>Muted</b>"s : "<b>Unmuted</b>"s) + - " them"); + extra_markup.emplace_back((change.NewValue->get<bool>() ? "<b>Muted</b>"s : "<b>Unmuted</b>"s) + + " them"); else if (change.Key == "nick" && change.NewValue.has_value()) extra_markup.push_back("Set their nickname to <b>" + Glib::Markup::escape_text(change.NewValue->get<std::string>()) + @@ -289,17 +287,17 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) { } else if (change.Key == "color" && change.NewValue.has_value()) { const auto col = change.NewValue->get<int>(); if (col == 0) - extra_markup.push_back("Removed the color"); + extra_markup.emplace_back("Removed the color"); else - extra_markup.push_back("Set the color to <b>" + - IntToCSSColor(col) + - "</b>"); + extra_markup.emplace_back("Set the color to <b>" + + IntToCSSColor(col) + + "</b>"); } else if (change.Key == "permissions") { - extra_markup.push_back("Updated the permissions"); + extra_markup.emplace_back("Updated the permissions"); } else if (change.Key == "mentionable" && change.NewValue.has_value()) { - extra_markup.push_back(change.NewValue->get<bool>() ? "Mentionable" : "Not mentionable"); + extra_markup.emplace_back(change.NewValue->get<bool>() ? "Mentionable" : "Not mentionable"); } else if (change.Key == "hoist" && change.NewValue.has_value()) { - extra_markup.push_back(change.NewValue->get<bool>() ? "Not hoisted" : "Hoisted"); + extra_markup.emplace_back(change.NewValue->get<bool>() ? "Not hoisted" : "Hoisted"); } } } break; @@ -324,13 +322,13 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) { } else if (change.Key == "max_uses" && change.NewValue.has_value()) { const auto uses = change.NewValue->get<int>(); if (uses == 0) - extra_markup.push_back("Which has <b>unlimited</b> uses"); + extra_markup.emplace_back("Which has <b>unlimited</b> uses"); else - extra_markup.push_back("Which has <b>" + std::to_string(uses) + "</b> uses"); + extra_markup.emplace_back("Which has <b>" + std::to_string(uses) + "</b> uses"); } else if (change.Key == "temporary" && change.NewValue.has_value()) { - extra_markup.push_back("With temporary <b>"s + - (change.NewValue->get<bool>() ? "on" : "off") + - "</b>"); + extra_markup.emplace_back("With temporary <b>"s + + (change.NewValue->get<bool>() ? "on" : "off") + + "</b>"); } // no max_age cuz fuck time } } break; @@ -378,7 +376,7 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) { Glib::Markup::escape_text(change.NewValue->get<std::string>()) + "</b>"); } else if (change.Key == "avatar_hash") { - extra_markup.push_back("Changed the avatar"); + extra_markup.emplace_back("Changed the avatar"); } else if (change.Key == "channel_id" && change.NewValue.has_value()) { const auto channel = discord.GetChannel(change.NewValue->get<Snowflake>()); if (channel.has_value()) { @@ -386,7 +384,7 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) { Glib::Markup::escape_text(*channel->Name) + "</b>"); } else { - extra_markup.push_back("Changed the channel"); + extra_markup.emplace_back("Changed the channel"); } } } @@ -552,18 +550,18 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) { if (change.Key == "name") extra_markup.push_back("Set the name to <b>" + Glib::Markup::escape_text(change.NewValue->get<std::string>()) + "</b>"); else if (change.Key == "archived") - extra_markup.push_back(change.NewValue->get<bool>() ? "Archived the thread" : "Unarchived the thread"); + extra_markup.emplace_back(change.NewValue->get<bool>() ? "Archived the thread" : "Unarchived the thread"); else if (change.Key == "auto_archive_duration") - extra_markup.push_back("Set auto archive duration to <b>"s + std::to_string(change.NewValue->get<int>()) + " minutes</b>"s); + extra_markup.emplace_back("Set auto archive duration to <b>"s + std::to_string(change.NewValue->get<int>()) + " minutes</b>"s); else if (change.Key == "rate_limit_per_user" && change.NewValue.has_value()) { const int secs = change.NewValue->get<int>(); if (secs == 0) - extra_markup.push_back("Disabled slowmode"); + extra_markup.emplace_back("Disabled slowmode"); else - extra_markup.push_back("Set slowmode to <b>" + - std::to_string(secs) + " seconds</b>"); + extra_markup.emplace_back("Set slowmode to <b>" + + std::to_string(secs) + " seconds</b>"); } else if (change.Key == "locked") - extra_markup.push_back(change.NewValue->get<bool>() ? "Locked the thread, restricting it to only be unarchived by moderators" : "Unlocked the thread, allowing it to be unarchived by non-moderators"); + extra_markup.emplace_back(change.NewValue->get<bool>() ? "Locked the thread, restricting it to only be unarchived by moderators" : "Unlocked the thread, allowing it to be unarchived by non-moderators"); } } } break; @@ -584,19 +582,19 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) { Glib::Markup::escape_text(change.NewValue->get<std::string>()) + "</b>"); else if (change.Key == "auto_archive_duration") - extra_markup.push_back("Set auto archive duration to <b>"s + std::to_string(change.NewValue->get<int>()) + " minutes</b>"s); + extra_markup.emplace_back("Set auto archive duration to <b>"s + std::to_string(change.NewValue->get<int>()) + " minutes</b>"s); else if (change.Key == "rate_limit_per_user" && change.NewValue.has_value()) { const int secs = change.NewValue->get<int>(); if (secs == 0) - extra_markup.push_back("Disabled slowmode"); + extra_markup.emplace_back("Disabled slowmode"); else - extra_markup.push_back("Set slowmode to <b>" + - std::to_string(secs) + - " seconds</b>"); + extra_markup.emplace_back("Set slowmode to <b>" + + std::to_string(secs) + + " seconds</b>"); } else if (change.Key == "locked") - extra_markup.push_back(change.NewValue->get<bool>() ? "Locked the thread, restricting it to only be unarchived by moderators" : "Unlocked the thread, allowing it to be unarchived by non-moderators"); + extra_markup.emplace_back(change.NewValue->get<bool>() ? "Locked the thread, restricting it to only be unarchived by moderators" : "Unlocked the thread, allowing it to be unarchived by non-moderators"); else if (change.Key == "archived") - extra_markup.push_back(change.NewValue->get<bool>() ? "Archived the thread" : "Unarchived the thread"); + extra_markup.emplace_back(change.NewValue->get<bool>() ? "Archived the thread" : "Unarchived the thread"); } } break; case AuditLogActionType::THREAD_DELETE: { diff --git a/src/windows/guildsettings/banspane.cpp b/src/windows/guildsettings/banspane.cpp index 97a70c4..d4b002c 100644 --- a/src/windows/guildsettings/banspane.cpp +++ b/src/windows/guildsettings/banspane.cpp @@ -94,7 +94,7 @@ void GuildSettingsBansPane::OnMenuUnban() { auto selected_row = *m_view.get_selection()->get_selected(); if (selected_row) { Snowflake id = selected_row[m_columns.m_col_id]; - auto cb = [this](DiscordError code) { + auto cb = [](DiscordError code) { if (code != DiscordError::NONE) { Gtk::MessageDialog dlg("Failed to unban user", false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); dlg.set_position(Gtk::WIN_POS_CENTER); @@ -119,7 +119,7 @@ bool GuildSettingsBansPane::OnTreeButtonPress(GdkEventButton *event) { m_menu_unban.set_sensitive(can_ban); auto selection = m_view.get_selection(); Gtk::TreeModel::Path path; - if (m_view.get_path_at_pos(event->x, event->y, path)) { + if (m_view.get_path_at_pos(static_cast<int>(event->x), static_cast<int>(event->y), path)) { m_view.get_selection()->select(path); m_menu.popup_at_pointer(reinterpret_cast<GdkEvent *>(event)); } diff --git a/src/windows/guildsettings/emojispane.cpp b/src/windows/guildsettings/emojispane.cpp index 57b697c..bdab6b8 100644 --- a/src/windows/guildsettings/emojispane.cpp +++ b/src/windows/guildsettings/emojispane.cpp @@ -52,7 +52,7 @@ GuildSettingsEmojisPane::GuildSettingsEmojisPane(Snowflake guild_id) m_filter->set_visible_func([this](const Gtk::TreeModel::const_iterator &iter) -> bool { const auto text = m_search.get_text(); - if (text == "") return true; + if (text.empty()) return true; return StringContainsCaseless((*iter)[m_columns.m_col_name], text); }); m_view.set_enable_search(false); @@ -71,12 +71,12 @@ GuildSettingsEmojisPane::GuildSettingsEmojisPane(Snowflake guild_id) column->pack_start(*renderer); column->add_attribute(renderer->property_text(), m_columns.m_col_name); renderer->property_editable() = true; - renderer->signal_edited().connect([this, renderer, column](const Glib::ustring &path, const Glib::ustring &text) { + renderer->signal_edited().connect([this](const Glib::ustring &path, const Glib::ustring &text) { std::string new_str; int size = 0; for (const auto ch : text) { if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') || ch == '_') - new_str += ch; + new_str += static_cast<char>(ch); else if (ch == ' ') new_str += '_'; if (++size == 32) break; @@ -174,7 +174,7 @@ void GuildSettingsEmojisPane::OnFetchEmojis(std::vector<EmojiData> emojis) { } void GuildSettingsEmojisPane::OnEditName(Snowflake id, const std::string &name) { - const auto cb = [this](DiscordError code) { + const auto cb = [](DiscordError code) { if (code != DiscordError::NONE) { Gtk::MessageDialog dlg("Failed to set emoji name", false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK); dlg.set_position(Gtk::WIN_POS_CENTER); @@ -197,7 +197,7 @@ void GuildSettingsEmojisPane::OnMenuDelete() { const auto id = static_cast<Snowflake>(selected_row[m_columns.m_col_id]); if (auto *window = dynamic_cast<Gtk::Window *>(get_toplevel())) if (Abaddon::Get().ShowConfirm("Are you sure you want to delete " + name + "?", window)) { - const auto cb = [this](DiscordError code) { + const auto cb = [](DiscordError code) { if (code != DiscordError::NONE) { Gtk::MessageDialog dlg("Failed to delete emoji", false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK); dlg.set_position(Gtk::WIN_POS_CENTER); @@ -234,7 +234,7 @@ bool GuildSettingsEmojisPane::OnTreeButtonPress(GdkEventButton *event) { auto selection = m_view.get_selection(); Gtk::TreeModel::Path path; - if (m_view.get_path_at_pos(event->x, event->y, path)) { + if (m_view.get_path_at_pos(static_cast<int>(event->x), static_cast<int>(event->y), path)) { m_view.get_selection()->select(path); m_menu.popup_at_pointer(reinterpret_cast<GdkEvent *>(event)); } diff --git a/src/windows/guildsettings/infopane.cpp b/src/windows/guildsettings/infopane.cpp index 9ef116f..bccfbf8 100644 --- a/src/windows/guildsettings/infopane.cpp +++ b/src/windows/guildsettings/infopane.cpp @@ -60,7 +60,7 @@ GuildSettingsInfoPane::GuildSettingsInfoPane(Snowflake id) guild_icon_url = guild.GetIconURL("gif", "512"); else guild_icon_url = guild.GetIconURL("png", "512"); - m_guild_icon_ev.signal_button_press_event().connect([this, guild_icon_url](GdkEventButton *event) -> bool { + m_guild_icon_ev.signal_button_press_event().connect([guild_icon_url](GdkEventButton *event) -> bool { if (event->type == GDK_BUTTON_PRESS) if (event->button == GDK_BUTTON_PRIMARY) LaunchBrowser(guild_icon_url); @@ -114,7 +114,7 @@ void GuildSettingsInfoPane::UpdateGuildIconFromData(const std::vector<uint8_t> & auto encoded = "data:" + mime + ";base64," + Glib::Base64::encode(std::string(data.begin(), data.end())); auto &discord = Abaddon::Get().GetDiscordClient(); - auto cb = [this](DiscordError code) { + auto cb = [](DiscordError code) { if (code != DiscordError::NONE) { Gtk::MessageDialog dlg("Failed to set guild icon", false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); dlg.set_position(Gtk::WIN_POS_CENTER); @@ -160,7 +160,7 @@ void GuildSettingsInfoPane::UpdateGuildIconPicker() { loader->write(data.data(), data.size()); loader->close(); UpdateGuildIconFromPixbuf(loader->get_pixbuf()); - } catch (const std::exception &) {}; + } catch (const std::exception &) {} } }); @@ -209,7 +209,7 @@ void GuildSettingsInfoPane::UpdateGuildIconClipboard() { UpdateGuildIconFromPixbuf(pb); return; - } catch (const std::exception &) {}; + } catch (const std::exception &) {} } if (cb->wait_is_image_available()) { diff --git a/src/windows/guildsettings/invitespane.cpp b/src/windows/guildsettings/invitespane.cpp index bec4784..2d737e9 100644 --- a/src/windows/guildsettings/invitespane.cpp +++ b/src/windows/guildsettings/invitespane.cpp @@ -96,7 +96,7 @@ void GuildSettingsInvitesPane::OnMenuDelete() { auto selected_row = *m_view.get_selection()->get_selected(); if (selected_row) { auto code = static_cast<Glib::ustring>(selected_row[m_columns.m_col_code]); - auto cb = [this](DiscordError code) { + auto cb = [](DiscordError code) { if (code != DiscordError::NONE) { Gtk::MessageDialog dlg("Failed to delete invite", false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); dlg.set_position(Gtk::WIN_POS_CENTER); @@ -115,7 +115,7 @@ bool GuildSettingsInvitesPane::OnTreeButtonPress(GdkEventButton *event) { m_menu_delete.set_sensitive(can_manage); auto selection = m_view.get_selection(); Gtk::TreeModel::Path path; - if (m_view.get_path_at_pos(event->x, event->y, path)) { + if (m_view.get_path_at_pos(static_cast<int>(event->x), static_cast<int>(event->y), path)) { m_view.get_selection()->select(path); m_menu.popup_at_pointer(reinterpret_cast<GdkEvent *>(event)); } diff --git a/src/windows/guildsettings/memberspane.cpp b/src/windows/guildsettings/memberspane.cpp index bda92b4..34650ad 100644 --- a/src/windows/guildsettings/memberspane.cpp +++ b/src/windows/guildsettings/memberspane.cpp @@ -64,7 +64,7 @@ GuildSettingsMembersPaneMembers::GuildSettingsMembersPaneMembers(Snowflake id) m_list.set_filter_func([this](Gtk::ListBoxRow *row_) -> bool { const auto search_term = m_search.get_text(); - if (search_term.size() == 0) return true; + if (search_term.empty()) return true; if (auto *row = dynamic_cast<GuildSettingsMembersListItem *>(row_)) return StringContainsCaseless(row->DisplayTerm, m_search.get_text()); return true; @@ -208,12 +208,12 @@ void GuildSettingsMembersPaneInfo::SetUser(Snowflake user_id) { m_id.set_text("User ID: " + std::to_string(user_id)); m_created.set_text("Account created: " + user_id.GetLocalTimestamp()); - if (member.JoinedAt != "") + if (!member.JoinedAt.empty()) m_joined.set_text("Joined server: " + FormatISO8601(member.JoinedAt)); else m_joined.set_text("Joined server: Unknown"); m_nickname.set_text("Nickname: " + member.Nickname); - m_nickname.set_visible(member.Nickname != ""); + m_nickname.set_visible(!member.Nickname.empty()); if (member.PremiumSince.has_value()) { m_boosting.set_text("Boosting since " + FormatISO8601(*member.PremiumSince)); m_boosting.show(); @@ -244,7 +244,7 @@ GuildSettingsMembersPaneRoles::GuildSettingsMembersPaneRoles(Snowflake guild_id) } } - m_list.set_sort_func([this](Gtk::ListBoxRow *a, Gtk::ListBoxRow *b) -> int { + m_list.set_sort_func([](Gtk::ListBoxRow *a, Gtk::ListBoxRow *b) -> int { auto *rowa = dynamic_cast<GuildSettingsMembersPaneRolesItem *>(a); auto *rowb = dynamic_cast<GuildSettingsMembersPaneRolesItem *>(b); return rowb->Position - rowa->Position; @@ -319,8 +319,8 @@ void GuildSettingsMembersPaneRoles::OnRoleToggle(Snowflake role_id, bool new_set // hack to prevent cb from being called if SetRoles is called before callback completion sigc::signal<void, bool> tmp; - m_update_connection.push_back(tmp.connect(std::move(cb))); - const auto tmp_cb = [this, tmp = std::move(tmp)](DiscordError code) { tmp.emit(code == DiscordError::NONE); }; + m_update_connection.emplace_back(tmp.connect(std::move(cb))); + const auto tmp_cb = [tmp = std::move(tmp)](DiscordError code) { tmp.emit(code == DiscordError::NONE); }; discord.SetMemberRoles(GuildID, UserID, m_set_role_ids.begin(), m_set_role_ids.end(), sigc::track_obj(tmp_cb, *this)); } diff --git a/src/windows/guildsettings/rolespane.cpp b/src/windows/guildsettings/rolespane.cpp index 3567e95..d4fa7c0 100644 --- a/src/windows/guildsettings/rolespane.cpp +++ b/src/windows/guildsettings/rolespane.cpp @@ -61,14 +61,14 @@ GuildSettingsRolesPaneRoles::GuildSettingsRolesPaneRoles(Snowflake guild_id) if (static_cast<size_t>(new_index) == num_rows) return true; // trying to move row below @everyone // make sure it wont modify a neighbor role u dont have perms to modify if (!discord.CanModifyRole(GuildID, row->RoleID)) return false; - const auto cb = [this](DiscordError code) { + const auto cb = [](DiscordError code) { if (code != DiscordError::NONE) { Gtk::MessageDialog dlg("Failed to set role position", false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); dlg.set_position(Gtk::WIN_POS_CENTER_ON_PARENT); dlg.run(); } }; - discord.ModifyRolePosition(GuildID, row->RoleID, new_pos, sigc::track_obj(cb, *this)); + discord.ModifyRolePosition(GuildID, row->RoleID, static_cast<int>(new_pos), sigc::track_obj(cb, *this)); return true; } return false; @@ -95,7 +95,7 @@ GuildSettingsRolesPaneRoles::GuildSettingsRolesPaneRoles(Snowflake guild_id) } } - m_list.set_sort_func([this](Gtk::ListBoxRow *rowa_, Gtk::ListBoxRow *rowb_) -> int { + m_list.set_sort_func([](Gtk::ListBoxRow *rowa_, Gtk::ListBoxRow *rowb_) -> int { auto *rowa = dynamic_cast<GuildSettingsRolesPaneRolesListItem *>(rowa_); auto *rowb = dynamic_cast<GuildSettingsRolesPaneRolesListItem *>(rowb_); return rowb->Position - rowa->Position; @@ -104,7 +104,7 @@ GuildSettingsRolesPaneRoles::GuildSettingsRolesPaneRoles(Snowflake guild_id) m_list.set_filter_func([this](Gtk::ListBoxRow *row_) -> bool { const auto search_term = m_search.get_text(); - if (search_term.size() == 0) return true; + if (search_term.empty()) return true; if (auto *row = dynamic_cast<GuildSettingsRolesPaneRolesListItem *>(row_)) return StringContainsCaseless(row->DisplayTerm, m_search.get_text()); return true; @@ -380,8 +380,8 @@ void GuildSettingsRolesPaneInfo::OnPermissionToggle(Permission perm, bool new_se m_perms &= ~perm; sigc::signal<void, bool> tmp; - m_update_connections.push_back(tmp.connect(std::move(cb))); - const auto tmp_cb = [this, tmp = std::move(tmp)](DiscordError code) { tmp.emit(code == DiscordError::NONE); }; + m_update_connections.emplace_back(tmp.connect(std::move(cb))); + const auto tmp_cb = [tmp = std::move(tmp)](DiscordError code) { tmp.emit(code == DiscordError::NONE); }; discord.ModifyRolePermissions(GuildID, RoleID, m_perms, sigc::track_obj(tmp_cb, *this)); } diff --git a/src/windows/mainwindow.cpp b/src/windows/mainwindow.cpp index c8abb75..89e89f0 100644 --- a/src/windows/mainwindow.cpp +++ b/src/windows/mainwindow.cpp @@ -84,7 +84,7 @@ MainWindow::MainWindow() m_signal_action_set_status.emit(); }); - m_menu_file_clear_cache.signal_activate().connect([this] { + m_menu_file_clear_cache.signal_activate().connect([] { Abaddon::Get().GetImageManager().ClearCache(); }); @@ -115,7 +115,7 @@ MainWindow::MainWindow() } }); - m_menu_view_mark_all_as_read.signal_activate().connect([this] { + m_menu_view_mark_all_as_read.signal_activate().connect([] { Abaddon::Get().GetDiscordClient().MarkAllAsRead(NOOP_CALLBACK); }); @@ -231,7 +231,7 @@ void MainWindow::UpdateChatPrependHistory(const std::vector<Message> &msgs) { m_chat.AddNewHistory(msgs); // given vector should be sorted ascending } -void MainWindow::InsertChatInput(std::string text) { +void MainWindow::InsertChatInput(const std::string &text) { m_chat.InsertChatInput(text); } @@ -260,7 +260,7 @@ void MainWindow::OnDiscordSubmenuPopup(const Gdk::Rectangle *flipped_rect, const const bool discord_active = Abaddon::Get().GetDiscordClient().IsStarted(); std::string token = Abaddon::Get().GetDiscordToken(); - m_menu_discord_connect.set_sensitive(token.size() > 0 && !discord_active); + m_menu_discord_connect.set_sensitive(!token.empty() && !discord_active); m_menu_discord_disconnect.set_sensitive(discord_active); m_menu_discord_join_guild.set_sensitive(discord_active); m_menu_discord_set_token.set_sensitive(!discord_active); diff --git a/src/windows/mainwindow.hpp b/src/windows/mainwindow.hpp index 7afe782..5e48f8a 100644 --- a/src/windows/mainwindow.hpp +++ b/src/windows/mainwindow.hpp @@ -19,7 +19,7 @@ public: void UpdateChatMessageDeleted(Snowflake id, Snowflake channel_id); void UpdateChatMessageUpdated(Snowflake id, Snowflake channel_id); void UpdateChatPrependHistory(const std::vector<Message> &msgs); - void InsertChatInput(std::string text); + void InsertChatInput(const std::string &text); Snowflake GetChatOldestListedMessage(); void UpdateChatReactionAdd(Snowflake id, const Glib::ustring ¶m); void UpdateChatReactionRemove(Snowflake id, const Glib::ustring ¶m); diff --git a/src/windows/profile/userinfopane.cpp b/src/windows/profile/userinfopane.cpp index a95a14c..a17dbff 100644 --- a/src/windows/profile/userinfopane.cpp +++ b/src/windows/profile/userinfopane.cpp @@ -39,8 +39,8 @@ ConnectionItem::ConnectionItem(const ConnectionData &conn) m_name.set_single_line_mode(true); m_name.set_ellipsize(Pango::ELLIPSIZE_END); m_box.add(m_name); - if (url != "") { - auto cb = [this, url](GdkEventButton *event) -> bool { + if (!url.empty()) { + auto cb = [url](GdkEventButton *event) -> bool { if (event->type == GDK_BUTTON_PRESS && event->button == GDK_BUTTON_PRIMARY) { LaunchBrowser(url); return true; @@ -102,7 +102,7 @@ void ConnectionsContainer::SetConnections(const std::vector<ConnectionData> &con if (supported_services.find(conn.Type) == supported_services.end()) continue; auto widget = Gtk::manage(new ConnectionItem(conn)); widget->show(); - attach(*widget, i % 2, i / 2, 1, 1); + attach(*widget, static_cast<int>(i % 2), static_cast<int>(i / 2), 1, 1); } set_halign(Gtk::ALIGN_FILL); @@ -185,7 +185,7 @@ ProfileUserInfoPane::ProfileUserInfoPane(Snowflake ID) m_created.get_style_context()->add_class("profile-info-created"); m_note.signal_update_note().connect([this](const Glib::ustring ¬e) { - auto cb = [this](DiscordError code) { + auto cb = [](DiscordError code) { if (code != DiscordError::NONE) { Gtk::MessageDialog dlg("Failed to set note", false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); dlg.set_position(Gtk::WIN_POS_CENTER); @@ -196,7 +196,7 @@ ProfileUserInfoPane::ProfileUserInfoPane(Snowflake ID) }); auto &discord = Abaddon::Get().GetDiscordClient(); - auto note_update_cb = [this](Snowflake id, std::string note) { + auto note_update_cb = [this](Snowflake id, const std::string ¬e) { if (id == UserID) m_note.SetNote(note); }; @@ -225,7 +225,7 @@ ProfileUserInfoPane::ProfileUserInfoPane(Snowflake ID) } void ProfileUserInfoPane::SetProfile(const UserProfileData &data) { - if (data.User.Bio.has_value() && *data.User.Bio != "") { + if (data.User.Bio.has_value() && !data.User.Bio->empty()) { m_bio.SetBio(*data.User.Bio); m_bio.show(); } else { diff --git a/src/windows/profilewindow.cpp b/src/windows/profilewindow.cpp index 9d93564..aff98c5 100644 --- a/src/windows/profilewindow.cpp +++ b/src/windows/profilewindow.cpp @@ -34,7 +34,7 @@ ProfileWindow::ProfileWindow(Snowflake user_id) if (user.HasAvatar()) AddPointerCursor(m_avatar_ev); - m_avatar_ev.signal_button_press_event().connect([this, user](GdkEventButton *event) -> bool { + m_avatar_ev.signal_button_press_event().connect([user](GdkEventButton *event) -> bool { if (event->type == GDK_BUTTON_PRESS && event->button == GDK_BUTTON_PRIMARY) { if (user.HasAnimatedAvatar()) LaunchBrowser(user.GetAvatarURL("gif", "512")); diff --git a/src/windows/threadswindow.cpp b/src/windows/threadswindow.cpp index c18819b..62cae19 100644 --- a/src/windows/threadswindow.cpp +++ b/src/windows/threadswindow.cpp @@ -62,7 +62,7 @@ ThreadsWindow::ThreadsWindow(const ChannelData &channel) add(m_box); } -bool ThreadsWindow::ListFilterFunc(Gtk::ListBoxRow *row_) { +bool ThreadsWindow::ListFilterFunc(Gtk::ListBoxRow *row_) const { if (auto *row = dynamic_cast<ThreadListRow *>(row_)) return (m_filter_mode == FILTER_PUBLIC && (row->Type == ChannelType::GUILD_PUBLIC_THREAD || row->Type == ChannelType::GUILD_NEWS_THREAD)) || (m_filter_mode == FILTER_PRIVATE && row->Type == ChannelType::GUILD_PRIVATE_THREAD); diff --git a/src/windows/threadswindow.hpp b/src/windows/threadswindow.hpp index ebcbd13..276e067 100644 --- a/src/windows/threadswindow.hpp +++ b/src/windows/threadswindow.hpp @@ -43,7 +43,7 @@ public: private: // this filtering is rather cringe but idk what a better alternative would be - bool ListFilterFunc(Gtk::ListBoxRow *row_); + bool ListFilterFunc(Gtk::ListBoxRow *row_) const; enum FilterMode { FILTER_PUBLIC = 0, |