79 lines
2.8 KiB
Markdown
79 lines
2.8 KiB
Markdown
# XML Configuration Implementation
|
|
|
|
## Overview
|
|
|
|
The configuration system has been successfully implemented using XML files instead of QSettings. The new ConfigManager class handles all configuration operations.
|
|
|
|
## Files Created/Modified
|
|
|
|
### New Files
|
|
|
|
- [`configmanager.h`](file:///Users/integzz/Documents/GitHub/qflock/configmanager.h) - Configuration manager header
|
|
- [`configmanager.cpp`](file:///Users/integzz/Documents/GitHub/qflock/configmanager.cpp) - Configuration manager implementation
|
|
- [`config.xml`](file:///Users/integzz/Documents/GitHub/qflock/config.xml) - Default configuration file
|
|
|
|
### Modified Files
|
|
|
|
- [`clockwidget.h`](file:///Users/integzz/Documents/GitHub/qflock/clockwidget.h) - Replaced QSettings with ConfigManager
|
|
- [`clockwidget.cpp`](file:///Users/integzz/Documents/GitHub/qflock/clockwidget.cpp) - Updated to use XML configuration
|
|
- [`flock.pro`](file:///Users/integzz/Documents/GitHub/qflock/flock.pro) - Added new source files
|
|
- [`CMakeLists.txt`](file:///Users/integzz/Documents/GitHub/qflock/CMakeLists.txt) - Added new source files
|
|
|
|
## XML Configuration Format
|
|
|
|
The configuration is stored in XML format with the following structure:
|
|
|
|
```xml
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<QFlockConfig>
|
|
<FontColor>#ffffff</FontColor>
|
|
<BackgroundColor>#96000000</BackgroundColor>
|
|
<FontSize>24</FontSize>
|
|
<AlwaysOnTop>true</AlwaysOnTop>
|
|
<WindowPosition>100,100</WindowPosition>
|
|
</QFlockConfig>
|
|
```
|
|
|
|
## Configuration Options
|
|
|
|
- **FontColor**: Font color in hex format (e.g., #ffffff for white)
|
|
- **BackgroundColor**: Background color in hex format with alpha (e.g., #96000000 for semi-transparent black)
|
|
- **FontSize**: Font size in points (8-72)
|
|
- **AlwaysOnTop**: Boolean value (true/false)
|
|
- **WindowPosition**: Window position as "x,y" coordinates
|
|
|
|
## Usage
|
|
|
|
The configuration is automatically loaded when the application starts and saved when it closes. Users can:
|
|
|
|
1. **Modify settings through the UI**: Right-click on the clock to access the context menu
|
|
2. **Edit config.xml directly**: The file is human-readable and can be edited manually
|
|
3. **Reset to defaults**: Use the "Reset Settings" option in the context menu
|
|
|
|
## Features
|
|
|
|
- ✅ XML-based configuration storage
|
|
- ✅ Automatic loading on startup
|
|
- ✅ Automatic saving on exit
|
|
- ✅ Default values if config file doesn't exist
|
|
- ✅ Human-readable XML format
|
|
- ✅ Error handling for corrupted config files
|
|
- ✅ Manual editing support
|
|
|
|
## Build and Test
|
|
|
|
Use the provided test script to build and verify the XML configuration:
|
|
|
|
```bash
|
|
./test_xml_config.sh
|
|
```
|
|
|
|
This will:
|
|
|
|
1. Clean previous build files
|
|
2. Build the project with XML configuration support
|
|
3. Display the current config.xml content
|
|
4. Provide instructions to run the application
|
|
|
|
The configuration file will be created automatically when you first run the application and make changes to the settings.
|