Architecture Overview
The browser component is built on Qt WebEngine (Chromium):Browser::WebView
Custom web view widget extendingQWebEngineView with Zeal-specific functionality.
Location: src/libs/browser/webview.h
Interface
Key Features
Zoom Control
Fromsrc/libs/browser/webview.h:20-31:
Event Handling
Fromsrc/libs/browser/webview.h:41-42:
- Mouse events: Middle-click for opening links in new tabs
- Wheel events: Ctrl+Wheel for zooming
Context Menu
Fromsrc/libs/browser/webview.h:44-46:
- Open link in new tab
- Copy link address
- Inspect element (in debug builds)
Window Creation
Browser::WebPage
Custom web page implementation with navigation control and JavaScript integration. Location:src/libs/browser/webpage.h
Interface
Navigation Control
Fromsrc/libs/browser/webpage.h:21:
- Local documentation: Always allowed
- External links: Subject to user preference (Settings::ExternalLinkPolicy)
- JavaScript navigation: Validated before execution
JavaScript Console
Fromsrc/libs/browser/webpage.h:22:
Browser::WebBridge
Bridge between C++ code and JavaScript in web pages. Location:src/libs/browser/webbridge.h
Interface
JavaScript Integration
The WebBridge is exposed to JavaScript through Qt’s WebChannel mechanism.From JavaScript
Q_INVOKABLE Methods
Fromsrc/libs/browser/webbridge.h:24-25:
- openShortUrl: Opens documentation using short URL keys
- triggerAction: Triggers application actions from web content
Properties
Fromsrc/libs/browser/webbridge.h:16:
Signals
Fromsrc/libs/browser/webbridge.h:21:
Browser::UrlRequestInterceptor
Intercepts and modifies URL requests before they’re sent. Location:src/libs/browser/urlrequestinterceptor.h
Interface
Request Interception
Fromsrc/libs/browser/urlrequestinterceptor.h:19:
- Blocking unwanted requests: Ads, tracking, external resources
- URL rewriting: Redirecting to local HTTP server
- Security controls: Preventing unauthorized access
- Resource optimization: Blocking unnecessary assets
Use Cases
-
Local Documentation Serving
- Rewrite docset:// URLs to http://localhost:port/
- Enable proper CORS and resource loading
-
Privacy Protection
- Block external tracking scripts
- Prevent analytics beacons
-
Resource Control
- Block large unnecessary resources
- Optimize page load times
WebEngine Integration
Profile Management
Zeal uses Qt WebEngine profiles to manage:- Persistent storage: Cookies, cache, local storage
- HTTP user agent: Custom user agent string
- Request interceptor: URL filtering and rewriting
JavaScript Injection
Zeal can inject JavaScript into pages for:- Setting up WebChannel communication
- Applying custom styling
- Adding navigation enhancements
- Implementing keyboard shortcuts
Settings
Web engine settings configured by Zeal:Custom CSS Support
Users can apply custom CSS to all documentation:- Override default documentation styling
- Implement dark mode
- Adjust typography
- Hide unwanted elements
Search Integration
The browser component integrates with search:URL Format
Documentation URLs include search terms for highlighting:Highlight on Navigate
WhenSettings::isHighlightOnNavigateEnabled is true:
- Search terms are extracted from URL
- JavaScript is injected to highlight matches
- Page scrolls to first match
Navigation History
WebView inherits Qt WebEngine’s history management:Developer Tools
In debug builds, the web inspector is available:See Also
- Core Component - HTTP server for documentation serving
- UI Component - Browser tab management
- Registry Component - Search result URLs