Files
DualFloatingClock/XML_CONFIG_GUIDE.md
T
2026-04-18 01:53:51 +08:00

2.8 KiB

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

Modified Files

XML Configuration Format

The configuration is stored in XML format with the following structure:

<?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:

./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.