summaryrefslogtreecommitdiff
path: root/Userland/Applications/KeyboardSettings
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2021-11-20 12:53:04 +0000
committerLinus Groh <mail@linusgroh.de>2021-11-20 21:05:20 +0000
commit4bac30f737e07ac83260a4e7d91315b5eee99caa (patch)
tree40c0275339c63dbf97fda391c625a12b475b1992 /Userland/Applications/KeyboardSettings
parent1dd5c838cfe7f553da97bf449fc1ddf4504f08d7 (diff)
downloadserenity-4bac30f737e07ac83260a4e7d91315b5eee99caa.zip
KeyboardSettings: Migrate layout to GML
All other Settings applications use this, so let's match them!
Diffstat (limited to 'Userland/Applications/KeyboardSettings')
-rw-r--r--Userland/Applications/KeyboardSettings/CMakeLists.txt3
-rw-r--r--Userland/Applications/KeyboardSettings/Keyboard.gml48
-rw-r--r--Userland/Applications/KeyboardSettings/main.cpp34
3 files changed, 65 insertions, 20 deletions
diff --git a/Userland/Applications/KeyboardSettings/CMakeLists.txt b/Userland/Applications/KeyboardSettings/CMakeLists.txt
index 5edad16209..9111022f7f 100644
--- a/Userland/Applications/KeyboardSettings/CMakeLists.txt
+++ b/Userland/Applications/KeyboardSettings/CMakeLists.txt
@@ -4,8 +4,11 @@ serenity_component(
TARGETS KeyboardSettings
)
+compile_gml(Keyboard.gml KeyboardWidgetGML.h keyboard_widget_gml)
+
set(SOURCES
main.cpp
+ KeyboardWidgetGML.h
)
serenity_app(KeyboardSettings ICON app-keyboard-settings)
diff --git a/Userland/Applications/KeyboardSettings/Keyboard.gml b/Userland/Applications/KeyboardSettings/Keyboard.gml
new file mode 100644
index 0000000000..0e09cb125c
--- /dev/null
+++ b/Userland/Applications/KeyboardSettings/Keyboard.gml
@@ -0,0 +1,48 @@
+@GUI::Frame {
+ fill_with_background_color: true
+
+ layout: @GUI::VerticalBoxLayout {
+ margins: [10]
+ spacing: 5
+ }
+
+ @GUI::GroupBox {
+ title: "Mapping"
+ fixed_height: 60
+
+ layout: @GUI::VerticalBoxLayout {
+ margins: [16, 8, 8]
+ spacing: 2
+ }
+
+ @GUI::Widget {
+ layout: @GUI::HorizontalBoxLayout {
+ spacing: 16
+ }
+
+ @GUI::Label {
+ text: "Character mapping file:"
+ fixed_width: 130
+ text_alignment: "CenterLeft"
+ }
+
+ @GUI::ComboBox {
+ name: "character_map_file_combo"
+ }
+ }
+ }
+
+ @GUI::GroupBox {
+ title: "Num Lock"
+ fixed_height: 60
+
+ layout: @GUI::HorizontalBoxLayout {
+ margins: [16, 8, 8]
+ }
+
+ @GUI::CheckBox {
+ text: "Enable Num Lock on login"
+ name: "num_lock_checkbox"
+ }
+ }
+}
diff --git a/Userland/Applications/KeyboardSettings/main.cpp b/Userland/Applications/KeyboardSettings/main.cpp
index 0a5d4c0843..60d9c4bb0a 100644
--- a/Userland/Applications/KeyboardSettings/main.cpp
+++ b/Userland/Applications/KeyboardSettings/main.cpp
@@ -1,11 +1,13 @@
/*
* Copyright (c) 2020, Hüseyin Aslıtürk <asliturk@hotmail.com>
+ * Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/JsonObject.h>
#include <AK/QuickSort.h>
+#include <Applications/KeyboardSettings/KeyboardWidgetGML.h>
#include <LibCore/DirIterator.h>
#include <LibCore/File.h>
#include <LibGUI/Action.h>
@@ -16,9 +18,8 @@
#include <LibGUI/ComboBox.h>
#include <LibGUI/ItemListModel.h>
#include <LibGUI/Label.h>
-#include <LibGUI/Menu.h>
-#include <LibGUI/Menubar.h>
#include <LibGUI/MessageBox.h>
+#include <LibGUI/TabWidget.h>
#include <LibGUI/WindowServerConnection.h>
#include <LibKeyboard/CharacterMap.h>
#include <spawn.h>
@@ -95,36 +96,29 @@ int main(int argc, char** argv)
auto window = GUI::Window::construct();
window->set_title("Keyboard Settings");
- window->resize(300, 78);
+ window->resize(400, 480);
window->set_resizable(false);
window->set_minimizable(false);
- window->set_icon(app_icon.bitmap_for_size(16));
- auto& root_widget = window->set_main_widget<GUI::Widget>();
- root_widget.set_layout<GUI::VerticalBoxLayout>();
- root_widget.set_fill_with_background_color(true);
- root_widget.layout()->set_spacing(0);
- root_widget.layout()->set_margins(4);
+ auto& main_widget = window->set_main_widget<GUI::Widget>();
+ main_widget.set_fill_with_background_color(true);
+ main_widget.set_layout<GUI::VerticalBoxLayout>();
+ main_widget.layout()->set_margins(4);
+ main_widget.layout()->set_spacing(6);
- auto& character_map_file_selection_container = root_widget.add<GUI::Widget>();
- character_map_file_selection_container.set_layout<GUI::HorizontalBoxLayout>();
- character_map_file_selection_container.set_fixed_height(22);
+ auto& tab_widget = main_widget.add<GUI::TabWidget>();
+ auto& keyboard_widget = tab_widget.add_tab<GUI::Widget>("Keyboard");
- auto& character_map_file_label = character_map_file_selection_container.add<GUI::Label>();
- character_map_file_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
- character_map_file_label.set_fixed_width(130);
- character_map_file_label.set_text("Character Mapping File:");
+ keyboard_widget.load_from_gml(keyboard_widget_gml);
- auto& character_map_file_combo = character_map_file_selection_container.add<GUI::ComboBox>();
+ auto& character_map_file_combo = *keyboard_widget.find_descendant_of_type_named<GUI::ComboBox>("character_map_file_combo");
character_map_file_combo.set_only_allow_values_from_model(true);
character_map_file_combo.set_model(*GUI::ItemListModel<String>::create(character_map_files));
character_map_file_combo.set_selected_index(initial_keymap_index);
- auto& num_lock_checkbox = root_widget.add<GUI::CheckBox>("Enable Num Lock on login");
+ auto& num_lock_checkbox = *keyboard_widget.find_descendant_of_type_named<GUI::CheckBox>("num_lock_checkbox");
num_lock_checkbox.set_checked(Config::read_bool("KeyboardSettings", "StartupEnable", "NumLock", true));
- root_widget.layout()->add_spacer();
-
auto apply_settings = [&](bool quit) {
String character_map_file = character_map_file_combo.text();
if (character_map_file.is_empty()) {