LibWebView+UI: Add a small history application menu
This currently just contains a menu item to open about:history. But in the future, we can add a list of recently closed / recently visited pages as well.
This commit is contained in:
parent
f72a18095d
commit
1a99bdad29
7 changed files with 19 additions and 8 deletions
|
|
@ -1510,6 +1510,11 @@ void Application::initialize_actions()
|
|||
m_bookmark_folder_context_menu->add_action(add_bookmark_action);
|
||||
m_bookmark_folder_context_menu->add_action(add_bookmark_folder_action);
|
||||
|
||||
m_history_menu = Menu::create("History"sv);
|
||||
m_history_menu->add_action(Action::create("View History"sv, ActionID::ViewHistory, [this]() {
|
||||
open_url_in_new_tab(URL::about_history(), Web::HTML::ActivateTab::Yes);
|
||||
}));
|
||||
|
||||
m_inspect_menu = Menu::create("Inspect"sv);
|
||||
|
||||
m_view_source_action = Action::create("View Source"sv, ActionID::ViewSource, [this]() {
|
||||
|
|
|
|||
|
|
@ -188,6 +188,8 @@ public:
|
|||
Menu& bookmark_context_menu() { return *m_bookmark_context_menu; }
|
||||
Menu& bookmark_folder_context_menu() { return *m_bookmark_folder_context_menu; }
|
||||
|
||||
Menu& history_menu() { return *m_history_menu; }
|
||||
|
||||
Menu& inspect_menu() { return *m_inspect_menu; }
|
||||
Action& view_source_action() { return *m_view_source_action; }
|
||||
|
||||
|
|
@ -387,6 +389,8 @@ private:
|
|||
RefPtr<Menu> m_bookmark_context_menu;
|
||||
RefPtr<Menu> m_bookmark_folder_context_menu;
|
||||
|
||||
RefPtr<Menu> m_history_menu;
|
||||
|
||||
RefPtr<Menu> m_inspect_menu;
|
||||
RefPtr<Action> m_view_source_action;
|
||||
RefPtr<Action> m_toggle_devtools_action;
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ enum class ActionID {
|
|||
NavigateBack,
|
||||
NavigateForward,
|
||||
Reload,
|
||||
ViewHistory,
|
||||
|
||||
CopySelection,
|
||||
CutSelection,
|
||||
|
|
|
|||
|
|
@ -338,14 +338,7 @@
|
|||
|
||||
- (NSMenuItem*)createHistoryMenu
|
||||
{
|
||||
auto* menu = [[NSMenuItem alloc] init];
|
||||
|
||||
auto* submenu = [[NSMenu alloc] initWithTitle:@"History"];
|
||||
[submenu setAutoenablesItems:NO];
|
||||
|
||||
[submenu addItem:Ladybird::create_application_menu_item(WebView::Application::the().reload_action())];
|
||||
[menu setSubmenu:submenu];
|
||||
return menu;
|
||||
return Ladybird::create_application_menu_item(WebView::Application::the().history_menu());
|
||||
}
|
||||
|
||||
- (NSMenuItem*)createBookmarksMenu
|
||||
|
|
|
|||
|
|
@ -225,6 +225,9 @@ static void initialize_native_icon(WebView::Action& action, id control)
|
|||
set_control_image(control, @"arrow.clockwise");
|
||||
[control setKeyEquivalent:@"r"];
|
||||
break;
|
||||
case WebView::ActionID::ViewHistory:
|
||||
set_control_image(control, @"clock");
|
||||
break;
|
||||
|
||||
case WebView::ActionID::CopySelection:
|
||||
set_control_image(control, @"document.on.document");
|
||||
|
|
|
|||
|
|
@ -372,6 +372,10 @@ BrowserWindow::BrowserWindow(Vector<URL::URL> const& initial_urls, IsPopupWindow
|
|||
m_hamburger_menu->addMenu(m_bookmarks_menu);
|
||||
menuBar()->addMenu(m_bookmarks_menu);
|
||||
|
||||
m_history_menu = create_application_menu(*this, application.history_menu());
|
||||
m_hamburger_menu->addMenu(m_history_menu);
|
||||
menuBar()->addMenu(m_history_menu);
|
||||
|
||||
auto* inspect_menu = create_application_menu(*m_hamburger_menu, application.inspect_menu());
|
||||
m_hamburger_menu->addMenu(inspect_menu);
|
||||
menuBar()->addMenu(inspect_menu);
|
||||
|
|
|
|||
|
|
@ -209,6 +209,7 @@ private:
|
|||
|
||||
QMenu* m_hamburger_menu { nullptr };
|
||||
QMenu* m_bookmarks_menu { nullptr };
|
||||
QMenu* m_history_menu { nullptr };
|
||||
QWidget* m_menu_bar_window_controls { nullptr };
|
||||
QToolButton* m_menu_bar_minimize_window_button { nullptr };
|
||||
QToolButton* m_menu_bar_maximize_window_button { nullptr };
|
||||
|
|
|
|||
Loading…
Reference in a new issue