mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
Mail: Use set_activates_on_selection and on_activation callback
Preparation for a sortable mailbox. Otherwise the model would resort itself and select mail again forever. Arrow keys will no longer load mail automatically, now you also need to hit Enter.
This commit is contained in:
parent
59968c97f0
commit
ea70b96cf8
Notes:
sideshowbarker
2024-07-17 01:21:02 +09:00
Author: https://github.com/krkk Commit: https://github.com/SerenityOS/serenity/commit/ea70b96cf8 Pull-request: https://github.com/SerenityOS/serenity/pull/20831 Reviewed-by: https://github.com/ADKaster ✅
2 changed files with 10 additions and 12 deletions
|
@ -32,12 +32,14 @@ MailWidget::MailWidget()
|
|||
m_web_view = *find_descendant_of_type_named<WebView::OutOfProcessWebView>("web_view");
|
||||
m_statusbar = *find_descendant_of_type_named<GUI::Statusbar>("statusbar");
|
||||
|
||||
m_mailbox_list->on_selection_change = [this] {
|
||||
selected_mailbox();
|
||||
m_mailbox_list->set_activates_on_selection(true);
|
||||
m_mailbox_list->on_activation = [this](auto& index) {
|
||||
selected_mailbox(index);
|
||||
};
|
||||
|
||||
m_individual_mailbox_view->on_selection_change = [this] {
|
||||
selected_email_to_load();
|
||||
m_individual_mailbox_view->set_activates_on_selection(true);
|
||||
m_individual_mailbox_view->on_activation = [this](auto& index) {
|
||||
selected_email_to_load(index);
|
||||
};
|
||||
|
||||
m_web_view->on_link_click = [this](auto& url, auto&, unsigned) {
|
||||
|
@ -241,13 +243,11 @@ bool MailWidget::is_supported_alternative(Alternative const& alternative) const
|
|||
return alternative.body_structure.type.equals_ignoring_ascii_case("text"sv) && (alternative.body_structure.subtype.equals_ignoring_ascii_case("plain"sv) || alternative.body_structure.subtype.equals_ignoring_ascii_case("html"sv));
|
||||
}
|
||||
|
||||
void MailWidget::selected_mailbox()
|
||||
void MailWidget::selected_mailbox(GUI::ModelIndex const& index)
|
||||
{
|
||||
m_individual_mailbox_model = InboxModel::create({});
|
||||
m_individual_mailbox_view->set_model(m_individual_mailbox_model);
|
||||
|
||||
auto const& index = m_mailbox_list->selection().first();
|
||||
|
||||
if (!index.is_valid())
|
||||
return;
|
||||
|
||||
|
@ -418,10 +418,8 @@ void MailWidget::selected_mailbox()
|
|||
m_individual_mailbox_view->set_model(m_individual_mailbox_model);
|
||||
}
|
||||
|
||||
void MailWidget::selected_email_to_load()
|
||||
void MailWidget::selected_email_to_load(GUI::ModelIndex const& index)
|
||||
{
|
||||
auto const& index = m_individual_mailbox_view->selection().first();
|
||||
|
||||
if (!index.is_valid())
|
||||
return;
|
||||
|
||||
|
|
|
@ -26,8 +26,8 @@ public:
|
|||
private:
|
||||
MailWidget();
|
||||
|
||||
void selected_mailbox();
|
||||
void selected_email_to_load();
|
||||
void selected_mailbox(GUI::ModelIndex const&);
|
||||
void selected_email_to_load(GUI::ModelIndex const&);
|
||||
|
||||
struct Alternative {
|
||||
IMAP::BodyStructureData const& body_structure;
|
||||
|
|
Loading…
Reference in a new issue