diff --git a/Ladybird/Info.plist b/Ladybird/Info.plist index ffa29253741..88d08e9093f 100644 --- a/Ladybird/Info.plist +++ b/Ladybird/Info.plist @@ -20,5 +20,55 @@ NSApplication NSHighResolutionCapable True + CFBundleDocumentTypes + + + CFBundleTypeName + Web documents + CFBundleTypeRole + Viewer + CFBundleTypeIconFile + document.icns + LSItemContentTypes + + public.html + public.xhtml + public.svg-image + + + + CFBundleTypeName + Other documents + CFBundleTypeRole + Viewer + CFBundleTypeIconFile + document.icns + CFBundleTypeExtensions + + md + + + + CFBundleURLTypes + + + CFBundleURLName + Web site URL + CFBundleURLSchemes + + http + https + gemini + + + + CFBundleURLName + Local file URL + CFBundleURLSchemes + + file + + + diff --git a/Ladybird/Qt/main.cpp b/Ladybird/Qt/main.cpp index 861d4768923..a72326806ce 100644 --- a/Ladybird/Qt/main.cpp +++ b/Ladybird/Qt/main.cpp @@ -21,6 +21,7 @@ #include #include #include +#include namespace Ladybird { @@ -54,9 +55,40 @@ static ErrorOr handle_attached_debugger() return {}; } +class LadybirdApplication : public QApplication { +public: + LadybirdApplication(int& argc, char** argv) + : QApplication(argc, argv) + { + } + + Function on_open_file; + + bool event(QEvent* event) override + { + switch (event->type()) { + case QEvent::FileOpen: { + if (!on_open_file) + break; + + auto const& open_event = *static_cast(event); + auto file = MUST(ak_string_from_qstring(open_event.file())); + + if (auto file_url = WebView::sanitize_url(file); file_url.has_value()) + on_open_file(file_url.release_value()); + } + + default: + break; + } + + return QApplication::event(event); + } +}; + ErrorOr serenity_main(Main::Arguments arguments) { - QApplication app(arguments.argc, arguments.argv); + LadybirdApplication app(arguments.argc, arguments.argv); Core::EventLoopManager::install(*new Ladybird::EventLoopManagerQt); Core::EventLoop event_loop; @@ -111,6 +143,10 @@ ErrorOr serenity_main(Main::Arguments arguments) Ladybird::BrowserWindow window(initial_urls, cookie_jar, webdriver_content_ipc_path, enable_callgrind_profiling ? WebView::EnableCallgrindProfiling::Yes : WebView::EnableCallgrindProfiling::No, use_lagom_networking ? Ladybird::UseLagomNetworking::Yes : Ladybird::UseLagomNetworking::No, use_gpu_painting ? WebView::EnableGPUPainting::Yes : WebView::EnableGPUPainting::No); window.setWindowTitle("Ladybird"); + app.on_open_file = [&](auto file_url) { + window.view().load(file_url); + }; + if (Ladybird::Settings::the()->is_maximized()) { window.showMaximized(); } else {