ZoneManager
ZoneManager
Manages standard dock zones for consistent UI layout. More…
#include <ZoneManager.hpp>
Inherits from QObject
Public Signals
| Name | |
|---|---|
| void | zonesReady() Emitted when zones are initialized. |
| void | widgetAddedToZone(ads::CDockWidget * dock_widget, Zone zone) Emitted when a widget is added to a zone. |
| void | zoneRatiosChanged() Emitted when zone ratios change. |
| void | configLoaded(QString const & file_path) Emitted when configuration is loaded. |
| void | configSaved(QString const & file_path) Emitted when configuration is saved. |
| void | configLoadError(QString const & error_message) Emitted when configuration load fails. |
Public Functions
| Name | |
|---|---|
| ZoneManager(ads::CDockManager * dock_manager, QObject * parent =[nullptr]) Construct a ZoneManager. |
|
| ~ZoneManager() override =default | |
| void | initializeZones() Initialize the zone structure. |
| bool | zonesInitialized() const Check if zones have been initialized. |
| ads::CDockAreaWidget * | getZoneArea(Zone zone) const Get the dock area for a specific zone. |
| void | addToZone(ads::CDockWidget * dock_widget, Zone zone, bool raise =true) Add a dock widget to a specific zone. |
| void | addBelowInZone(ads::CDockWidget * dock_widget, Zone zone, float size_ratio =0.7f) Add a dock widget below existing content in a zone. |
| Zone | getDefaultZone(QString const & editor_type) const Get the default zone for an editor type. |
| void | setZoneWidthRatios(float left_ratio, float center_ratio, float right_ratio) Set zone width ratios. |
| void | setBottomHeightRatio(float height_ratio) Set bottom zone height ratio. |
| ads::CDockManager * | dockManager() const Get the dock manager. |
| void | refreshZoneAreas() Refresh zone area pointers after ADS restoreState(). |
| ZoneConfig::ZoneLayoutConfig | captureCurrentConfig() const Capture the current layout configuration. |
| bool | applyConfig(ZoneConfig::ZoneLayoutConfig const & config) Apply a layout configuration. |
| QString | loadConfigFromFile(QString const & file_path) Load and apply configuration from file. |
| bool | saveConfigToFile(QString const & file_path) const Save current configuration to file. |
| void | setAutoSaveEnabled(bool enabled) Enable/disable automatic saving of layout changes. |
| bool | isAutoSaveEnabled() const Check if auto-save is enabled. |
| void | setAutoSaveFilePath(QString const & file_path) Set the file path for auto-save. |
| QString | autoSaveFilePath() const Get the current auto-save file path. |
| void | setAutoSaveDebounceMs(int milliseconds) Set the debounce delay for auto-save. |
| ZoneConfig::ZoneRatios | currentRatios() const Get current zone ratios. |
| void | reapplySplitterSizes(int delay_ms =100) Force reapplication of zone ratios to splitters. |
Detailed Description
class ZoneManager;Manages standard dock zones for consistent UI layout.
ZoneManager wraps the ADS (Advanced Docking System) dock manager to provide a higher-level abstraction for placing widgets into standardized UI zones.
The manager:
- Creates placeholder dock areas for each zone during initialization
- Tracks which dock area represents each zone
- Provides methods to add widgets to specific zones
- Handles default zone sizing
Public Signals Documentation
signal zonesReady
void zonesReady()Emitted when zones are initialized.
signal widgetAddedToZone
void widgetAddedToZone(
ads::CDockWidget * dock_widget,
Zone zone
)Emitted when a widget is added to a zone.
Parameters:
- dock_widget The added dock widget
- zone The target zone
signal zoneRatiosChanged
void zoneRatiosChanged()Emitted when zone ratios change.
This is emitted after splitter resizing is complete (debounced).
signal configLoaded
void configLoaded(
QString const & file_path
)Emitted when configuration is loaded.
Parameters:
- file_path Path that was loaded
signal configSaved
void configSaved(
QString const & file_path
)Emitted when configuration is saved.
Parameters:
- file_path Path that was saved to
signal configLoadError
void configLoadError(
QString const & error_message
)Emitted when configuration load fails.
Parameters:
- error_message Description of the error
Public Functions Documentation
function ZoneManager
explicit ZoneManager(
ads::CDockManager * dock_manager,
QObject * parent =nullptr
)Construct a ZoneManager.
Parameters:
- dock_manager The ADS dock manager to wrap
- parent Parent QObject (typically MainWindow)
function ~ZoneManager
~ZoneManager() override =defaultfunction initializeZones
void initializeZones()Initialize the zone structure.
Creates placeholder widgets for each zone to establish the layout. Call this after constructing the dock manager but before adding any content widgets.
This sets up the basic three-column layout:
- Left zone (15% width)
- Center zone (70% width)
- Right zone (15% width)
- Bottom zone (spanning full width, minimal height)
function zonesInitialized
inline bool zonesInitialized() constCheck if zones have been initialized.
function getZoneArea
ads::CDockAreaWidget * getZoneArea(
Zone zone
) constGet the dock area for a specific zone.
Parameters:
- zone The zone to query
Return: Dock area widget, or nullptr if zone not initialized
function addToZone
void addToZone(
ads::CDockWidget * dock_widget,
Zone zone,
bool raise =true
)Add a dock widget to a specific zone.
Parameters:
- dock_widget The dock widget to add
- zone Target zone
- raise If true, make this the active tab in the zone
The widget will be added to the appropriate dock area, tabbed with existing widgets in that zone.
function addBelowInZone
void addBelowInZone(
ads::CDockWidget * dock_widget,
Zone zone,
float size_ratio =0.7f
)Add a dock widget below existing content in a zone.
Parameters:
- dock_widget The dock widget to add
- zone Target zone
- size_ratio Ratio of original content to new content (0.0-1.0)
Creates a vertical split in the zone, placing the new widget below existing content. Useful for adding sub-components to the left or right panels.
function getDefaultZone
Zone getDefaultZone(
QString const & editor_type
) constGet the default zone for an editor type.
Parameters:
- editor_type The editor type ID (e.g., “MediaWidget”, “TestWidget”)
Return: Default zone for this editor type
Maps common editor type strings to their default zones. Used when opening editors without explicit zone specification.
function setZoneWidthRatios
void setZoneWidthRatios(
float left_ratio,
float center_ratio,
float right_ratio
)Set zone width ratios.
Parameters:
- left_ratio Left zone width ratio (default 0.15)
- center_ratio Center zone width ratio (default 0.70)
- right_ratio Right zone width ratio (default 0.15)
Adjusts the relative widths of the left, center, and right zones. Ratios should sum to approximately 1.0.
function setBottomHeightRatio
void setBottomHeightRatio(
float height_ratio
)Set bottom zone height ratio.
Parameters:
- height_ratio Bottom zone height as fraction of total height (default 0.10)
function dockManager
inline ads::CDockManager * dockManager() constGet the dock manager.
function refreshZoneAreas
void refreshZoneAreas()Refresh zone area pointers after ADS restoreState().
ADS restoreState() can destroy and recreate CDockAreaWidget objects, leaving _zone_areas with dangling pointers. This method updates each entry by querying the surviving placeholder dock widget for its current parent dock area.
Call this immediately after CDockManager::restoreState().
function captureCurrentConfig
ZoneConfig::ZoneLayoutConfig captureCurrentConfig() constCapture the current layout configuration.
Return: Current layout configuration
Creates a ZoneLayoutConfig that reflects the current state of the UI, including zone ratios and widget placement. This can be serialized to JSON for persistence.
function applyConfig
bool applyConfig(
ZoneConfig::ZoneLayoutConfig const & config
)Apply a layout configuration.
Parameters:
- config Configuration to apply
Return: true if applied successfully, false on error
Updates zone ratios from the configuration. Note that this only applies size ratios - widget placement must be handled separately by EditorCreationController during startup.
function loadConfigFromFile
QString loadConfigFromFile(
QString const & file_path
)Load and apply configuration from file.
Parameters:
- file_path Path to JSON configuration file
Return: Error message if failed, empty string on success
function saveConfigToFile
bool saveConfigToFile(
QString const & file_path
) constSave current configuration to file.
Parameters:
- file_path Path to output JSON file
Return: true if saved successfully
function setAutoSaveEnabled
void setAutoSaveEnabled(
bool enabled
)Enable/disable automatic saving of layout changes.
Parameters:
- enabled Whether to enable auto-save
When enabled, layout changes (splitter resizing) will be automatically saved to the configured file path after a debounce delay.
function isAutoSaveEnabled
inline bool isAutoSaveEnabled() constCheck if auto-save is enabled.
function setAutoSaveFilePath
void setAutoSaveFilePath(
QString const & file_path
)Set the file path for auto-save.
Parameters:
- file_path Path where configuration will be saved
function autoSaveFilePath
inline QString autoSaveFilePath() constGet the current auto-save file path.
function setAutoSaveDebounceMs
void setAutoSaveDebounceMs(
int milliseconds
)Set the debounce delay for auto-save.
Parameters:
- milliseconds Delay in milliseconds (default: 500)
After a layout change, the system will wait this long before saving to avoid excessive writes during continuous resizing.
function currentRatios
ZoneConfig::ZoneRatios currentRatios() constGet current zone ratios.
function reapplySplitterSizes
void reapplySplitterSizes(
int delay_ms =100
)Force reapplication of zone ratios to splitters.
Parameters:
- delay_ms Delay before applying sizes (default 100ms)
Call this after the main window is shown and has been sized. The sizes are applied via a single-shot timer to ensure the layout has been fully computed.
Updated on 2026-11-13 at 20:25:39 +0000