Mail: Draw unread messages as bold

This commit is contained in:
Karol Kosek 2023-07-11 19:18:26 +02:00 committed by Sam Atkins
parent 411ffb7954
commit 619b53eaca
3 changed files with 12 additions and 1 deletions

View file

@ -6,6 +6,7 @@
*/
#include "InboxModel.h"
#include <LibGfx/Font/FontDatabase.h>
InboxModel::InboxModel(Vector<InboxEntry> entries)
: m_entries(move(entries))
@ -46,5 +47,9 @@ GUI::Variant InboxModel::data(GUI::ModelIndex const& index, GUI::ModelRole role)
if (index.column() == Column::Date)
return Gfx::TextAlignment::CenterRight;
}
if (role == GUI::ModelRole::Font) {
if (!value.seen)
return Gfx::FontDatabase::default_font().bold_variant();
}
return {};
}

View file

@ -14,6 +14,7 @@ struct InboxEntry {
DeprecatedString from;
DeprecatedString subject;
DeprecatedString date;
bool seen;
};
class InboxModel final : public GUI::Model {

View file

@ -290,6 +290,9 @@ void MailWidget::selected_mailbox()
.headers = { { "Date", "Subject", "From" } },
},
},
IMAP::FetchCommand::DataItem {
.type = IMAP::FetchCommand::DataItemType::Flags,
},
},
};
@ -309,6 +312,8 @@ void MailWidget::selected_mailbox()
auto& response_data = fetch_data.get<IMAP::FetchResponseData>();
auto& body_data = response_data.body_data();
auto seen = !response_data.flags().find_if([](StringView value) { return value.equals_ignoring_ascii_case("\\Seen"sv); }).is_end();
auto data_item_has_header = [](IMAP::FetchCommand::DataItem const& data_item, DeprecatedString const& search_header) {
if (!data_item.section.has_value())
return false;
@ -415,7 +420,7 @@ void MailWidget::selected_mailbox()
if (from.is_empty())
from = "(Unknown sender)";
InboxEntry inbox_entry { from, subject, date };
InboxEntry inbox_entry { from, subject, date, seen };
m_statusbar->set_text(String::formatted("[{}]: Loading entry {}", mailbox.name, ++i).release_value_but_fixme_should_propagate_errors());
active_inbox_entries.append(inbox_entry);