2020-05-09 13:02:01 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-05-09 13:02:01 +01:00
|
|
|
*/
|
|
|
|
|
|
2020-04-23 21:27:34 +02:00
|
|
|
#include "WindowActions.h"
|
2022-01-10 19:06:11 -08:00
|
|
|
#include <Applications/Browser/Browser.h>
|
2021-01-04 23:34:32 +01:00
|
|
|
#include <LibGUI/Icon.h>
|
2020-04-23 21:27:34 +02:00
|
|
|
#include <LibGUI/Window.h>
|
2020-04-24 20:22:45 +02:00
|
|
|
#include <LibGfx/Bitmap.h>
|
2020-04-23 21:27:34 +02:00
|
|
|
|
|
|
|
|
namespace Browser {
|
|
|
|
|
|
|
|
|
|
static WindowActions* s_the;
|
|
|
|
|
|
|
|
|
|
WindowActions& WindowActions::the()
|
|
|
|
|
{
|
2021-02-23 20:42:32 +01:00
|
|
|
VERIFY(s_the);
|
2020-04-23 21:27:34 +02:00
|
|
|
return *s_the;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WindowActions::WindowActions(GUI::Window& window)
|
|
|
|
|
{
|
2021-02-23 20:42:32 +01:00
|
|
|
VERIFY(!s_the);
|
2020-04-23 21:27:34 +02:00
|
|
|
s_the = this;
|
|
|
|
|
m_create_new_tab_action = GUI::Action::create(
|
2022-01-10 19:06:11 -08:00
|
|
|
"&New Tab", { Mod_Ctrl, Key_T }, g_icon_bag.new_tab, [this](auto&) {
|
2020-04-23 21:27:34 +02:00
|
|
|
if (on_create_new_tab)
|
|
|
|
|
on_create_new_tab();
|
|
|
|
|
},
|
|
|
|
|
&window);
|
2021-04-18 00:53:37 +02:00
|
|
|
m_create_new_tab_action->set_status_tip("Open a new tab");
|
2020-04-23 21:43:24 +02:00
|
|
|
|
|
|
|
|
m_next_tab_action = GUI::Action::create(
|
2021-04-09 17:07:34 +02:00
|
|
|
"&Next Tab", { Mod_Ctrl, Key_PageDown }, [this](auto&) {
|
2020-04-23 21:43:24 +02:00
|
|
|
if (on_next_tab)
|
|
|
|
|
on_next_tab();
|
|
|
|
|
},
|
|
|
|
|
&window);
|
2021-04-18 00:53:37 +02:00
|
|
|
m_next_tab_action->set_status_tip("Switch to the next tab");
|
2020-04-23 21:43:24 +02:00
|
|
|
|
|
|
|
|
m_previous_tab_action = GUI::Action::create(
|
2021-04-09 17:07:34 +02:00
|
|
|
"&Previous Tab", { Mod_Ctrl, Key_PageUp }, [this](auto&) {
|
2020-04-23 21:43:24 +02:00
|
|
|
if (on_previous_tab)
|
|
|
|
|
on_previous_tab();
|
|
|
|
|
},
|
|
|
|
|
&window);
|
2021-04-18 00:53:37 +02:00
|
|
|
m_previous_tab_action->set_status_tip("Switch to the previous tab");
|
2020-04-24 20:50:06 +02:00
|
|
|
|
|
|
|
|
m_about_action = GUI::Action::create(
|
2021-04-09 17:07:34 +02:00
|
|
|
"&About Browser", GUI::Icon::default_icon("app-browser").bitmap_for_size(16), [this](const GUI::Action&) {
|
2020-04-24 20:50:06 +02:00
|
|
|
if (on_about)
|
|
|
|
|
on_about();
|
|
|
|
|
},
|
|
|
|
|
&window);
|
2021-04-18 00:53:37 +02:00
|
|
|
m_about_action->set_status_tip("Show application about box");
|
2021-02-26 07:05:41 -05:00
|
|
|
|
2020-04-25 17:20:23 +02:00
|
|
|
m_show_bookmarks_bar_action = GUI::Action::create_checkable(
|
2021-04-09 17:07:34 +02:00
|
|
|
"&Bookmarks Bar", { Mod_Ctrl, Key_B },
|
2020-04-25 17:20:23 +02:00
|
|
|
[this](auto& action) {
|
|
|
|
|
if (on_show_bookmarks_bar)
|
|
|
|
|
on_show_bookmarks_bar(action);
|
|
|
|
|
},
|
|
|
|
|
&window);
|
2021-04-18 00:53:37 +02:00
|
|
|
m_show_bookmarks_bar_action->set_status_tip("Show/hide the bookmarks bar");
|
2020-04-23 21:27:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|