From ede1a8476acd54941c20b809455ba62b30302a4e Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 7 Nov 2022 01:01:28 +0100 Subject: Add option to limit number of lines of text drawn in Text class --- src/plugins/Fourchan.cpp | 13 +------------ src/plugins/Matrix.cpp | 2 ++ 2 files changed, 3 insertions(+), 12 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/Fourchan.cpp b/src/plugins/Fourchan.cpp index 051acc3..4cfaeaa 100644 --- a/src/plugins/Fourchan.cpp +++ b/src/plugins/Fourchan.cpp @@ -527,20 +527,9 @@ namespace QuickMedia { title_text.back() = ' '; std::string comment_text = html_to_text(comment_begin, comment_end - comment_begin, comment_by_postno, result_items, 0); - // TODO: Do the same when wrapping is implemented - // TODO: Remove this - int num_lines = 0; - for(size_t i = 0; i < comment_text.size(); ++i) { - if(comment_text[i] == '\n') { - ++num_lines; - if(num_lines == 6) { - comment_text = comment_text.substr(0, i) + " (...)"; - break; - } - } - } auto body_item = BodyItem::create(std::move(comment_text)); + body_item->set_title_max_lines(6); body_item->set_author(std::move(title_text)); body_item->url = std::to_string(thread_num.asInt64()); diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index e4a7bd1..14a5bbe 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -678,6 +678,7 @@ namespace QuickMedia { room->body_item->set_description_color(get_theme().faded_text_color); } room->body_item->set_description(std::move(room_desc)); + room->body_item->set_description_max_lines(3); if(set_room_as_unread) room->body_item->set_title_color(get_theme().attention_alert_text_color, true); room->last_message_read = false; @@ -687,6 +688,7 @@ namespace QuickMedia { } else if(last_new_message) { room->body_item->set_description(extract_first_line_remove_newline_elipses(matrix->message_get_author_displayname(last_new_message.get()), AUTHOR_MAX_LENGTH) + ": " + message_to_room_description_text(last_new_message.get())); room->body_item->set_description_color(get_theme().faded_text_color); + room->body_item->set_description_max_lines(3); rooms_page->move_room_to_top(room); room_tags_page->move_room_to_top(room); -- cgit v1.2.3