mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:07:35 +00:00
KeyboardSettings: Use LibConfig intead of Core::ConfigFile
This commit is contained in:
parent
8fdb435d24
commit
fdc9ff2ee7
2 changed files with 7 additions and 11 deletions
|
@ -9,4 +9,4 @@ set(SOURCES
|
||||||
)
|
)
|
||||||
|
|
||||||
serenity_app(KeyboardSettings ICON app-keyboard-settings)
|
serenity_app(KeyboardSettings ICON app-keyboard-settings)
|
||||||
target_link_libraries(KeyboardSettings LibGUI LibKeyboard)
|
target_link_libraries(KeyboardSettings LibGUI LibKeyboard LibConfig)
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#include <AK/JsonObject.h>
|
#include <AK/JsonObject.h>
|
||||||
#include <AK/QuickSort.h>
|
#include <AK/QuickSort.h>
|
||||||
#include <LibCore/ConfigFile.h>
|
|
||||||
#include <LibCore/DirIterator.h>
|
#include <LibCore/DirIterator.h>
|
||||||
#include <LibCore/File.h>
|
#include <LibCore/File.h>
|
||||||
#include <LibGUI/Action.h>
|
#include <LibGUI/Action.h>
|
||||||
|
@ -24,6 +23,9 @@
|
||||||
#include <LibKeyboard/CharacterMap.h>
|
#include <LibKeyboard/CharacterMap.h>
|
||||||
#include <spawn.h>
|
#include <spawn.h>
|
||||||
|
|
||||||
|
// Including this after to avoid LibIPC errors
|
||||||
|
#include <LibConfig/Client.h>
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
if (pledge("stdio rpath cpath wpath recvfd sendfd unix proc exec", nullptr) < 0) {
|
if (pledge("stdio rpath cpath wpath recvfd sendfd unix proc exec", nullptr) < 0) {
|
||||||
|
@ -32,18 +34,13 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto app = GUI::Application::construct(argc, argv);
|
auto app = GUI::Application::construct(argc, argv);
|
||||||
|
Config::pledge_domains("KeyboardSettings");
|
||||||
|
|
||||||
if (pledge("stdio rpath cpath wpath recvfd sendfd proc exec", nullptr) < 0) {
|
if (pledge("stdio rpath cpath wpath recvfd sendfd proc exec", nullptr) < 0) {
|
||||||
perror("pledge");
|
perror("pledge");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto config = Core::ConfigFile::open_for_app("KeyboardSettings", Core::ConfigFile::AllowWriting::Yes);
|
|
||||||
if (unveil(config->filename().characters(), "rwc") < 0) {
|
|
||||||
perror("unveil");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (unveil("/res", "r") < 0) {
|
if (unveil("/res", "r") < 0) {
|
||||||
perror("unveil");
|
perror("unveil");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -126,7 +123,7 @@ int main(int argc, char** argv)
|
||||||
character_map_file_combo.set_selected_index(initial_keymap_index);
|
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 = root_widget.add<GUI::CheckBox>("Enable Num Lock on login");
|
||||||
num_lock_checkbox.set_checked(config->read_bool_entry("StartupEnable", "NumLock", true));
|
num_lock_checkbox.set_checked(Config::read_bool("KeyboardSettings", "StartupEnable", "NumLock", true));
|
||||||
|
|
||||||
root_widget.layout()->add_spacer();
|
root_widget.layout()->add_spacer();
|
||||||
|
|
||||||
|
@ -143,8 +140,7 @@ int main(int argc, char** argv)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
config->write_bool_entry("StartupEnable", "NumLock", num_lock_checkbox.is_checked());
|
Config::write_bool("KeyboardSettings", "StartupEnable", "NumLock", num_lock_checkbox.is_checked());
|
||||||
config->sync();
|
|
||||||
|
|
||||||
if (quit)
|
if (quit)
|
||||||
app->quit();
|
app->quit();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue