1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 07:07:44 +00:00

Ladybird+LibWeb: Add initial about:version internal page

This commit is contained in:
Bastiaan van der Plaat 2024-01-12 19:41:26 +01:00 committed by Tim Flynn
parent 05c0640474
commit cde14901bc
7 changed files with 100 additions and 1 deletions

View file

@ -148,6 +148,18 @@
#pragma mark - Private methods
- (void)openAboutVersionPage:(id)sender
{
auto* current_tab = [NSApp keyWindow];
if (![current_tab isKindOfClass:[Tab class]]) {
return;
}
[self createNewTab:URL("about:version"sv)
fromTab:(Tab*)current_tab
activateTab:Web::HTML::ActivateTab::Yes];
}
- (nonnull TabController*)createNewTab:(Web::HTML::ActivateTab)activate_tab
fromTab:(nullable Tab*)tab
{
@ -242,7 +254,7 @@
auto* submenu = [[NSMenu alloc] initWithTitle:process_name];
[submenu addItem:[[NSMenuItem alloc] initWithTitle:[NSString stringWithFormat:@"About %@", process_name]
action:@selector(orderFrontStandardAboutPanel:)
action:@selector(openAboutVersionPage:)
keyEquivalent:@""]];
[submenu addItem:[NSMenuItem separatorItem]];

View file

@ -74,6 +74,11 @@ BrowserWindow::BrowserWindow(Vector<URL> const& initial_urls, WebView::CookieJar
auto* menu = menuBar()->addMenu("&File");
auto* about_action = new QAction("&About Ladybird", this);
menu->addAction(about_action);
menu->addSeparator();
auto* new_tab_action = new QAction("New &Tab", this);
new_tab_action->setIcon(load_icon_from_uri("resource://icons/16x16/new-tab.png"sv));
new_tab_action->setShortcuts(QKeySequence::keyBindings(QKeySequence::StandardKey::AddTab));
@ -375,6 +380,9 @@ BrowserWindow::BrowserWindow(Vector<URL> const& initial_urls, WebView::CookieJar
debug_request("same-origin-policy", state ? "on" : "off");
});
QObject::connect(about_action, &QAction::triggered, this, [this] {
new_tab("about:version", Web::HTML::ActivateTab::Yes);
});
QObject::connect(new_tab_action, &QAction::triggered, this, [this] {
new_tab(Settings::the()->new_tab_page(), Web::HTML::ActivateTab::Yes);
});