2020-06-02 20:59:30 +03:00
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2020, Hüseyin Aslıtürk <asliturk@hotmail.com>
|
2022-02-10 22:28:48 +03:00
|
|
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
2020-06-02 20:59:30 +03:00
|
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-06-02 20:59:30 +03:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "KeyButton.h"
|
|
|
|
|
#include <LibGUI/Button.h>
|
|
|
|
|
#include <LibKeyboard/CharacterMapData.h>
|
|
|
|
|
|
2021-11-01 01:38:04 +03:00
|
|
|
|
class KeyboardMapperWidget final : public GUI::Widget {
|
2020-06-02 20:59:30 +03:00
|
|
|
|
C_OBJECT(KeyboardMapperWidget)
|
|
|
|
|
|
|
|
|
|
public:
|
2022-02-10 22:28:48 +03:00
|
|
|
|
virtual ~KeyboardMapperWidget() override = default;
|
2020-06-02 20:59:30 +03:00
|
|
|
|
|
|
|
|
|
void create_frame();
|
2021-12-16 21:39:38 +03:00
|
|
|
|
ErrorOr<void> load_map_from_file(const String&);
|
|
|
|
|
ErrorOr<void> load_map_from_system();
|
|
|
|
|
ErrorOr<void> save();
|
|
|
|
|
ErrorOr<void> save_to_file(StringView);
|
|
|
|
|
void show_error_to_user(Error);
|
2022-01-07 20:01:58 +03:00
|
|
|
|
void set_automatic_modifier(bool checked);
|
2020-06-02 20:59:30 +03:00
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual void keydown_event(GUI::KeyEvent&) override;
|
|
|
|
|
virtual void keyup_event(GUI::KeyEvent&) override;
|
|
|
|
|
|
|
|
|
|
void set_current_map(const String);
|
|
|
|
|
void update_window_title();
|
|
|
|
|
|
|
|
|
|
private:
|
2021-11-01 01:38:04 +03:00
|
|
|
|
KeyboardMapperWidget();
|
|
|
|
|
|
2020-06-02 20:59:30 +03:00
|
|
|
|
Vector<KeyButton*> m_keys;
|
|
|
|
|
RefPtr<GUI::Widget> m_map_group;
|
2021-12-15 20:44:55 +03:00
|
|
|
|
void add_map_radio_button(const StringView map_name, const StringView button_text);
|
2021-12-15 23:58:46 +03:00
|
|
|
|
u32* map_from_name(const StringView map_name);
|
2022-01-07 20:01:58 +03:00
|
|
|
|
void update_modifier_radio_buttons(GUI::KeyEvent&);
|
2020-06-02 20:59:30 +03:00
|
|
|
|
|
2021-04-29 22:46:15 +03:00
|
|
|
|
String m_filename;
|
2020-06-02 20:59:30 +03:00
|
|
|
|
Keyboard::CharacterMapData m_character_map;
|
|
|
|
|
String m_current_map_name;
|
|
|
|
|
bool m_modified { false };
|
2022-01-07 20:01:58 +03:00
|
|
|
|
bool m_automatic_modifier { false };
|
2020-06-02 20:59:30 +03:00
|
|
|
|
};
|