KeyboardSettings: Highlight default keymap in Keyboard Settings dialog
This commit is contained in:
parent
9a83d34543
commit
4fd65748a8
Notes:
sideshowbarker
2024-07-19 17:07:55 +09:00
Author: https://github.com/tsymalla Commit: https://github.com/SerenityOS/serenity/commit/4fd65748a87 Pull-request: https://github.com/SerenityOS/serenity/pull/12834 Reviewed-by: https://github.com/awesomekling
1 changed files with 16 additions and 2 deletions
|
@ -23,6 +23,7 @@
|
|||
#include <LibGUI/Model.h>
|
||||
#include <LibGUI/Widget.h>
|
||||
#include <LibGUI/Window.h>
|
||||
#include <LibGfx/FontDatabase.h>
|
||||
#include <LibKeyboard/CharacterMap.h>
|
||||
#include <spawn.h>
|
||||
|
||||
|
@ -107,9 +108,13 @@ public:
|
|||
int row_count(GUI::ModelIndex const&) const override { return m_data.size(); }
|
||||
int column_count(GUI::ModelIndex const&) const override { return 1; }
|
||||
|
||||
GUI::Variant data(GUI::ModelIndex const& index, GUI::ModelRole) const override
|
||||
GUI::Variant data(GUI::ModelIndex const& index, GUI::ModelRole role) const override
|
||||
{
|
||||
return m_data.at(index.row());
|
||||
String const& data = m_data.at(index.row());
|
||||
if (role == GUI::ModelRole::Font && data == m_active_keymap)
|
||||
return Gfx::FontDatabase::default_font().bold_variant();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void remove_at(size_t index)
|
||||
|
@ -124,10 +129,17 @@ public:
|
|||
invalidate();
|
||||
}
|
||||
|
||||
void set_active_keymap(String const& keymap)
|
||||
{
|
||||
m_active_keymap = keymap;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
Vector<String> const& keymaps() const { return m_data; }
|
||||
|
||||
private:
|
||||
Vector<String> m_data;
|
||||
String m_active_keymap;
|
||||
};
|
||||
|
||||
KeyboardSettingsWidget::KeyboardSettingsWidget()
|
||||
|
@ -159,6 +171,8 @@ KeyboardSettingsWidget::KeyboardSettingsWidget()
|
|||
keymaps_list_model.add_keymap(keymap);
|
||||
}
|
||||
|
||||
keymaps_list_model.set_active_keymap(m_current_applied_keymap);
|
||||
|
||||
m_add_keymap_button = find_descendant_of_type_named<GUI::Button>("add_keymap_button");
|
||||
|
||||
m_add_keymap_button->on_click = [&](auto) {
|
||||
|
|
Loading…
Add table
Reference in a new issue