1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-19 13:17:39 +00:00

LibGUI+VisualBuilder: Support custom editing widgets for property values.

Implemented this by letting GAbstractViews provide a GModelEditingDelegate
for a given index, which then knows how to create and setup a custom widget
appropriate for the data type being edited.
This commit is contained in:
Andreas Kling 2019-06-23 08:18:28 +02:00
parent 1d0ada32cc
commit 6a0011dcea
8 changed files with 170 additions and 7 deletions

View file

@ -41,7 +41,11 @@ GComboBox::GComboBox(GWidget* parent)
auto new_value = model()->data(index).to_string();
m_editor->set_text(new_value);
m_editor->select_all();
m_list_window->hide();
close();
deferred_invoke([this](auto&) {
if (on_change)
on_change(m_editor->text());
});
};
}
@ -63,6 +67,11 @@ void GComboBox::set_model(NonnullRefPtr<GModel> model)
m_list_view->set_model(move(model));
}
void GComboBox::select_all()
{
m_editor->select_all();
}
void GComboBox::open()
{
if (!model())
@ -100,3 +109,10 @@ void GComboBox::set_text(const String& text)
{
m_editor->set_text(text);
}
void GComboBox::set_only_allow_values_from_model(bool b)
{
if (m_only_allow_values_from_model == b)
return;
m_editor->set_readonly(m_only_allow_values_from_model);
}