Overview
TheMainWindow class (Zeal::WidgetUi::MainWindow) is the primary application window for Zeal. It inherits from QMainWindow and manages the overall application UI, including tabs, menu bar, sidebar, and web view stack.
Header: src/libs/ui/mainwindow.h
Namespace: Zeal::WidgetUi
Constructor
app- Pointer to the Core::Application instanceparent- Optional parent widget (defaults to nullptr)
- Sets window title to “Zeal” (or “Zeal Portable” for portable builds)
- Sets default size to 900x600 pixels
- Initializes menu bar, shortcuts, and tab bar
- Creates central widget with splitter layout
- Restores saved window geometry from settings
- Connects to application update check signals
Destructor
Public Methods
search
query- The search query to execute
src/libs/ui/mainwindow.cpp:147
bringToFront
- Shows the window if hidden
- Clears minimized state and sets window active
- Raises window to front
- Activates the window
- Focuses the search edit in the current tab
src/libs/ui/mainwindow.cpp:625
createTab
BrowserTab
Behavior:
- Creates a new
BrowserTabinstance - Navigates to the start page
- Adds the tab to the window
src/libs/ui/mainwindow.cpp:184
Public Slots
toggleWindow
- If window is not visible or not active (when called from global shortcut), brings it to front
- Otherwise, either hides to tray (if tray icon exists) or minimizes the window
src/libs/ui/mainwindow.cpp:744
Signals
currentTabChanged
Protected Methods
changeEvent
closeEvent
eventFilter
- Tab bar: Handles middle-click to close tabs, blocks mouse wheel events
- Menu bar: Auto-hides menu bar on focus loss or Escape key when in auto-hide mode
keyPressEvent
- Escape: Focuses search edit and clears query
- ?: Focuses search edit
Private Slots
applySettings
src/libs/ui/mainwindow.cpp:732
closeTab
src/libs/ui/mainwindow.cpp:154
moveTab
src/libs/ui/mainwindow.cpp:176
duplicateTab
src/libs/ui/mainwindow.cpp:192
UI Components
The main window contains several key UI components:Menu Bar
Managed bysetupMainMenu(), includes:
- File Menu: New Tab, Close Tab, Quit
- Edit Menu: Find in Page, Preferences
- View Menu: Toolbars (Menu Bar toggle) - not available on macOS
- Tools Menu: Docsets Manager
- Help Menu: Submit Feedback, Check for Updates, About
src/libs/ui/mainwindow.cpp:249
Tab Bar
Managed bysetupTabBar(), features:
- Document mode styling
- Tab width of 150 pixels
- Movable and closable tabs
- Keyboard shortcuts (Alt+1 through Alt+9 on Linux, Ctrl+1-9 on other platforms)
- Middle-click to close
- Double-click empty area to create new tab
src/libs/ui/mainwindow.cpp:525
Splitter Layout
The main window uses a horizontal splitter with:- Left side: Sidebar container with search sidebar
- Right side: Stacked widget containing browser tabs
Keyboard Shortcuts
Managed bysetupShortcuts(), includes:
- Ctrl+K / Ctrl+L: Focus search edit
- Ctrl+Alt+T: Duplicate current tab
- Ctrl+B: Toggle sidebar visibility
- Ctrl+Tab / Ctrl+PageDown: Next tab
- Ctrl+Shift+Tab / Ctrl+PageUp: Previous tab
- Browser navigation: Back, Forward, Zoom In/Out, Reset Zoom
- Global shortcut: Configurable hotkey to toggle window (if supported)
src/libs/ui/mainwindow.cpp:422
System Tray Integration
When enabled in settings:- System tray icon with context menu
- Click tray icon to toggle window visibility
- “Show Zeal” / “Minimize to Tray” menu item
- Quit action
src/libs/ui/mainwindow.cpp:583
Member Variables
m_application- Core application instancem_settings- Settings instancem_webBridge- Bridge for web content communicationm_globalShortcut- Global keyboard shortcut handler (if supported)m_menuBar- Main menu barm_tabBar- Tab bar widgetm_splitter- Horizontal splitter for sidebar and contentm_webViewStack- Stacked widget containing browser tabsm_trayIcon- System tray icon (when enabled)
Integration with Other Components
BrowserTab
Each tab is aBrowserTab instance that contains:
- Web view for displaying documentation
- Search sidebar for navigation
- Tab-specific state and history
SearchSidebar
The sidebar is integrated viaSidebarViewProvider and Sidebar::Container:
- Provides search interface
- Displays docset tree and search results
- Integrates with global search functionality
Settings
The window responds to settings changes via theapplySettings() slot:
- Global shortcut updates
- System tray visibility
- Menu bar visibility
- Tab behavior