Add QoL for editing filter titles

This commit is contained in:
blankie 2023-02-07 13:51:18 +07:00
parent c43dd3a4db
commit b21c31ad97
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 10 additions and 2 deletions

View File

@ -24,11 +24,18 @@ static void render_filter(Filter* filter, std::string* title, bool* request_remo
ImGui::AlignTextToFramePadding();
ImGui::Text("Title:%s%s", title->empty() ? "" : " ", title->c_str());
ImGui::SameLine();
bool popup_just_opened = false;
if (ImGui::Button("Edit")) {
ImGui::OpenPopup("change_filter_title");
popup_just_opened = true;
}
if (ImGui::BeginPopup("change_filter_title")) {
ImGui::InputText("##title", title);
ImGui::SetKeyboardFocusHere();
bool enter_pressed = ImGui::InputText("##title", title, ImGuiInputTextFlags_EnterReturnsTrue);
if (enter_pressed || (!popup_just_opened && !ImGui::IsItemActive())) {
ImGui::CloseCurrentPopup();
}
ImGui::EndPopup();
}
ImGui::SameLine();
@ -223,7 +230,8 @@ static void try_write_config(const Config& config) {
void filters_fragment(Config& active_config, Filters& __restrict active_filters, Filters& __restrict inactive_filters,
const std::vector<LogcatEntry>& logcat_entries, std::vector<size_t>& filtered_logcat_entry_offsets,
bool* p_open) {
ImGui::TextUnformatted("You can use regex for strings by prepending \"regex:\"");
ImGui::TextWrapped("You can use regex for strings by prepending \"regex:\". "
"While editing titles, press Enter to use the new title or press Escape to keep the old one");
for (Filters::iterator it = inactive_filters.begin(); it != inactive_filters.end();) {
bool removal_requested = false;