mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:38:11 +00:00
Applications: Map Alt+F4 to Quit in FileManager/ProcessManager/Terminal.
This commit is contained in:
parent
7c06431ff7
commit
b0c673265a
6 changed files with 35 additions and 10 deletions
|
@ -64,7 +64,7 @@ int main(int argc, char** argv)
|
||||||
auto menubar = make<GMenuBar>();
|
auto menubar = make<GMenuBar>();
|
||||||
|
|
||||||
auto app_menu = make<GMenu>("FileManager");
|
auto app_menu = make<GMenu>("FileManager");
|
||||||
app_menu->add_action(GAction::create("Quit", String(), [] (const GAction&) {
|
app_menu->add_action(GAction::create("Quit", { Mod_Alt, Key_F4 }, [] (const GAction&) {
|
||||||
GApplication::the().quit(0);
|
GApplication::the().quit(0);
|
||||||
return;
|
return;
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -50,7 +50,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto menubar = make<GMenuBar>();
|
auto menubar = make<GMenuBar>();
|
||||||
auto app_menu = make<GMenu>("ProcessManager");
|
auto app_menu = make<GMenu>("ProcessManager");
|
||||||
app_menu->add_action(GAction::create("Quit", String(), [] (const GAction&) {
|
app_menu->add_action(GAction::create("Quit", { Mod_Alt, Key_F4 }, [] (const GAction&) {
|
||||||
GApplication::the().quit(0);
|
GApplication::the().quit(0);
|
||||||
return;
|
return;
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -100,7 +100,7 @@ int main(int argc, char** argv)
|
||||||
auto menubar = make<GMenuBar>();
|
auto menubar = make<GMenuBar>();
|
||||||
|
|
||||||
auto app_menu = make<GMenu>("Terminal");
|
auto app_menu = make<GMenu>("Terminal");
|
||||||
app_menu->add_action(GAction::create("Quit", String(), [] (const GAction&) {
|
app_menu->add_action(GAction::create("Quit", { Mod_Alt, Key_F4 }, [] (const GAction&) {
|
||||||
dbgprintf("Terminal: Quit menu activated!\n");
|
dbgprintf("Terminal: Quit menu activated!\n");
|
||||||
GApplication::the().quit(0);
|
GApplication::the().quit(0);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -50,9 +50,9 @@ static KeyCode unshifted_key_map[0x80] =
|
||||||
Key_Alt, // 54
|
Key_Alt, // 54
|
||||||
Key_Invalid, Key_Invalid,
|
Key_Invalid, Key_Invalid,
|
||||||
Key_Space, // 57
|
Key_Space, // 57
|
||||||
Key_Invalid, Key_Invalid,
|
Key_Invalid, // 58
|
||||||
Key_Invalid, // 60
|
Key_F1, Key_F2, Key_F3, Key_F4, Key_F5, Key_F6, Key_F7, Key_F8, Key_F9, Key_F10,
|
||||||
Key_Invalid, Key_Invalid, Key_Invalid, Key_Invalid, Key_Invalid, Key_Invalid, Key_Invalid, Key_Invalid, Key_Invalid,
|
Key_Invalid,
|
||||||
Key_Invalid, // 70
|
Key_Invalid, // 70
|
||||||
Key_Invalid,
|
Key_Invalid,
|
||||||
Key_Up,
|
Key_Up,
|
||||||
|
@ -65,6 +65,13 @@ static KeyCode unshifted_key_map[0x80] =
|
||||||
Key_Invalid,
|
Key_Invalid,
|
||||||
Key_Down, // 80
|
Key_Down, // 80
|
||||||
Key_PageDown,
|
Key_PageDown,
|
||||||
|
Key_Invalid,
|
||||||
|
Key_Invalid,
|
||||||
|
Key_Invalid,
|
||||||
|
Key_Invalid,
|
||||||
|
Key_Invalid,
|
||||||
|
Key_F11,
|
||||||
|
Key_F12,
|
||||||
};
|
};
|
||||||
|
|
||||||
static KeyCode shifted_key_map[0x100] =
|
static KeyCode shifted_key_map[0x100] =
|
||||||
|
@ -81,10 +88,10 @@ static KeyCode shifted_key_map[0x100] =
|
||||||
Key_Z, Key_X, Key_C, Key_V, Key_B, Key_N, Key_M, Key_LessThan, Key_GreaterThan, Key_QuestionMark,
|
Key_Z, Key_X, Key_C, Key_V, Key_B, Key_N, Key_M, Key_LessThan, Key_GreaterThan, Key_QuestionMark,
|
||||||
Key_Alt,
|
Key_Alt,
|
||||||
Key_Invalid, Key_Invalid,
|
Key_Invalid, Key_Invalid,
|
||||||
Key_Space,
|
Key_Space, // 57
|
||||||
Key_Invalid, Key_Invalid,
|
Key_Invalid, // 58
|
||||||
Key_Invalid, // 60
|
Key_F1, Key_F2, Key_F3, Key_F4, Key_F5, Key_F6, Key_F7, Key_F8, Key_F9, Key_F10,
|
||||||
Key_Invalid, Key_Invalid, Key_Invalid, Key_Invalid, Key_Invalid, Key_Invalid, Key_Invalid, Key_Invalid, Key_Invalid,
|
Key_Invalid,
|
||||||
Key_Invalid, // 70
|
Key_Invalid, // 70
|
||||||
Key_Invalid,
|
Key_Invalid,
|
||||||
Key_Up,
|
Key_Up,
|
||||||
|
@ -97,6 +104,13 @@ static KeyCode shifted_key_map[0x100] =
|
||||||
Key_Invalid,
|
Key_Invalid,
|
||||||
Key_Down, // 80
|
Key_Down, // 80
|
||||||
Key_PageDown,
|
Key_PageDown,
|
||||||
|
Key_Invalid,
|
||||||
|
Key_Invalid,
|
||||||
|
Key_Invalid,
|
||||||
|
Key_Invalid,
|
||||||
|
Key_Invalid,
|
||||||
|
Key_F11,
|
||||||
|
Key_F12,
|
||||||
};
|
};
|
||||||
|
|
||||||
void KeyboardDevice::key_state_changed(byte raw, bool pressed)
|
void KeyboardDevice::key_state_changed(byte raw, bool pressed)
|
||||||
|
|
|
@ -20,6 +20,12 @@ GAction::GAction(const String& text, RetainPtr<GraphicsBitmap>&& icon, Function<
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GAction::GAction(const String& text, const GShortcut& shortcut, Function<void(const GAction&)> on_activation_callback)
|
||||||
|
: GAction(text, shortcut, nullptr, move(on_activation_callback))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
GAction::GAction(const String& text, const GShortcut& shortcut, RetainPtr<GraphicsBitmap>&& icon, Function<void(const GAction&)> on_activation_callback)
|
GAction::GAction(const String& text, const GShortcut& shortcut, RetainPtr<GraphicsBitmap>&& icon, Function<void(const GAction&)> on_activation_callback)
|
||||||
: on_activation(move(on_activation_callback))
|
: on_activation(move(on_activation_callback))
|
||||||
, m_text(text)
|
, m_text(text)
|
||||||
|
|
|
@ -21,6 +21,10 @@ public:
|
||||||
{
|
{
|
||||||
return adopt(*new GAction(text, move(icon), move(callback)));
|
return adopt(*new GAction(text, move(icon), move(callback)));
|
||||||
}
|
}
|
||||||
|
static Retained<GAction> create(const String& text, const GShortcut& shortcut, Function<void(const GAction&)> callback)
|
||||||
|
{
|
||||||
|
return adopt(*new GAction(text, shortcut, move(callback)));
|
||||||
|
}
|
||||||
static Retained<GAction> create(const String& text, const GShortcut& shortcut, RetainPtr<GraphicsBitmap>&& icon, Function<void(const GAction&)> callback)
|
static Retained<GAction> create(const String& text, const GShortcut& shortcut, RetainPtr<GraphicsBitmap>&& icon, Function<void(const GAction&)> callback)
|
||||||
{
|
{
|
||||||
return adopt(*new GAction(text, shortcut, move(icon), move(callback)));
|
return adopt(*new GAction(text, shortcut, move(icon), move(callback)));
|
||||||
|
@ -38,6 +42,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GAction(const String& text, Function<void(const GAction&)> = nullptr);
|
GAction(const String& text, Function<void(const GAction&)> = nullptr);
|
||||||
|
GAction(const String& text, const GShortcut&, Function<void(const GAction&)> = nullptr);
|
||||||
GAction(const String& text, const GShortcut&, RetainPtr<GraphicsBitmap>&& icon, Function<void(const GAction&)> = nullptr);
|
GAction(const String& text, const GShortcut&, RetainPtr<GraphicsBitmap>&& icon, Function<void(const GAction&)> = nullptr);
|
||||||
GAction(const String& text, RetainPtr<GraphicsBitmap>&& icon, Function<void(const GAction&)> = nullptr);
|
GAction(const String& text, RetainPtr<GraphicsBitmap>&& icon, Function<void(const GAction&)> = nullptr);
|
||||||
GAction(const String& text, const String& custom_data = String(), Function<void(const GAction&)> = nullptr);
|
GAction(const String& text, const String& custom_data = String(), Function<void(const GAction&)> = nullptr);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue