summaryrefslogtreecommitdiff
path: root/Userland/Applets/Keymap/KeymapStatusWidget.h
blob: 3e3e0fa54e31e183d66b2b735cf2d7b1f2e05e1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
 * Copyright (c) 2022, the SerenityOS developers.
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <LibCore/FileWatcher.h>
#include <LibGUI/ActionGroup.h>
#include <LibGUI/Label.h>
#include <LibGUI/Menu.h>
#include <LibGUI/Window.h>

enum class ClearBackground {
    No,
    Yes
};

class KeymapStatusWidget : public GUI::Label {
    C_OBJECT(KeymapStatusWidget);

    virtual void mousedown_event(GUI::MouseEvent& event) override;

    void set_current_keymap(String const& keymap, ClearBackground clear_background = ClearBackground::Yes);

private:
    RefPtr<GUI::Menu> m_context_menu;
    String m_current_keymap;

    ErrorOr<void> refresh_menu();

    GUI::ActionGroup m_keymaps_group;
};