From f234c416af2378d8172e04e13469b2faaed22211 Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Fri, 9 Jul 2021 17:42:17 +0200 Subject: [PATCH] LibGUI: Handle TTF size selection changes in font picker properly This patch addresses the following issues: - size resetting to 1 when switching from bitmap font size 10 to TTF - size resetting to 1 when incrementing spinbox from 8 to 9 - selection mode not being set on m_size_list_view selection change --- Userland/Libraries/LibGUI/FontPicker.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibGUI/FontPicker.cpp b/Userland/Libraries/LibGUI/FontPicker.cpp index ea592bef79..a2e0b66709 100644 --- a/Userland/Libraries/LibGUI/FontPicker.cpp +++ b/Userland/Libraries/LibGUI/FontPicker.cpp @@ -134,8 +134,13 @@ FontPicker::FontPicker(Window* parent_window, const Gfx::Font* current_font, boo m_size_list_view->on_selection_change = [this] { const auto& index = m_size_list_view->selection().first(); - m_size = index.data().to_i32(); - m_size_spin_box->set_value(m_size.value()); + auto size = index.data().to_i32(); + Optional index_of_new_size_in_list = m_sizes.find_first_index(size); + if (index_of_new_size_in_list.has_value()) { + m_size_list_view->set_selection_mode(GUI::AbstractView::SelectionMode::SingleSelection); + m_size = size; + m_size_spin_box->set_value(m_size.value()); + } update_font(); };